From f0490a54b7db6b07c5a4df1b83a18e1ff833401e Mon Sep 17 00:00:00 2001 From: Aditya Toshniwal Date: Thu, 18 Jun 2020 11:14:56 +0530 Subject: [PATCH] =?UTF-8?q?Fixed=20redundant=20tagged=20issue=20reported?= =?UTF-8?q?=C2=A0by=20SonarQube.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../extensions/static/js/extension.js | 2 +- .../static/js/check_constraint.js | 2 +- .../schemas/tables/indexes/__init__.py | 6 ++---- .../schemas/tables/rules/static/js/rule.js | 2 +- .../tables/triggers/static/js/trigger.js | 5 ++--- .../databases/schemas/views/static/js/mview.js | 4 ++-- .../databases/schemas/views/static/js/view.js | 4 ++-- .../pgagent/steps/static/js/pga_jobstep.js | 2 +- .../servers/roles/static/js/role.js | 4 ++-- web/pgadmin/browser/static/js/browser.js | 2 +- web/pgadmin/browser/static/js/node.js | 3 +-- .../misc/statistics/static/js/statistics.js | 18 ++++++++---------- web/pgadmin/static/js/backform.pgadmin.js | 2 +- web/pgadmin/static/js/keyboard_shortcuts.js | 4 +--- web/pgadmin/static/js/pgadmin.js | 2 +- web/pgadmin/static/js/slickgrid/editors.js | 2 +- .../js/sqleditor/query_tool_notifications.js | 2 +- web/pgadmin/static/js/utils.js | 2 +- web/pgadmin/tools/debugger/static/js/direct.js | 2 +- .../grant_wizard/static/js/grant_wizard.js | 2 +- .../tools/maintenance/static/js/maintenance.js | 2 +- .../tools/sqleditor/static/js/sqleditor.js | 2 +- 22 files changed, 34 insertions(+), 42 deletions(-) diff --git a/web/pgadmin/browser/server_groups/servers/databases/extensions/static/js/extension.js b/web/pgadmin/browser/server_groups/servers/databases/extensions/static/js/extension.js index e66cc5037..1d52e5314 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/extensions/static/js/extension.js +++ b/web/pgadmin/browser/server_groups/servers/databases/extensions/static/js/extension.js @@ -248,7 +248,7 @@ define('pgadmin.node.extension', [ if (_.isUndefined(name) || _.isNull(name) || String(name).replace(/^\s+|\s+$/g, '') == '') { err['name'] = gettext('Name cannot be empty.'); - errmsg = errmsg || err['name']; + errmsg = err['name']; this.errorModel.set('name', errmsg); return errmsg; } diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/static/js/check_constraint.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/static/js/check_constraint.js index 0408ce7fd..209767d46 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/static/js/check_constraint.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/static/js/check_constraint.js @@ -174,7 +174,7 @@ define('pgadmin.node.check_constraint', [ if (_.isUndefined(this.get('consrc')) || String(this.get('consrc')).replace(/^\s+|\s+$/g, '') == '') { err['consrc'] = gettext('Check cannot be empty.'); - errmsg = errmsg || err['consrc']; + errmsg = err['consrc']; } this.errorModel.clear().set(err); diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/__init__.py index aea38879a..c5335cc89 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/__init__.py @@ -1057,16 +1057,14 @@ class IndexesView(PGChildNodeView, SchemaDiffObjectCompare): for key in required_create_keys: if key in diff_dict: - if key == 'columns' and (( + if (key == 'columns' and (( 'added' in diff_dict[key] and len(diff_dict[key]['added']) > 0 ) or ('changed' in diff_dict[key] and len(diff_dict[key]['changed']) > 0) or ( 'deleted' in diff_dict[key] and len(diff_dict[key]['deleted']) > 0) - ): - create_req = True - elif key != 'columns': + )) or key != 'columns': create_req = True if create_req: diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/rules/static/js/rule.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/rules/static/js/rule.js index 5fe213617..d1cd60046 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/rules/static/js/rule.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/rules/static/js/rule.js @@ -211,7 +211,7 @@ define('pgadmin.node.rule', [ String(field_name).replace(/^\s+|\s+$/g, '') === '') { err['name'] = gettext('Please specify name.'); - errmsg = errmsg || err['name']; + errmsg = err['name']; this.errorModel.set('name', errmsg); return errmsg; } diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/static/js/trigger.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/static/js/trigger.js index d3b406957..2cb8f2c7b 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/static/js/trigger.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/static/js/trigger.js @@ -603,7 +603,7 @@ define('pgadmin.node.trigger', [ }, // Disable/Enable Transition tables disableTransition: function(m) { - var flag = true, + var flag = false, evnt = null, name = this.name, evnt_count = 0; @@ -630,8 +630,7 @@ define('pgadmin.node.trigger', [ // Disable New transition table if both UPDATE and INSERT events are disabled if(!m.get('is_constraint_trigger') && m.get('fires') == 'AFTER' && (m.get('evnt_update') || m.get(evnt)) && evnt_count == 1) { - if (m.get('evnt_update') && (_.size(m.get('columns')) >= 1 && m.get('columns')[0] != '')) flag = true; - else flag = false; + flag = (m.get('evnt_update') && (_.size(m.get('columns')) >= 1 && m.get('columns')[0] != '')); } flag && setTimeout(function() { diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/static/js/mview.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/static/js/mview.js index 0f57ed833..47ec5e071 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/static/js/mview.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/static/js/mview.js @@ -258,7 +258,7 @@ define('pgadmin.node.mview', [ if (_.isUndefined(field_name) || _.isNull(field_name) || String(field_name).replace(/^\s+|\s+$/g, '') == '') { err['name'] = gettext('Please specify name.'); - errmsg = errmsg || err['name']; + errmsg = err['name']; this.errorModel.set('name', errmsg); return errmsg; }else{ @@ -267,7 +267,7 @@ define('pgadmin.node.mview', [ if (_.isUndefined(field_def) || _.isNull(field_def) || String(field_def).replace(/^\s+|\s+$/g, '') == '') { err['definition'] = gettext('Please enter view definition.'); - errmsg = errmsg || err['definition']; + errmsg = err['definition']; this.errorModel.set('definition', errmsg); return errmsg; }else{ diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/static/js/view.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/static/js/view.js index bf38c9d9c..0de385d58 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/static/js/view.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/static/js/view.js @@ -223,7 +223,7 @@ define('pgadmin.node.view', [ if (_.isUndefined(field_name) || _.isNull(field_name) || String(field_name).replace(/^\s+|\s+$/g, '') == '') { err['name'] = gettext('Please specify name.'); - errmsg = errmsg || err['name']; + errmsg = err['name']; this.errorModel.set('name', errmsg); return errmsg; }else{ @@ -232,7 +232,7 @@ define('pgadmin.node.view', [ if (_.isUndefined(field_def) || _.isNull(field_def) || String(field_def).replace(/^\s+|\s+$/g, '') == '') { err['definition'] = gettext('Please enter view code.'); - errmsg = errmsg || err['definition']; + errmsg = err['definition']; this.errorModel.set('definition', errmsg); return errmsg; }else{ diff --git a/web/pgadmin/browser/server_groups/servers/pgagent/steps/static/js/pga_jobstep.js b/web/pgadmin/browser/server_groups/servers/pgagent/steps/static/js/pga_jobstep.js index c13b325f7..cbd504c54 100644 --- a/web/pgadmin/browser/server_groups/servers/pgagent/steps/static/js/pga_jobstep.js +++ b/web/pgadmin/browser/server_groups/servers/pgagent/steps/static/js/pga_jobstep.js @@ -120,7 +120,7 @@ define('pgadmin.node.pga_jobstep', [ initialize: function() { pgBrowser.Node.Model.prototype.initialize.apply(this, arguments); if (this.isNew() && this.get('jstconntype')) { - var args = arguments && arguments.length > 1 && arguments[1]; + var args = arguments.length > 1 && arguments[1]; if (args) { if (!_.isUndefined(args['node_info']) || diff --git a/web/pgadmin/browser/server_groups/servers/roles/static/js/role.js b/web/pgadmin/browser/server_groups/servers/roles/static/js/role.js index 359910b16..e92741ba8 100644 --- a/web/pgadmin/browser/server_groups/servers/roles/static/js/role.js +++ b/web/pgadmin/browser/server_groups/servers/roles/static/js/role.js @@ -325,7 +325,7 @@ define('pgadmin.node.role', [ return r.label; }, node_image: function(r) { - if (r == null || r == undefined) + if (!r) return 'icon-role'; return (r.can_login ? 'icon-role' : 'icon-group'); }, @@ -546,7 +546,7 @@ define('pgadmin.node.role', [ if (_.isUndefined(this.get('rolname')) || String(this.get('rolname')).replace(/^\s+|\s+$/g, '') == '') { err['name'] = gettext('Name cannot be empty.'); - errmsg = errmsg || err['name']; + errmsg = err['name']; } if (seclabels) { diff --git a/web/pgadmin/browser/static/js/browser.js b/web/pgadmin/browser/static/js/browser.js index ffd11a0c2..8dc850ccb 100644 --- a/web/pgadmin/browser/static/js/browser.js +++ b/web/pgadmin/browser/static/js/browser.js @@ -689,7 +689,7 @@ define('pgadmin.browser', [ set_master_password: function(password='', button_click=false, set_callback=()=>{}) { let data=null, self = this; - if(password != null || password!='') { + if(!password) { data = JSON.stringify({ 'password': password, 'button_click': button_click, diff --git a/web/pgadmin/browser/static/js/node.js b/web/pgadmin/browser/static/js/node.js index cb8af348c..21a731d21 100644 --- a/web/pgadmin/browser/static/js/node.js +++ b/web/pgadmin/browser/static/js/node.js @@ -888,7 +888,7 @@ define('pgadmin.browser.node', [ return; // Go further only if node type is a Server - if (data && data._type && data._type == 'server') { + if (data._type && data._type == 'server') { var element = $(item).find('span.aciTreeItem').first() || null, // First element will be icon and second will be colour code bgcolor = data.icon.split(' ')[1] || null, @@ -1655,7 +1655,6 @@ define('pgadmin.browser.node', [ if (action) { if (action == 'create') { - onCancelFunc = closePanel; onSaveFunc = saveNewNode; } if (action != 'properties') { diff --git a/web/pgadmin/misc/statistics/static/js/statistics.js b/web/pgadmin/misc/statistics/static/js/statistics.js index ebce79265..0bc08abc8 100644 --- a/web/pgadmin/misc/statistics/static/js/statistics.js +++ b/web/pgadmin/misc/statistics/static/js/statistics.js @@ -368,17 +368,15 @@ define('misc.statistics', [ * We will wait for some time before fetching the statistics for the * selected node. **/ - if (node) { - if (self.timeout) { - clearTimeout(self.timeout); - } - self.timeout = setTimeout( - function() { - self.__updateCollection.call( - self, node.generate_url(item, 'stats', data, true), node, item, data._type - ); - }, 400); + if (self.timeout) { + clearTimeout(self.timeout); } + self.timeout = setTimeout( + function() { + self.__updateCollection.call( + self, node.generate_url(item, 'stats', data, true), node, item, data._type + ); + }, 400); }, __createMultiLineStatistics: function(data, prettifyFields) { diff --git a/web/pgadmin/static/js/backform.pgadmin.js b/web/pgadmin/static/js/backform.pgadmin.js index b96298283..57dbc28f8 100644 --- a/web/pgadmin/static/js/backform.pgadmin.js +++ b/web/pgadmin/static/js/backform.pgadmin.js @@ -3308,7 +3308,7 @@ define([ var fields = this.field.get('fields'); - if (fields == null || fields == undefined) { + if (!fields) { throw new ReferenceError('"fields" not found in keyboard shortcut'); } diff --git a/web/pgadmin/static/js/keyboard_shortcuts.js b/web/pgadmin/static/js/keyboard_shortcuts.js index fba3c9fb8..c02923e24 100644 --- a/web/pgadmin/static/js/keyboard_shortcuts.js +++ b/web/pgadmin/static/js/keyboard_shortcuts.js @@ -131,7 +131,7 @@ function focusDockerPanel(docker, op) { // Mod is used to cycle the op if (op == 'switch') { - let i = 0, total_frames = docker._frameList.length; + let i, total_frames = docker._frameList.length; for(i = 0; i < total_frames; i++) { if(focus_frame === docker._frameList[i]) break; @@ -141,10 +141,8 @@ function focusDockerPanel(docker, op) { flash = true; } else if (op == 'left') { focus_id = getMod(focus_frame._curTab-1, focus_frame._panelList.length); - flash = false; } else if (op == 'right') { focus_id = getMod(focus_frame._curTab+1, focus_frame._panelList.length); - flash = false; } let focus_panel = focus_frame._panelList[focus_id]; diff --git a/web/pgadmin/static/js/pgadmin.js b/web/pgadmin/static/js/pgadmin.js index ac271810a..dc2c2f4c8 100644 --- a/web/pgadmin/static/js/pgadmin.js +++ b/web/pgadmin/static/js/pgadmin.js @@ -142,7 +142,7 @@ define([], function() { value = +value; exp = +exp; // If the value is not a number or the exp is not an integer... - if (isNaN(value) || !(typeof exp === 'number' && exp % 1 === 0)) { + if (isNaN(value) || exp % 1 !== 0) { return NaN; } // Shift diff --git a/web/pgadmin/static/js/slickgrid/editors.js b/web/pgadmin/static/js/slickgrid/editors.js index 1647d4b82..f6328b8ec 100644 --- a/web/pgadmin/static/js/slickgrid/editors.js +++ b/web/pgadmin/static/js/slickgrid/editors.js @@ -671,7 +671,7 @@ import gettext from 'sources/gettext'; var value = item[args.column.field]; // Check if value is null or undefined - if (value === undefined && typeof value === 'undefined') { + if (value === null || typeof value === 'undefined') { value = ''; } defaultValue = value; diff --git a/web/pgadmin/static/js/sqleditor/query_tool_notifications.js b/web/pgadmin/static/js/sqleditor/query_tool_notifications.js index 37ab6d9bc..c62c41777 100644 --- a/web/pgadmin/static/js/sqleditor/query_tool_notifications.js +++ b/web/pgadmin/static/js/sqleditor/query_tool_notifications.js @@ -104,7 +104,7 @@ let queryToolNotifications = { }); // Render the grid - if (notifications_grid && notifications_panel) + if (notifications_panel) notifications_panel.$container.find('.sql-editor-notifications').append(notifications_grid.render().el); }, diff --git a/web/pgadmin/static/js/utils.js b/web/pgadmin/static/js/utils.js index b0c9165af..89b0c5858 100644 --- a/web/pgadmin/static/js/utils.js +++ b/web/pgadmin/static/js/utils.js @@ -181,7 +181,7 @@ export function parseFuncParams(label) { paramName = '', paramModes = ['IN', 'OUT', 'INOUT', 'VARIADIC']; - paramStart = i = 0; + i = 0; while(i < paramStr.length) { if(paramStr[i] == '"') { /* If quotes, skip all the chars till next quote */ diff --git a/web/pgadmin/tools/debugger/static/js/direct.js b/web/pgadmin/tools/debugger/static/js/direct.js index 74cd7b7b2..cc3b579c3 100644 --- a/web/pgadmin/tools/debugger/static/js/direct.js +++ b/web/pgadmin/tools/debugger/static/js/direct.js @@ -1562,7 +1562,7 @@ define([ ); } }); - } else if (trans_id != undefined && debug_type) { + } else if (trans_id != undefined) { // Make ajax call to execute the and start the target for execution baseUrl = url_for('debugger.start_listener', { 'trans_id': trans_id, diff --git a/web/pgadmin/tools/grant_wizard/static/js/grant_wizard.js b/web/pgadmin/tools/grant_wizard/static/js/grant_wizard.js index dff68eaa1..4c98c32b5 100644 --- a/web/pgadmin/tools/grant_wizard/static/js/grant_wizard.js +++ b/web/pgadmin/tools/grant_wizard/static/js/grant_wizard.js @@ -79,7 +79,7 @@ define([ node = this.get('objects').toJSON(); if (_.isEmpty(node)) { err['selected'] = gettext('Please select any database object.'); - errmsg = errmsg || err['selected']; + errmsg = err['selected']; this.errorModel.set('selected', errmsg); return errmsg; } else { diff --git a/web/pgadmin/tools/maintenance/static/js/maintenance.js b/web/pgadmin/tools/maintenance/static/js/maintenance.js index 73a7029f0..476d8f4e0 100644 --- a/web/pgadmin/tools/maintenance/static/js/maintenance.js +++ b/web/pgadmin/tools/maintenance/static/js/maintenance.js @@ -247,7 +247,7 @@ define([ if (!d) return; - var node = d && pgBrowser.Nodes[d._type], + var node = pgBrowser.Nodes[d._type], treeInfo = node.getTreeNodeHierarchy.apply(node, [i]); if (treeInfo.database._label.indexOf('=') >= 0) { diff --git a/web/pgadmin/tools/sqleditor/static/js/sqleditor.js b/web/pgadmin/tools/sqleditor/static/js/sqleditor.js index 0f3874e25..4271d51ad 100644 --- a/web/pgadmin/tools/sqleditor/static/js/sqleditor.js +++ b/web/pgadmin/tools/sqleditor/static/js/sqleditor.js @@ -2316,7 +2316,7 @@ define('tools.querytool', [ }) .done(function(res) { self.gridView.query_tool_obj.refresh(); - if (res && res !== '') { + if (res) { self.gridView.query_tool_obj.setValue(res); } })