Fixed following issues reported by SonarQube:
1) Replace this if-then-else statement by a single return statement. (clumsy) 2) 'switch' statements should have at least 3 'case' clauses. (bad practice)pull/33/head
parent
cf64e2c97c
commit
d43518cb3c
|
@ -437,13 +437,12 @@ define('pgadmin.node.function', [
|
|||
if(this.node_info && 'catalog' in this.node_info) {
|
||||
return true;
|
||||
}
|
||||
switch(this.name){
|
||||
case 'prosupportfunc':
|
||||
if(this.name === 'prosupportfunc'){
|
||||
var item = pgAdmin.Browser.tree.selected();
|
||||
if(pgAdmin.Browser.Nodes['function'].getTreeNodeHierarchy(item).server.user.is_superuser)
|
||||
return false;
|
||||
return true;
|
||||
default:
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
|
|
@ -98,12 +98,7 @@ define('pgadmin.node.procedure', [
|
|||
),
|
||||
canVarAdd: function() {
|
||||
var server = this.node_info.server;
|
||||
if (server.version < 90500) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
return !(server.version < 90500);
|
||||
},
|
||||
isVisible: function() {
|
||||
if (this.name == 'sysfunc') { return false; }
|
||||
|
|
|
@ -358,13 +358,12 @@ define('pgadmin.node.trigger_function', [
|
|||
if(this.node_info && 'catalog' in this.node_info) {
|
||||
return true;
|
||||
}
|
||||
switch(this.name){
|
||||
case 'prorows':
|
||||
if (this.name === 'prorows'){
|
||||
if(m.get('proretset') == true) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
default:
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
|
|
@ -661,11 +661,7 @@ define('pgadmin.node.column', [
|
|||
type: 'text', mode: ['properties'], deps: ['is_inherited'],
|
||||
group: gettext('Definition'),
|
||||
visible: function(m) {
|
||||
if (!_.isUndefined(m.get('is_inherited')) && m.get('is_inherited')) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return (!_.isUndefined(m.get('is_inherited')) && m.get('is_inherited'));
|
||||
},
|
||||
},{
|
||||
id: 'is_sys_column', label: gettext('System column?'), cell: 'string',
|
||||
|
@ -871,11 +867,7 @@ define('pgadmin.node.column', [
|
|||
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;
|
||||
},
|
||||
|
@ -903,11 +895,7 @@ define('pgadmin.node.column', [
|
|||
return false;
|
||||
}
|
||||
// if we are in edit mode
|
||||
if (!_.isUndefined(m.get('attnum')) && m.get('attnum') > 0 ) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
return !(!_.isUndefined(m.get('attnum')) && m.get('attnum') > 0 );
|
||||
}
|
||||
return true;
|
||||
},
|
||||
|
@ -947,15 +935,11 @@ define('pgadmin.node.column', [
|
|||
d = i ? t.itemData(i) : null;
|
||||
}
|
||||
// If node is under catalog then do not allow 'create' menu
|
||||
if (_.indexOf(parents, 'catalog') > -1 ||
|
||||
_.indexOf(parents, 'coll-view') > -1 ||
|
||||
_.indexOf(parents, 'coll-mview') > -1 ||
|
||||
_.indexOf(parents, 'mview') > -1 ||
|
||||
_.indexOf(parents, 'view') > -1) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
return !(_.indexOf(parents, 'catalog') > -1 ||
|
||||
_.indexOf(parents, 'coll-view') > -1 ||
|
||||
_.indexOf(parents, 'coll-mview') > -1 ||
|
||||
_.indexOf(parents, 'mview') > -1 ||
|
||||
_.indexOf(parents, 'view') > -1);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
|
|
@ -397,11 +397,7 @@ define('pgadmin.node.compound_trigger', [
|
|||
return false;
|
||||
} else {
|
||||
// if we are in edit mode
|
||||
if (!_.isUndefined(m.get('attnum')) && m.get('attnum') >= 1 ) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
return !(!_.isUndefined(m.get('attnum')) && m.get('attnum') >= 1 );
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -210,11 +210,7 @@ define('pgadmin.node.check_constraint', [
|
|||
d = i ? t.itemData(i) : null;
|
||||
}
|
||||
// If node is under catalog then do not allow 'create' menu
|
||||
if (_.indexOf(parents, 'catalog') > -1) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
return !(_.indexOf(parents, 'catalog') > -1);
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
@ -698,8 +698,7 @@ define('pgadmin.node.exclusion_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');
|
||||
},
|
||||
},{
|
||||
id: 'amname', label: gettext('Access method'),
|
||||
|
|
|
@ -417,11 +417,7 @@ define('pgadmin.node.primary_key', [
|
|||
disabled: function(m) {
|
||||
// Disable if index is selected.
|
||||
var index = m.get('index');
|
||||
if(_.isUndefined(index) || index == '') {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
return !(_.isUndefined(index) || index == '');
|
||||
},
|
||||
},{
|
||||
id: 'include', label: gettext('Include columns'),
|
||||
|
|
Loading…
Reference in New Issue