Fixed following SonarQube issues:

1. Boolean checks should not be inverted.
2. The comma operator should not be used.
3. Arguments to built-in functions should match documented types.
4. Redundant pairs of parentheses should be removed.
5. A conditionally executed single line should be denoted by indentation, 
6. A while loop should be used instead of a 'for' loop.
This commit is contained in:
Yogesh Mahajan 2020-06-26 13:12:07 +05:30 committed by Akshay Joshi
parent 6a63279396
commit 707ff450b5
8 changed files with 17 additions and 12 deletions

View File

@ -776,7 +776,7 @@ define('pgadmin.node.type', [
if(acl.length > 0)
acl.reset();
}
return !(m.get('typtype') === 'p');
return (m.get('typtype') !== 'p');
},
},{
id: 'seclabels', label: gettext('Security labels'),
@ -792,7 +792,7 @@ define('pgadmin.node.type', [
if(secLabs.length > 0)
secLabs.reset();
}
return !(m.get('typtype') === 'p');
return (m.get('typtype') !== 'p');
},
}],
validate: function() {

View File

@ -26,7 +26,7 @@
let tokenSetNo = 0;
let startTkn = tokenSet[tokenSetNo].start,
endTkn = tokenSet[tokenSetNo].end;
for (; at > 0;) {
while (at > 0) {
var found = lineText.lastIndexOf(startTkn, at);
var startToken = startTkn;
var endToken = endTkn;
@ -57,7 +57,8 @@
outer: for (var i = line + 1; i < lastLine; ++i) {
var text = cm.getLine(i),
pos = 0;
for (;;) {
var whileloopvar = 0;
while (whileloopvar < 1) {
var nextOpen = text.indexOf(startToken, pos),
nextClose = text.indexOf(endToken, pos);
if (nextOpen < 0) nextOpen = text.length;

View File

@ -66,7 +66,7 @@ define([], function() {
c = [1 / 25.4, 1 / 2.54, 1 / 72, 1 / 6],
f = ['mm', 'cm', 'pt', 'pc', 'in', 'mozmm'],
u = 6;
for (i.appendChild(n), m && (n.style.marginTop = '1%', p = '1%' === m(n).marginTop); u--;) d[f[u] + 'toPx'] = c[u] ? c[u] * d.inToPx : r(n, '1' + f[u]);
for (i.appendChild(n), m && ((n.style.marginTop = '1%'), (p = '1%' === m(n).marginTop)); u--;) d[f[u] + 'toPx'] = c[u] ? c[u] * d.inToPx : r(n, '1' + f[u]);
i.removeChild(n); t.toPx = r;
})(pgAdmin, window.document);

View File

@ -191,7 +191,8 @@ define(['jquery', 'underscore', 'sources/gettext', 'sources/url_for'],
calcFontSize: function(fontSize) {
if(fontSize) {
let rounded = Number((Math.round(fontSize + 'e+2') + 'e-2'));
fontSize = parseFloat((Math.round(parseFloat(fontSize + 'e+2')) + 'e-2'));
let rounded = Number(fontSize);
if(rounded > 0) {
return rounded + 'em';
}

View File

@ -210,7 +210,7 @@ define([
type: 'int',
deps: ['format'],
disabled: function(m) {
return !(m.get('format') === 'directory');
return (m.get('format') !== 'directory');
},
visible: function(m) {
if (!_.isUndefined(m.get('type')) && m.get('type') === 'server')

View File

@ -1590,8 +1590,9 @@ define([
);
}
});
} else
} else {
this.intializePanels();
}
},
// Read the messages of the database server and get the port ID and attach

View File

@ -3536,8 +3536,9 @@ define('tools.querytool', [
return 2000;
} else if (seconds >= 90) {
return 5000;
} else
} else {
return 1;
}
};
},
@ -3857,8 +3858,9 @@ define('tools.querytool', [
if (res.data.status) {
// Refresh the sql grid
queryToolActions.executeQuery(self);
} else
} else {
alertify.alert(gettext('Change limit Error'), res.data.result);
}
}, 10
);
})

View File

@ -535,8 +535,8 @@ define([
} else {
if ((_.isUndefined(this.get('newPassword')) || _.isNull(this.get('newPassword')) ||
this.get('newPassword') == '') &&
((_.isUndefined(this.get('confirmPassword')) || _.isNull(this.get('confirmPassword')) ||
this.get('confirmPassword') == ''))) {
(_.isUndefined(this.get('confirmPassword')) || _.isNull(this.get('confirmPassword')) ||
this.get('confirmPassword') == '')) {
this.errorModel.unset('newPassword');
if (this.get('newPassword') == '') {