Fixed following code smells reported by SonarQube:

1) Remove this redundant jump.
 2) Remove this commented out code.
 3) Variables should not be shadowed.
This commit is contained in:
Akshay Joshi
2022-01-21 18:53:48 +05:30
parent 12d6271b13
commit 343c3ee49c
50 changed files with 130 additions and 161 deletions

View File

@@ -381,7 +381,7 @@ export function getMiscellaneousSchema(fieldOptions) {
}
export default class BackupSchema extends BaseUISchema {
constructor(getSectionSchema, getTypeObjSchema, getSaveOptSchema, getQueryOptionSchema, getDisabledOptionSchema, getMiscellaneousSchema, fieldOptions = {}, treeNodeInfo=[], pgBrowser=null, backupType='server') {
constructor(sectionSchema, typeObjSchema, saveOptSchema, queryOptionSchema, disabledOptionSchema, miscellaneousSchema, fieldOptions = {}, treeNodeInfo=[], pgBrowser=null, backupType='server') {
super({
file: undefined,
format: 'custom',
@@ -399,12 +399,12 @@ export default class BackupSchema extends BaseUISchema {
this.treeNodeInfo = treeNodeInfo;
this.pgBrowser = pgBrowser;
this.backupType = backupType;
this.getSectionSchema = getSectionSchema;
this.getTypeObjSchema = getTypeObjSchema;
this.getSaveOptSchema = getSaveOptSchema;
this.getQueryOptionSchema = getQueryOptionSchema;
this.getDisabledOptionSchema = getDisabledOptionSchema;
this.getMiscellaneousSchema = getMiscellaneousSchema;
this.getSectionSchema = sectionSchema;
this.getTypeObjSchema = typeObjSchema;
this.getSaveOptSchema = saveOptSchema;
this.getQueryOptionSchema = queryOptionSchema;
this.getDisabledOptionSchema = disabledOptionSchema;
this.getMiscellaneousSchema = miscellaneousSchema;
}
get idAttribute() {

View File

@@ -46,7 +46,7 @@ export function getMiscellaneousSchema() {
}
export default class BackupGlobalSchema extends BaseUISchema {
constructor(getMiscellaneousSchema, fieldOptions = {}) {
constructor(miscellaneousSchema, fieldOptions = {}) {
super({
id: null,
verbose: true,
@@ -57,7 +57,7 @@ export default class BackupGlobalSchema extends BaseUISchema {
...fieldOptions,
};
this.getMiscellaneousSchema = getMiscellaneousSchema;
this.getMiscellaneousSchema = miscellaneousSchema;
}
get idAttribute() {

View File

@@ -582,9 +582,9 @@ define([
url: baseUrl,
method: 'GET',
})
.done(function(res) {
.done(function(result) {
var data = res.data;
var data = result.data;
var url = url_for('debugger.direct', {
'trans_id': trans_id,

View File

@@ -311,8 +311,8 @@ export default class ERDCore {
let sourceNode = tableNodesDict[onetomanyData.referenced_table_uid];
let targetNode = tableNodesDict[onetomanyData.local_table_uid];
fkColumn.local_column = _.find(targetNode.getColumns(), (col)=>col.attnum==onetomanyData.local_column_attnum).name;
fkColumn.referenced = _.find(sourceNode.getColumns(), (col)=>col.attnum==onetomanyData.referenced_column_attnum).name;
fkColumn.local_column = _.find(targetNode.getColumns(), (colm)=>colm.attnum==onetomanyData.local_column_attnum).name;
fkColumn.referenced = _.find(sourceNode.getColumns(), (colm)=>colm.attnum==onetomanyData.referenced_column_attnum).name;
fkColumn.references = onetomanyData.referenced_table_uid;
fkColumn.references_table_name = sourceNode.getData().name;

View File

@@ -142,7 +142,7 @@ export default function GrantWizard({ sid, did, nodeInfo, nodeData }) {
}, [privileges]);
React.useEffect(() => {
const privSchema = new PrivilegeSchema((privileges) => getNodePrivilegeRoleSchema('', nodeInfo, nodeData, privileges));
const privSchema = new PrivilegeSchema((privs) => getNodePrivilegeRoleSchema('', nodeInfo, nodeData, privs));
setPrivSchemaInstance(privSchema);
setLoaderText('Loading...');
@@ -288,13 +288,13 @@ export default function GrantWizard({ sid, did, nodeInfo, nodeData }) {
selObj.push(row.values);
});
}
var privileges = new Set();
var privs = new Set();
objectTypes.forEach((objType) => {
privOptions[objType]?.acl.forEach((priv) => {
privileges.add(priv);
privs.add(priv);
});
});
setPrivileges(Array.from(privileges));
setPrivileges(Array.from(privs));
setSelectedObject(selObj);
setErrMsg(selObj.length === 0 ? gettext('Please select any database object.') : '');
};

View File

@@ -147,7 +147,6 @@ define([
gettext('Utility not found'),
res.data.errormsg
);
return;
}else{
// Open the Alertify dialog for the import/export module
pgBrowser.Node.registerUtilityPanel();
@@ -179,7 +178,6 @@ define([
gettext('Utility not found'),
gettext('Failed to fetch Utility information')
);
return;
});
},
};

View File

@@ -231,8 +231,8 @@ export default function ImportExportServers() {
<WizardStep stepId={1} className={classes.noOverflow}>
<Box className={classes.boxText}>{gettext('Select the Server Groups/Servers to import/export:')}</Box>
<Box className={classes.treeContainer}>
<CheckBoxTree treeData={serverData} getSelectedServers={(selectedServers) => {
setSelectedServers(selectedServers);
<CheckBoxTree treeData={serverData} getSelectedServers={(selServers) => {
setSelectedServers(selServers);
}}/>
</Box>
</WizardStep>

View File

@@ -179,7 +179,7 @@ define([
panel.focus();
let urlShortcut = 'maintenance.create_job',
baseUrl = url_for(urlShortcut, {
jobUrl = url_for(urlShortcut, {
'sid': treeInfo.server._id,
'did': treeInfo.database._id
});
@@ -191,7 +191,7 @@ define([
});
getUtilityView(
schema, treeInfo, 'select', 'dialog', j[0], panel, that.saveCallBack, extraData, 'OK', baseUrl, sqlHelpUrl, helpUrl);
schema, treeInfo, 'select', 'dialog', j[0], panel, that.saveCallBack, extraData, 'OK', jobUrl, sqlHelpUrl, helpUrl);
}
})
.catch(function() {

View File

@@ -76,7 +76,7 @@ export function getVacuumSchema(fieldOptions) {
//Maintenance Schema
export default class MaintenanceSchema extends BaseUISchema {
constructor(getVacuumSchema, fieldOptions = {}) {
constructor(vacuumSchema, fieldOptions = {}) {
super({
op: 'VACUUM',
verbose: true,
@@ -90,7 +90,7 @@ export default class MaintenanceSchema extends BaseUISchema {
...fieldOptions,
};
this.getVacuumSchema = getVacuumSchema;
this.getVacuumSchema = vacuumSchema;
this.nodeInfo = fieldOptions.nodeInfo;
}

View File

@@ -214,21 +214,21 @@ export function initialize(gettext, url_for, $, _, pgAdmin, csrfToken, Browser)
}
},
getPanelUrls: function(transId, panelTitle, parentData) {
getPanelUrls: function(transId, panelTitle, pData) {
let openUrl = url_for('psql.panel', {
trans_id: transId,
});
const misc_preferences = pgBrowser.get_preferences_for_module('misc');
var theme = misc_preferences.theme;
openUrl += `?sgid=${parentData.server_group._id}`
+`&sid=${parentData.server._id}`
+`&did=${parentData.database._id}`
+`&server_type=${parentData.server.server_type}`
openUrl += `?sgid=${pData.server_group._id}`
+`&sid=${pData.server._id}`
+`&did=${pData.database._id}`
+`&server_type=${pData.server.server_type}`
+ `&theme=${theme}`;
let db_label = '';
if(parentData.database && parentData.database._id) {
db_label = _.escape(parentData.database._label.replace('\\', '\\\\'));
if(pData.database && pData.database._id) {
db_label = _.escape(pData.database._label.replace('\\', '\\\\'));
db_label = db_label.replace('\'', '\'');
db_label = db_label.replace('"', '\"');
openUrl += `&db=${db_label}`;

View File

@@ -331,7 +331,7 @@ export function getRestoreMiscellaneousSchema(fieldOptions) {
//Restore Schema
export default class RestoreSchema extends BaseUISchema {
constructor(getRestoreSectionSchema, getRestoreTypeObjSchema, getRestoreSaveOptSchema, getRestoreQueryOptionSchema, getRestoreDisableOptionSchema, getRestoreMiscellaneousSchema, fieldOptions = {}, treeNodeInfo=[], pgBrowser=null) {
constructor(restoreSectionSchema, restoreTypeObjSchema, restoreSaveOptSchema, restoreQueryOptionSchema, restoreDisableOptionSchema, restoreMiscellaneousSchema, fieldOptions = {}, treeNodeInfo={}, pgBrowser=null) {
super({
custom: false,
file: undefined,
@@ -355,12 +355,12 @@ export default class RestoreSchema extends BaseUISchema {
...fieldOptions,
};
this.getSectionSchema = getRestoreSectionSchema;
this.getRestoreTypeObjSchema = getRestoreTypeObjSchema;
this.getRestoreSaveOptSchema = getRestoreSaveOptSchema;
this.getRestoreQueryOptionSchema = getRestoreQueryOptionSchema;
this.getRestoreDisableOptionSchema = getRestoreDisableOptionSchema;
this.getRestoreMiscellaneousSchema = getRestoreMiscellaneousSchema;
this.getSectionSchema = restoreSectionSchema;
this.getRestoreTypeObjSchema = restoreTypeObjSchema;
this.getRestoreSaveOptSchema = restoreSaveOptSchema;
this.getRestoreQueryOptionSchema = restoreQueryOptionSchema;
this.getRestoreDisableOptionSchema = restoreDisableOptionSchema;
this.getRestoreMiscellaneousSchema = restoreMiscellaneousSchema;
this.treeNodeInfo = treeNodeInfo;
this.pgBrowser = pgBrowser;
}

View File

@@ -860,7 +860,7 @@ export default class SchemaDiffUI {
if (index === -1) self.sel_filters.push(filter);
} else {
$(filter_class).addClass('visibility-hidden');
if(index !== -1 ) delete self.sel_filters[index];
if(index !== -1 ) self.sel_filters.splice(index, 1);
}
}
});