Replace if-then-else statement by a single return statement, issue reported by SonarQube.

This commit is contained in:
Satish V 2020-06-18 15:51:01 +05:30 committed by Akshay Joshi
parent a278e8b1e6
commit 905be1d894
6 changed files with 10 additions and 41 deletions

View File

@ -527,8 +527,7 @@ define('pgadmin.node.primary_key', [
select2:{allowClear:false},
filter: function(m) {
// Don't show pg_global tablespace in selection.
if (m.label == 'pg_global') return false;
else return true;
return (m.label != 'pg_global');
},
disabled: function(m) {
// Disable if index is selected.

View File

@ -517,8 +517,7 @@ define('pgadmin.node.unique_constraint', [
select2:{allowClear:false},
filter: function(m) {
// Don't show pg_global tablespace in selection.
if (m.label == 'pg_global') return false;
else return true;
return (m.label != 'pg_global');
},
disabled: function(m) {
// Disable if index is selected.

View File

@ -192,11 +192,7 @@ define('pgadmin.node.index', [
inSchemaWithModelCheck: function(m) {
if(m.top.node_info && 'schema' in m.top.node_info) {
// We will disable control if it's in 'edit' mode
if (m.top.isNew()) {
return false;
} else {
return true;
}
return !m.top.isNew();
}
return true;
},
@ -419,20 +415,12 @@ define('pgadmin.node.index', [
group: gettext('Definition'), model: ColumnModel, mode: ['edit', 'create'],
canAdd: function(m) {
// We will disable it if it's in 'edit' mode
if (m.isNew()) {
return true;
} else {
return false;
}
return m.isNew();
},
canEdit: false,
canDelete: function(m) {
// We will disable it if it's in 'edit' mode
if (m.isNew()) {
return true;
} else {
return false;
}
return m.isNew();
},
control: 'unique-col-collection', uniqueCol : ['colname'],
columns: ['colname', 'op_class', 'sort_order', 'nulls', 'collspcname'],
@ -532,11 +520,7 @@ define('pgadmin.node.index', [
inSchemaWithModelCheck: function(m) {
if(this.node_info && 'schema' in this.node_info) {
// We will disable control if it's in 'edit' mode
if (m.isNew()) {
return false;
} else {
return true;
}
return !m.isNew();
}
return true;
},

View File

@ -1204,22 +1204,14 @@ function(
canCreate_with_trigger_enable: function(itemData, item, data) {
if(this.canCreate.apply(this, [itemData, item, data])) {
// We are here means we can create menu, now let's check condition
if(itemData.tigger_count > 0) {
return true;
} else {
return false;
}
return (itemData.tigger_count > 0);
}
},
// Check to whether table has enable trigger(s)
canCreate_with_trigger_disable: function(itemData, item, data) {
if(this.canCreate.apply(this, [itemData, item, data])) {
// We are here means we can create menu, now let's check condition
if(itemData.tigger_count > 0 && itemData.has_enable_triggers > 0) {
return true;
} else {
return false;
}
return (itemData.tigger_count > 0 && itemData.has_enable_triggers > 0);
}
},
});

View File

@ -385,11 +385,7 @@ define('pgadmin.node.type', [
group: gettext('Definition'), mode: ['edit', 'create'],
canAdd: true, canEdit: false, canDelete: function(m) {
// We will disable it if it's in 'edit' mode
if (m.isNew()) {
return true;
} else {
return false;
}
return m.isNew();
},
disabled: 'inSchema', deps: ['typtype'],
control: 'unique-col-collection', uniqueCol : ['label'],

View File

@ -201,8 +201,7 @@ define('pgadmin.node.mview', [
type: 'text', group: gettext('Storage'), first_empty: false,
control: 'node-list-by-name', node: 'tablespace', select2: { allowClear: false },
filter: function(m) {
if (m.label == 'pg_global') return false;
else return true;
return (m.label != 'pg_global');
},
},{
id: 'fillfactor', label: gettext('Fill factor'),