mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
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)
This commit is contained in:
parent
cf64e2c97c
commit
d43518cb3c
@ -437,13 +437,12 @@ define('pgadmin.node.function', [
|
|||||||
if(this.node_info && 'catalog' in this.node_info) {
|
if(this.node_info && 'catalog' in this.node_info) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
switch(this.name){
|
if(this.name === 'prosupportfunc'){
|
||||||
case 'prosupportfunc':
|
|
||||||
var item = pgAdmin.Browser.tree.selected();
|
var item = pgAdmin.Browser.tree.selected();
|
||||||
if(pgAdmin.Browser.Nodes['function'].getTreeNodeHierarchy(item).server.user.is_superuser)
|
if(pgAdmin.Browser.Nodes['function'].getTreeNodeHierarchy(item).server.user.is_superuser)
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
default:
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -98,12 +98,7 @@ define('pgadmin.node.procedure', [
|
|||||||
),
|
),
|
||||||
canVarAdd: function() {
|
canVarAdd: function() {
|
||||||
var server = this.node_info.server;
|
var server = this.node_info.server;
|
||||||
if (server.version < 90500) {
|
return !(server.version < 90500);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
isVisible: function() {
|
isVisible: function() {
|
||||||
if (this.name == 'sysfunc') { return false; }
|
if (this.name == 'sysfunc') { return false; }
|
||||||
|
@ -358,13 +358,12 @@ define('pgadmin.node.trigger_function', [
|
|||||||
if(this.node_info && 'catalog' in this.node_info) {
|
if(this.node_info && 'catalog' in this.node_info) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
switch(this.name){
|
if (this.name === 'prorows'){
|
||||||
case 'prorows':
|
|
||||||
if(m.get('proretset') == true) {
|
if(m.get('proretset') == true) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
default:
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -661,11 +661,7 @@ define('pgadmin.node.column', [
|
|||||||
type: 'text', mode: ['properties'], deps: ['is_inherited'],
|
type: 'text', mode: ['properties'], deps: ['is_inherited'],
|
||||||
group: gettext('Definition'),
|
group: gettext('Definition'),
|
||||||
visible: function(m) {
|
visible: function(m) {
|
||||||
if (!_.isUndefined(m.get('is_inherited')) && m.get('is_inherited')) {
|
return (!_.isUndefined(m.get('is_inherited')) && m.get('is_inherited'));
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
},{
|
},{
|
||||||
id: 'is_sys_column', label: gettext('System column?'), cell: 'string',
|
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)
|
if(this.node_info && 'schema' in this.node_info)
|
||||||
{
|
{
|
||||||
// We will disable control if it's in 'edit' mode
|
// We will disable control if it's in 'edit' mode
|
||||||
if (m.isNew()) {
|
return !(m.isNew());
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
@ -903,11 +895,7 @@ define('pgadmin.node.column', [
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// if we are in edit mode
|
// if we are in edit mode
|
||||||
if (!_.isUndefined(m.get('attnum')) && m.get('attnum') > 0 ) {
|
return !(!_.isUndefined(m.get('attnum')) && m.get('attnum') > 0 );
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
@ -947,15 +935,11 @@ define('pgadmin.node.column', [
|
|||||||
d = i ? t.itemData(i) : null;
|
d = i ? t.itemData(i) : null;
|
||||||
}
|
}
|
||||||
// If node is under catalog then do not allow 'create' menu
|
// If node is under catalog then do not allow 'create' menu
|
||||||
if (_.indexOf(parents, 'catalog') > -1 ||
|
return !(_.indexOf(parents, 'catalog') > -1 ||
|
||||||
_.indexOf(parents, 'coll-view') > -1 ||
|
_.indexOf(parents, 'coll-view') > -1 ||
|
||||||
_.indexOf(parents, 'coll-mview') > -1 ||
|
_.indexOf(parents, 'coll-mview') > -1 ||
|
||||||
_.indexOf(parents, 'mview') > -1 ||
|
_.indexOf(parents, 'mview') > -1 ||
|
||||||
_.indexOf(parents, 'view') > -1) {
|
_.indexOf(parents, 'view') > -1);
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -397,11 +397,7 @@ define('pgadmin.node.compound_trigger', [
|
|||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
// if we are in edit mode
|
// if we are in edit mode
|
||||||
if (!_.isUndefined(m.get('attnum')) && m.get('attnum') >= 1 ) {
|
return !(!_.isUndefined(m.get('attnum')) && m.get('attnum') >= 1 );
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -210,11 +210,7 @@ define('pgadmin.node.check_constraint', [
|
|||||||
d = i ? t.itemData(i) : null;
|
d = i ? t.itemData(i) : null;
|
||||||
}
|
}
|
||||||
// If node is under catalog then do not allow 'create' menu
|
// If node is under catalog then do not allow 'create' menu
|
||||||
if (_.indexOf(parents, 'catalog') > -1) {
|
return !(_.indexOf(parents, 'catalog') > -1);
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -698,8 +698,7 @@ define('pgadmin.node.exclusion_constraint', [
|
|||||||
select2:{allowClear:false},
|
select2:{allowClear:false},
|
||||||
filter: function(m) {
|
filter: function(m) {
|
||||||
// Don't show pg_global tablespace in selection.
|
// Don't show pg_global tablespace in selection.
|
||||||
if (m.label == 'pg_global') return false;
|
return !(m.label == 'pg_global');
|
||||||
else return true;
|
|
||||||
},
|
},
|
||||||
},{
|
},{
|
||||||
id: 'amname', label: gettext('Access method'),
|
id: 'amname', label: gettext('Access method'),
|
||||||
|
@ -417,11 +417,7 @@ define('pgadmin.node.primary_key', [
|
|||||||
disabled: function(m) {
|
disabled: function(m) {
|
||||||
// Disable if index is selected.
|
// Disable if index is selected.
|
||||||
var index = m.get('index');
|
var index = m.get('index');
|
||||||
if(_.isUndefined(index) || index == '') {
|
return !(_.isUndefined(index) || index == '');
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
},{
|
},{
|
||||||
id: 'include', label: gettext('Include columns'),
|
id: 'include', label: gettext('Include columns'),
|
||||||
|
Loading…
Reference in New Issue
Block a user