Fixed code smell 'potential hiding of variables declared in an outer scope'.

This commit is contained in:
Aditya Toshniwal 2020-07-16 19:53:39 +05:30 committed by Akshay Joshi
parent 703faf3b15
commit 9d0f3ce90b
9 changed files with 65 additions and 65 deletions

View File

@ -21,13 +21,13 @@ define([
'jquery', 'underscore', 'pgadmin.alertifyjs', 'jquery', 'underscore', 'pgadmin.alertifyjs',
'sources/gettext', 'sources/url_for', 'dropzone', 'sources/pgadmin', 'sources/gettext', 'sources/url_for', 'dropzone', 'sources/pgadmin',
'sources/csrf', 'tablesorter', 'tablesorter-metric', 'sources/csrf', 'tablesorter', 'tablesorter-metric',
], function($, _, Alertify, gettext, url_for, Dropzone, pgAdmin, csrfToken) { ], function($, _, Alertify, gettext, url_for, Dropzone, pgAdmin, csrf) {
/*--------------------------------------------------------- /*---------------------------------------------------------
Define functions used for various operations Define functions used for various operations
---------------------------------------------------------*/ ---------------------------------------------------------*/
// Set the CSRF Token // Set the CSRF Token
csrfToken.setPGCSRFToken(pgAdmin.csrf_token_header, pgAdmin.csrf_token); csrf.setPGCSRFToken(pgAdmin.csrf_token_header, pgAdmin.csrf_token);
// Return file extension // Return file extension
var getFileExtension = function(name) { var getFileExtension = function(name) {

View File

@ -23,9 +23,9 @@ define('pgadmin.misc.explain', [
var initSnap = function(snapModule) { var initSnap = function(snapModule) {
Snap = snapModule; Snap = snapModule;
// Snap.svg plug-in to write multitext as image name // Snap.svg plug-in to write multitext as image name
Snap.plugin(function(Snap, Element, Paper) { Snap.plugin(function(_Snap, Element, Paper) {
Paper.prototype.multitext = function(x, y, txt, max_width, attributes) { Paper.prototype.multitext = function(x, y, txt, max_width, attributes) {
var svg = Snap(), var svg = _Snap(),
abc = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', abc = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
temp = svg.text(0, 0, abc); temp = svg.text(0, 0, abc);
@ -1431,7 +1431,7 @@ define('pgadmin.misc.explain', [
curr_zoom_factor = curr_zoom_factor < MIN_ZOOM_FACTOR ? MIN_ZOOM_FACTOR : curr_zoom_factor; curr_zoom_factor = curr_zoom_factor < MIN_ZOOM_FACTOR ? MIN_ZOOM_FACTOR : curr_zoom_factor;
curr_zoom_factor = curr_zoom_factor > INIT_ZOOM_FACTOR ? INIT_ZOOM_FACTOR : curr_zoom_factor; curr_zoom_factor = curr_zoom_factor > INIT_ZOOM_FACTOR ? INIT_ZOOM_FACTOR : curr_zoom_factor;
var zoomInMatrix = new Snap.matrix(); let zoomInMatrix = new Snap.matrix();
zoomInMatrix.scale(curr_zoom_factor, curr_zoom_factor); zoomInMatrix.scale(curr_zoom_factor, curr_zoom_factor);
$svg.find('g').first().attr({ $svg.find('g').first().attr({
@ -1446,7 +1446,7 @@ define('pgadmin.misc.explain', [
zoomInBtn.on('click', function() { zoomInBtn.on('click', function() {
curr_zoom_factor = ((curr_zoom_factor + ZOOM_RATIO) > MAX_ZOOM_FACTOR) ? MAX_ZOOM_FACTOR : (curr_zoom_factor + ZOOM_RATIO); curr_zoom_factor = ((curr_zoom_factor + ZOOM_RATIO) > MAX_ZOOM_FACTOR) ? MAX_ZOOM_FACTOR : (curr_zoom_factor + ZOOM_RATIO);
var zoomInMatrix = new Snap.matrix(); let zoomInMatrix = new Snap.matrix();
zoomInMatrix.scale(curr_zoom_factor, curr_zoom_factor); zoomInMatrix.scale(curr_zoom_factor, curr_zoom_factor);
$svg.find('g').first().attr({ $svg.find('g').first().attr({
@ -1461,7 +1461,7 @@ define('pgadmin.misc.explain', [
zoomOutBtn.on('click', function() { zoomOutBtn.on('click', function() {
curr_zoom_factor = ((curr_zoom_factor - ZOOM_RATIO) < MIN_ZOOM_FACTOR) ? MIN_ZOOM_FACTOR : (curr_zoom_factor - ZOOM_RATIO); curr_zoom_factor = ((curr_zoom_factor - ZOOM_RATIO) < MIN_ZOOM_FACTOR) ? MIN_ZOOM_FACTOR : (curr_zoom_factor - ZOOM_RATIO);
var zoomInMatrix = new Snap.matrix(); let zoomInMatrix = new Snap.matrix();
zoomInMatrix.scale(curr_zoom_factor, curr_zoom_factor); zoomInMatrix.scale(curr_zoom_factor, curr_zoom_factor);
$svg.find('g').first().attr({ $svg.find('g').first().attr({
@ -1476,7 +1476,7 @@ define('pgadmin.misc.explain', [
zoomToNormal.on('click', function() { zoomToNormal.on('click', function() {
curr_zoom_factor = INIT_ZOOM_FACTOR; curr_zoom_factor = INIT_ZOOM_FACTOR;
var zoomInMatrix = new Snap.matrix(); let zoomInMatrix = new Snap.matrix();
zoomInMatrix.scale(curr_zoom_factor, curr_zoom_factor); zoomInMatrix.scale(curr_zoom_factor, curr_zoom_factor);
$svg.find('g').first().attr({ $svg.find('g').first().attr({

View File

@ -13,7 +13,7 @@
* @namespace Slick * @namespace Slick
*/ */
import JSONBigNumber from 'json-bignumber'; import JSONBigNumberLib from 'json-bignumber';
import gettext from 'sources/gettext'; import gettext from 'sources/gettext';
(function($, JSONBigNumber) { (function($, JSONBigNumber) {
@ -975,4 +975,4 @@ import gettext from 'sources/gettext';
this.init(); this.init();
} }
})(window.jQuery, JSONBigNumber); })(window.jQuery, JSONBigNumberLib);

View File

@ -19,10 +19,10 @@
// Set up Backform appropriately for the environment. Start with AMD. // Set up Backform appropriately for the environment. Start with AMD.
if (typeof define === 'function' && define.amd) { if (typeof define === 'function' && define.amd) {
define(['underscore', 'jquery', 'backbone'], function(_, $, Backbone) { define(['underscore', 'jquery', 'backbone'], function(underscore, $, Backbone) {
// Export global even in AMD case in case this script is loaded with // Export global even in AMD case in case this script is loaded with
// others that may still expect a global Backform. // others that may still expect a global Backform.
return factory(root, _, $, Backbone); return factory(root, underscore, $, Backbone);
}); });
// Next for Node.js or CommonJS. jQuery may not be needed as a module. // Next for Node.js or CommonJS. jQuery may not be needed as a module.

View File

@ -449,8 +449,8 @@ var requirejs, require, define;
if (prefix) { if (prefix) {
if (pluginModule && pluginModule.normalize) { if (pluginModule && pluginModule.normalize) {
//Plugin is loaded, use its normalize method. //Plugin is loaded, use its normalize method.
normalizedName = pluginModule.normalize(name, function (name) { normalizedName = pluginModule.normalize(name, function (_name) {
return normalize(name, parentName, applyMap); return normalize(_name, parentName, applyMap);
}); });
} else { } else {
// If nested plugin references, then do not try to // If nested plugin references, then do not try to
@ -962,8 +962,8 @@ var requirejs, require, define;
if (this.map.unnormalized) { if (this.map.unnormalized) {
//Normalize the ID if the plugin allows it. //Normalize the ID if the plugin allows it.
if (plugin.normalize) { if (plugin.normalize) {
name = plugin.normalize(name, function (name) { name = plugin.normalize(name, function (_name) {
return normalize(name, parentName, true); return normalize(_name, parentName, true);
}) || ''; }) || '';
} }
@ -1267,11 +1267,11 @@ var requirejs, require, define;
* Set a configuration for the context. * Set a configuration for the context.
* @param {Object} cfg config object to integrate. * @param {Object} cfg config object to integrate.
*/ */
configure: function (cfg) { configure: function (_cfg) {
//Make sure the baseUrl ends in a slash. //Make sure the baseUrl ends in a slash.
if (cfg.baseUrl) { if (_cfg.baseUrl) {
if (cfg.baseUrl.charAt(cfg.baseUrl.length - 1) !== '/') { if (_cfg.baseUrl.charAt(_cfg.baseUrl.length - 1) !== '/') {
cfg.baseUrl += '/'; _cfg.baseUrl += '/';
} }
} }
@ -1285,7 +1285,7 @@ var requirejs, require, define;
map: true map: true
}; };
eachProp(cfg, function (value, prop) { eachProp(_cfg, function (value, prop) {
if (objs[prop]) { if (objs[prop]) {
if (!config[prop]) { if (!config[prop]) {
config[prop] = {}; config[prop] = {};
@ -1297,8 +1297,8 @@ var requirejs, require, define;
}); });
//Reverse map the bundles //Reverse map the bundles
if (cfg.bundles) { if (_cfg.bundles) {
eachProp(cfg.bundles, function (value, prop) { eachProp(_cfg.bundles, function (value, prop) {
each(value, function (v) { each(value, function (v) {
if (v !== prop) { if (v !== prop) {
bundlesMap[v] = prop; bundlesMap[v] = prop;
@ -1308,8 +1308,8 @@ var requirejs, require, define;
} }
//Merge shim //Merge shim
if (cfg.shim) { if (_cfg.shim) {
eachProp(cfg.shim, function (value, id) { eachProp(_cfg.shim, function (value, id) {
//Normalize the structure //Normalize the structure
if (isArray(value)) { if (isArray(value)) {
value = { value = {
@ -1325,8 +1325,8 @@ var requirejs, require, define;
} }
//Adjust packages if necessary. //Adjust packages if necessary.
if (cfg.packages) { if (_cfg.packages) {
each(cfg.packages, function (pkgObj) { each(_cfg.packages, function (pkgObj) {
var location, name; var location, name;
pkgObj = typeof pkgObj === 'string' ? { name: pkgObj } : pkgObj; pkgObj = typeof pkgObj === 'string' ? { name: pkgObj } : pkgObj;
@ -1363,8 +1363,8 @@ var requirejs, require, define;
//If a deps array or a config callback is specified, then call //If a deps array or a config callback is specified, then call
//require with those args. This is useful when require is defined as a //require with those args. This is useful when require is defined as a
//config object before require.js is loaded. //config object before require.js is loaded.
if (cfg.deps || cfg.callback) { if (_cfg.deps || _cfg.callback) {
context.require(cfg.deps || [], cfg.callback); context.require(_cfg.deps || [], _cfg.callback);
} }
}, },

View File

@ -488,37 +488,37 @@ define([
// Initialize the target and create asynchronous connection and unique transaction ID // Initialize the target and create asynchronous connection and unique transaction ID
// If there is no arguments to the functions then we should not ask for for function arguments and // If there is no arguments to the functions then we should not ask for for function arguments and
// Directly open the panel // Directly open the panel
var t = pgBrowser.tree, var _t = pgBrowser.tree,
i = t.selected(), _i = _t.selected(),
d = i && i.length == 1 ? t.itemData(i) : undefined, _d = _i && _i.length == 1 ? _t.itemData(_i) : undefined,
node = d && pgBrowser.Nodes[d._type]; _node = _d && pgBrowser.Nodes[_d._type];
if (!d) if (!_d)
return; return;
var treeInfo = node.getTreeNodeHierarchy.apply(node, [i]), var newTreeInfo = _node.getTreeNodeHierarchy.apply(_node, [_i]),
baseUrl; baseUrl;
if (d._type == 'function' || d._type == 'edbfunc') { if (_d._type == 'function' || _d._type == 'edbfunc') {
baseUrl = url_for( baseUrl = url_for(
'debugger.initialize_target_for_function', { 'debugger.initialize_target_for_function', {
'debug_type': 'direct', 'debug_type': 'direct',
'trans_id': trans_id, 'trans_id': trans_id,
'sid': treeInfo.server._id, 'sid': newTreeInfo.server._id,
'did': treeInfo.database._id, 'did': newTreeInfo.database._id,
'scid': treeInfo.schema._id, 'scid': newTreeInfo.schema._id,
'func_id': debuggerUtils.getFunctionId(treeInfo), 'func_id': debuggerUtils.getFunctionId(newTreeInfo),
} }
); );
} else if(d._type == 'procedure' || d._type == 'edbproc') { } else if(_d._type == 'procedure' || _d._type == 'edbproc') {
baseUrl = url_for( baseUrl = url_for(
'debugger.initialize_target_for_function', { 'debugger.initialize_target_for_function', {
'debug_type': 'direct', 'debug_type': 'direct',
'trans_id': trans_id, 'trans_id': trans_id,
'sid': treeInfo.server._id, 'sid': newTreeInfo.server._id,
'did': treeInfo.database._id, 'did': newTreeInfo.database._id,
'scid': treeInfo.schema._id, 'scid': newTreeInfo.schema._id,
'func_id': debuggerUtils.getProcedureId(treeInfo), 'func_id': debuggerUtils.getProcedureId(newTreeInfo),
} }
); );
} }

View File

@ -677,13 +677,13 @@ export default class SchemaDiffUI {
placeholder: gettext('Select database...'), placeholder: gettext('Select database...'),
}, },
disabled: function(m) { disabled: function(m) {
let self = this; let self_local = this;
if (!_.isUndefined(m.get('target_sid')) && !_.isNull(m.get('target_sid')) if (!_.isUndefined(m.get('target_sid')) && !_.isNull(m.get('target_sid'))
&& m.get('target_sid') !== '') { && m.get('target_sid') !== '') {
setTimeout(function() { setTimeout(function() {
for (var i = 0; i < self.options.length; i++) { for (var i = 0; i < self_local.options.length; i++) {
if (self.options[i].is_maintenance_db) { if (self_local.options[i].is_maintenance_db) {
m.set('target_did', self.options[i].value); m.set('target_did', self_local.options[i].value);
} }
} }
}, 10); }, 10);
@ -713,12 +713,12 @@ export default class SchemaDiffUI {
placeholder: gettext('Select schema...'), placeholder: gettext('Select schema...'),
}, },
disabled: function(m) { disabled: function(m) {
let self = this; let self_local = this;
if (!_.isUndefined(m.get('target_did')) && !_.isNull(m.get('target_did')) if (!_.isUndefined(m.get('target_did')) && !_.isNull(m.get('target_did'))
&& m.get('target_did') !== '') { && m.get('target_did') !== '') {
setTimeout(function() { setTimeout(function() {
if (self.options.length > 0) { if (self_local.options.length > 0) {
m.set('target_scid', self.options[0].value); m.set('target_scid', self_local.options[0].value);
} }
}, 10); }, 10);
return false; return false;
@ -801,23 +801,23 @@ export default class SchemaDiffUI {
connect_server(server_id, callback) { connect_server(server_id, callback) {
var onFailure = function( var onFailure = function(
xhr, status, error, server_id, callback xhr, status, error, sid, err_callback
) { ) {
Alertify.pgNotifier('error', xhr, error, function(msg) { Alertify.pgNotifier('error', xhr, error, function(msg) {
setTimeout(function() { setTimeout(function() {
Alertify.dlgServerPass( Alertify.dlgServerPass(
gettext('Connect to Server'), gettext('Connect to Server'),
msg, msg,
server_id, sid,
callback err_callback
).resizeTo(); ).resizeTo();
}, 100); }, 100);
}); });
}, },
onSuccess = function(res, callback) { onSuccess = function(res, suc_callback) {
if (res && res.data) { if (res && res.data) {
// We're not reconnecting // We're not reconnecting
callback(res.data); suc_callback(res.data);
} }
}; };
@ -827,11 +827,11 @@ export default class SchemaDiffUI {
Alertify.dialog('dlgServerPass', function factory() { Alertify.dialog('dlgServerPass', function factory() {
return { return {
main: function( main: function(
title, message, server_id, success_callback, _onSuccess, _onFailure, _onCancel title, message, sid, success_callback, _onSuccess, _onFailure, _onCancel
) { ) {
this.set('title', title); this.set('title', title);
this.message = message; this.message = message;
this.server_id = server_id; this.server_id = sid;
this.success_callback = success_callback; this.success_callback = success_callback;
this.onSuccess = _onSuccess || onSuccess; this.onSuccess = _onSuccess || onSuccess;
this.onFailure = _onFailure || onFailure; this.onFailure = _onFailure || onFailure;

View File

@ -281,9 +281,9 @@ export default class SearchObjectsDialogWrapper extends DialogWrapper {
treeMenu.selectNode(treeItem.domNode, true); treeMenu.selectNode(treeItem.domNode, true);
this.showMessage(null); this.showMessage(null);
}) })
.catch((args)=>{ .catch((error)=>{
this.showMessage(gettext('Unable to locate this object in the browser.'), true); this.showMessage(gettext('Unable to locate this object in the browser.'), true);
console.warn(args, rowData.id_path); console.warn(error, rowData.id_path);
}); });
}); });

View File

@ -242,13 +242,13 @@ var themeCssRules = function(theme_name) {
{ {
loader: 'sass-resources-loader', loader: 'sass-resources-loader',
options: { options: {
resources: function(theme_name){ resources: function(_theme_name){
let ret_res = [ let ret_res = [
'./pgadmin/static/scss/resources/' + theme_name + '/_theme.variables.scss', './pgadmin/static/scss/resources/' + _theme_name + '/_theme.variables.scss',
'./pgadmin/static/scss/resources/pgadmin.resources.scss', './pgadmin/static/scss/resources/pgadmin.resources.scss',
]; ];
if(theme_name!='standard') { if(_theme_name!='standard') {
ret_res.unshift('./pgadmin/static/scss/resources/' + theme_name + '/_theme.variables.scss'); ret_res.unshift('./pgadmin/static/scss/resources/' + _theme_name + '/_theme.variables.scss');
} }
return ret_res; return ret_res;
}(theme_name), }(theme_name),