Fixed redundant tagged issue reported by SonarQube.

This commit is contained in:
Aditya Toshniwal 2020-06-18 11:14:56 +05:30 committed by Akshay Joshi
parent 5ed1e1e5b6
commit f0490a54b7
22 changed files with 34 additions and 42 deletions

View File

@ -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;
}

View File

@ -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);

View File

@ -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:

View File

@ -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;
}

View File

@ -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() {

View File

@ -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{

View File

@ -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{

View File

@ -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']) ||

View File

@ -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) {

View File

@ -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,

View File

@ -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') {

View File

@ -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) {

View File

@ -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');
}

View File

@ -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];

View File

@ -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

View File

@ -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;

View File

@ -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);
},

View File

@ -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 */

View File

@ -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,

View File

@ -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 {

View File

@ -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) {

View File

@ -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);
}
})