Fixed sonaqube security smells and bugs

1. Delete unreachable code or refactor the code to make it reachable.
2. Unexpected var, use let or const instead.
3. Remove useless assignment to variable.
4. Define a constant instead of duplicating the literal
5. Remove commented out code
This commit is contained in:
Pravesh Sharma
2023-07-10 10:36:15 +05:30
committed by GitHub
parent 9aa116bf3f
commit 62056cab14
14 changed files with 27 additions and 60 deletions

View File

@@ -33,10 +33,14 @@ export default class CastSchema extends BaseUISchema {
let srctype = state.srctyp;
let trgtype = state.trgtyp;
if(srctype != undefined && srctype != '' &&
trgtype != undefined && trgtype != '')
return state.name = srctype+'->'+trgtype;
else
return state.name = '';
trgtype != undefined && trgtype != '') {
state.name = srctype+'->'+trgtype;
return state.name;
}
else {
state.name = '';
return state.name;
}
}
get baseFields() {

View File

@@ -169,6 +169,7 @@ class PublicationView(PGChildNodeView, SchemaDiffObjectCompare):
gettext("Could not find the publication information.")
node_type = blueprint.node_type
BASE_TEMPLATE_PATH = 'publications/{0}/#{1}#/sql'
GET_PUB_SCHEMAS_SQL = 'get_pub_schemas.sql'
parent_ids = [
{'type': 'int', 'id': 'gid'},
@@ -380,7 +381,7 @@ class PublicationView(PGChildNodeView, SchemaDiffObjectCompare):
if not res['rows'][0]['all_table']:
if self.manager.version >= 150000:
schema_name_sql = render_template(
"/".join([self.template_path, 'get_pub_schemas.sql']),
"/".join([self.template_path, self.GET_PUB_SCHEMAS_SQL]),
pbid=pbid
)
status, snames_list_res = self.conn.execute_dict(
@@ -736,7 +737,7 @@ class PublicationView(PGChildNodeView, SchemaDiffObjectCompare):
if self.manager.version >= 150000:
schema_name_sql = render_template(
"/".join([self.template_path, 'get_pub_schemas.sql']),
"/".join([self.template_path, self.GET_PUB_SCHEMAS_SQL]),
pbid=pbid
)
status, snames_list_res = self.conn.execute_dict(
@@ -949,7 +950,7 @@ class PublicationView(PGChildNodeView, SchemaDiffObjectCompare):
if self.manager.version >= 150000:
schema_name_sql = render_template(
"/".join([self.template_path, 'get_pub_schemas.sql']),
"/".join([self.template_path, self.GET_PUB_SCHEMAS_SQL]),
pbid=pbid
)
status, snames_list_res = self.conn.execute_dict(

View File

@@ -40,10 +40,7 @@ export class DomainConstSchema extends BaseUISchema {
type: 'checkbox',
readonly: function(state) {
let currCon = _.find(obj.top.origData.constraints, (con)=>con.conoid == state.conoid);
if (!obj.isNew(state) && currCon.convalidated) {
return true;
}
return false;
return !obj.isNew(state) && currCon.convalidated ? true : false;
},
}
];

View File

@@ -97,10 +97,7 @@ export default class SynonymSchema extends BaseUISchema {
};
},
readonly: function() {
if(!obj.inCatalog()) {
return false;
}
return true;
return !obj.inCatalog() ? false : true;
}
}, {
id: 'is_sys_obj', label: gettext('System synonym?'),

View File

@@ -666,8 +666,6 @@ define('pgadmin.node.server', [
// Check the database server against supported version.
checkSupportedVersion(_data.version, res.info);
// obj.trigger('connected', obj, _item, _data);
// Generate the event that server is connected
pgBrowser.Events.trigger(
'pgadmin:server:connected', _data._id, _item, _data