mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Fixed SonarQube code smell 'Variables should not be shadowed'.
This commit is contained in:
committed by
Akshay Joshi
parent
c2e875d54b
commit
6dd3ca31be
@@ -84,13 +84,13 @@ define('pgadmin.node.fts_configuration', [
|
||||
this,
|
||||
arguments
|
||||
);
|
||||
var self = this,
|
||||
url = self.field.get('url') || self.defaults.url,
|
||||
m = self.model.top || self.model;
|
||||
var _self = this,
|
||||
url = _self.field.get('url') || _self.defaults.url,
|
||||
m = _self.model.top || _self.model;
|
||||
|
||||
/* Fetch the tokens/dict list from 'self' node.
|
||||
* Here 'self' refers to unique collection control where
|
||||
* 'self' refers to nodeAjaxOptions control for dictionary
|
||||
/* Fetch the tokens/dict list from '_self' node.
|
||||
* Here '_self' refers to unique collection control where
|
||||
* '_self' refers to nodeAjaxOptions control for dictionary
|
||||
*/
|
||||
if (url) {
|
||||
var node = this.field.get('schema_node'),
|
||||
@@ -118,7 +118,7 @@ define('pgadmin.node.fts_configuration', [
|
||||
// Fetch token/dictionary list
|
||||
if (this.field.get('version_compatible') &&
|
||||
(_.isUndefined(data) || _.isNull(data))) {
|
||||
m.trigger('pgadmin:view:fetching', m, self.field);
|
||||
m.trigger('pgadmin:view:fetching', m, _self.field);
|
||||
$.ajax({
|
||||
async: false,
|
||||
url: full_url,
|
||||
@@ -135,9 +135,9 @@ define('pgadmin.node.fts_configuration', [
|
||||
);
|
||||
})
|
||||
.fail(function() {
|
||||
m.trigger('pgadmin:view:fetch:error', m, self.field);
|
||||
m.trigger('pgadmin:view:fetch:error', m, _self.field);
|
||||
});
|
||||
m.trigger('pgadmin:view:fetched', m, self.field);
|
||||
m.trigger('pgadmin:view:fetched', m, _self.field);
|
||||
}
|
||||
|
||||
// It is feasible that the data may not have been fetched.
|
||||
@@ -147,11 +147,11 @@ define('pgadmin.node.fts_configuration', [
|
||||
* Transform the data
|
||||
*/
|
||||
var transform = (this.field.get('transform')
|
||||
|| self.defaults.transform);
|
||||
|| _self.defaults.transform);
|
||||
if (transform && _.isFunction(transform)) {
|
||||
self.field.set('options', transform.bind(self, data));
|
||||
_self.field.set('options', transform.bind(_self, data));
|
||||
} else {
|
||||
self.field.set('options', data);
|
||||
_self.field.set('options', data);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -19,7 +19,7 @@ export function childCreateMenuEnabled(itemData, item, data) {
|
||||
|
||||
if (node)
|
||||
return node.anyFamilyMember(
|
||||
(node) => (node.getData()._type === 'schema')
|
||||
(parentNode) => (parentNode.getData()._type === 'schema')
|
||||
);
|
||||
|
||||
return false;
|
||||
|
||||
@@ -323,7 +323,7 @@ define('pgadmin.node.exclusion_constraint', [
|
||||
// This will only get called in case of NodeListByNameControl.
|
||||
|
||||
var that = this,
|
||||
node = that.field.get('schema_node'),
|
||||
schema_node = that.field.get('schema_node'),
|
||||
res = [],
|
||||
col_types = [],
|
||||
filter = that.field.get('filter') || function() { return true; };
|
||||
@@ -332,14 +332,14 @@ define('pgadmin.node.exclusion_constraint', [
|
||||
|
||||
_.each(rows, function(r) {
|
||||
if (filter(r)) {
|
||||
var l = (_.isFunction(node['node_label']) ?
|
||||
(node['node_label']).apply(node, [r, that.model, that]) :
|
||||
var l = (_.isFunction(schema_node['node_label']) ?
|
||||
(schema_node['node_label']).apply(schema_node, [r, that.model, that]) :
|
||||
r.label),
|
||||
image = (_.isFunction(node['node_image']) ?
|
||||
(node['node_image']).apply(
|
||||
node, [r, that.model, that]
|
||||
image = (_.isFunction(schema_node['node_image']) ?
|
||||
(schema_node['node_image']).apply(
|
||||
schema_node, [r, that.model, that]
|
||||
) :
|
||||
(node['node_image'] || ('icon-' + node.type)));
|
||||
(schema_node['node_image'] || ('icon-' + schema_node.type)));
|
||||
res.push({
|
||||
'value': r.label,
|
||||
'image': image,
|
||||
|
||||
@@ -461,12 +461,12 @@ function(
|
||||
var self = this,
|
||||
collection = self.model.get(self.field.get('name'));
|
||||
|
||||
collection.on('change:is_primary_key', function(m) {
|
||||
collection.on('change:is_primary_key', function(local_model) {
|
||||
var primary_key_coll = self.model.get('primary_key'),
|
||||
column_name = m.get('name'),
|
||||
column_name = local_model.get('name'),
|
||||
primary_key, primary_key_column_coll;
|
||||
|
||||
if(m.get('is_primary_key')) {
|
||||
if(local_model.get('is_primary_key')) {
|
||||
// Add column to primary key.
|
||||
if (primary_key_coll.length < 1) {
|
||||
primary_key = new (primary_key_coll.model)({}, {
|
||||
|
||||
@@ -357,15 +357,15 @@ define('pgadmin.node.mview', [
|
||||
data: {'concurrent': args.concurrent, 'with_data': args.with_data},
|
||||
dataType: 'json',
|
||||
})
|
||||
.done(function(res) {
|
||||
if (res.data && res.data.status) {
|
||||
.done(function(refreshed_res) {
|
||||
if (refreshed_res.data && refreshed_res.data.status) {
|
||||
//Do nothing as we are creating the job and exiting from the main dialog
|
||||
Alertify.success(res.data.info);
|
||||
Alertify.success(refreshed_res.data.info);
|
||||
pgBrowser.Events.trigger('pgadmin-bgprocess:created', obj);
|
||||
} else {
|
||||
Alertify.alert(
|
||||
gettext('Failed to create materialized view refresh job.'),
|
||||
res.errormsg
|
||||
refreshed_res.errormsg
|
||||
);
|
||||
}
|
||||
})
|
||||
|
||||
@@ -553,42 +553,42 @@ define('pgadmin.node.database', [
|
||||
});
|
||||
},
|
||||
onSuccess = function(
|
||||
res, model, data, tree, item, connected
|
||||
res, model, _data, _tree, _item, _connected
|
||||
) {
|
||||
data.is_connecting = false;
|
||||
if (!connected) {
|
||||
tree.deselect(item);
|
||||
tree.setInode(item);
|
||||
_data.is_connecting = false;
|
||||
if (!_connected) {
|
||||
_tree.deselect(_item);
|
||||
_tree.setInode(_item);
|
||||
}
|
||||
if (res && res.data) {
|
||||
if(typeof res.data.connected == 'boolean') {
|
||||
data.connected = res.data.connected;
|
||||
if (res && res._data) {
|
||||
if(typeof res._data.connected == 'boolean') {
|
||||
_data.connected = res._data.connected;
|
||||
}
|
||||
if (typeof res.data.icon == 'string') {
|
||||
tree.removeIcon(item);
|
||||
data.icon = res.data.icon;
|
||||
tree.addIcon(item, {icon: data.icon});
|
||||
_tree.removeIcon(_item);
|
||||
_data.icon = res._data.icon;
|
||||
_tree.addIcon(_item, {icon: _data.icon});
|
||||
}
|
||||
if(res.data.already_connected) {
|
||||
if(res._data.already_connected) {
|
||||
res.info = gettext('Database already connected.');
|
||||
}
|
||||
if(res.data.info_prefix) {
|
||||
res.info = `${_.escape(res.data.info_prefix)} - ${res.info}`;
|
||||
if(res._data.info_prefix) {
|
||||
res.info = `${_.escape(res._data.info_prefix)} - ${res.info}`;
|
||||
}
|
||||
if(res.data.already_connected) {
|
||||
if(res._data.already_connected) {
|
||||
Alertify.info(res.info);
|
||||
} else {
|
||||
Alertify.success(res.info);
|
||||
}
|
||||
obj.trigger('connected', obj, item, data);
|
||||
obj.trigger('connected', obj, _item, _data);
|
||||
pgBrowser.Events.trigger(
|
||||
'pgadmin:database:connected', item, data
|
||||
'pgadmin:database:connected', _item, _data
|
||||
);
|
||||
|
||||
if (!connected) {
|
||||
if (!_connected) {
|
||||
setTimeout(function() {
|
||||
tree.select(item);
|
||||
tree.open(item);
|
||||
_tree.select(_item);
|
||||
_tree.open(_item);
|
||||
}, 10);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,11 +104,11 @@ define(['sources/gettext', 'underscore', 'jquery', 'backbone', 'backform',
|
||||
}
|
||||
|
||||
var rerender = function (m) {
|
||||
var self = this;
|
||||
var _self = this;
|
||||
if ('grantee' in m.changed && this.model.cid != m.cid) {
|
||||
setTimeout(
|
||||
function() {
|
||||
self.render();
|
||||
_self.render();
|
||||
}, 50
|
||||
);
|
||||
}
|
||||
|
||||
@@ -61,8 +61,8 @@ _.extend(pgBrowser, {
|
||||
let eventHandler = function() {
|
||||
if(self.is_pgadmin_timedout()) {
|
||||
/* If the main page has logged out then remove the listener and call the timeout callback */
|
||||
inactivity_events.forEach((event)=>{
|
||||
target.removeEventListener(event, eventHandler, true);
|
||||
inactivity_events.forEach((events)=>{
|
||||
target.removeEventListener(events, eventHandler, true);
|
||||
});
|
||||
timeout_callback();
|
||||
} else {
|
||||
|
||||
@@ -1282,12 +1282,12 @@ define([
|
||||
} else {
|
||||
var msg = 'Duplicate rows.';
|
||||
setTimeout(function() {
|
||||
_.each(new_conflicting_models, function(m) {
|
||||
_.each(new_conflicting_models, function(local_model) {
|
||||
self.trigger(
|
||||
'pgadmin-session:model:invalid', msg, m, self.handler
|
||||
'pgadmin-session:model:invalid', msg, local_model, self.handler
|
||||
);
|
||||
m.trigger(
|
||||
'pgadmin-session:model:duplicate', m, msg
|
||||
local_model.trigger(
|
||||
'pgadmin-session:model:duplicate', local_model, msg
|
||||
);
|
||||
});
|
||||
}, 10);
|
||||
|
||||
@@ -110,9 +110,9 @@ export function initializeToolbar(panel, wcDocker) {
|
||||
|
||||
// This function is used to enable/disable the specific button
|
||||
// based on their label.
|
||||
export function enable(label, enable) {
|
||||
export function enable(label, enable_btn) {
|
||||
if (label in _toolbarButtons) {
|
||||
_browserPanel.buttonEnable(label, enable);
|
||||
_browserPanel.buttonEnable(label, enable_btn);
|
||||
} else {
|
||||
console.warn('Developer warning: No tool button found with label: ' + label);
|
||||
}
|
||||
|
||||
@@ -263,12 +263,12 @@ define([
|
||||
$(this.elements.commands.close).attr('aria-label', gettext('Close'));
|
||||
$(this.elements.commands.maximize).attr('aria-label', gettext('Maximize'));
|
||||
alertifyDialogResized.apply(this, arguments);
|
||||
let self = this;
|
||||
let _self = this;
|
||||
|
||||
let cmds = Object.values(this.elements.commands);
|
||||
$(cmds).on('keydown', 'button', (event) => {
|
||||
if (event.shiftKey && event.keyCode == 9 && $(this).nextAll('button:not([disabled])').length == 0){
|
||||
let container = $(self.elements.footer);
|
||||
let container = $(_self.elements.footer);
|
||||
commonUtils.findAndSetFocus(container.find('button:not([disabled]):last'));
|
||||
}
|
||||
});
|
||||
@@ -339,7 +339,7 @@ define([
|
||||
args: args,
|
||||
},
|
||||
reconnectServer = function() {
|
||||
var ctx = this,
|
||||
var ctx_local = this,
|
||||
onServerConnect = function(_sid, _i, _d) {
|
||||
// Yay - server is reconnected.
|
||||
if (this.args.info.server._id == _sid) {
|
||||
@@ -363,7 +363,7 @@ define([
|
||||
);
|
||||
}
|
||||
}
|
||||
}.bind(ctx),
|
||||
}.bind(ctx_local),
|
||||
onConnectCancel = function(_sid, _item, _data) {
|
||||
// User has cancelled the operation in between.
|
||||
if (_sid == this.args.info.server.id) {
|
||||
@@ -376,7 +376,7 @@ define([
|
||||
this.resp.data.database || _data.db, _item, _data
|
||||
);
|
||||
}
|
||||
}.bind(ctx);
|
||||
}.bind(ctx_local);
|
||||
|
||||
pgBrowser.Events.on('pgadmin:server:connected', onServerConnect);
|
||||
pgBrowser.Events.on('pgadmin:server:connect:cancelled', onConnectCancel);
|
||||
|
||||
@@ -1363,11 +1363,11 @@ define([
|
||||
var idx = that.indexOf(m);
|
||||
if (idx > -1) {
|
||||
var row = self.grid.body.rows[idx],
|
||||
editCell = row.$el.find('.subnode-edit-in-process').parent();
|
||||
rowEditCell = row.$el.find('.subnode-edit-in-process').parent();
|
||||
// Only close row if it's open.
|
||||
if (editCell.length > 0) {
|
||||
if (rowEditCell.length > 0) {
|
||||
var event = new Event('click');
|
||||
editCell[0].dispatchEvent(event);
|
||||
rowEditCell[0].dispatchEvent(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1420,11 +1420,11 @@ define([
|
||||
if (canAddRow) {
|
||||
// Close any existing expanded row before adding new one.
|
||||
_.each(self.grid.body.rows, function(row) {
|
||||
var editCell = row.$el.find('.subnode-edit-in-process').parent();
|
||||
var rowEditCell = row.$el.find('.subnode-edit-in-process').parent();
|
||||
// Only close row if it's open.
|
||||
if (editCell.length > 0) {
|
||||
if (rowEditCell.length > 0) {
|
||||
var event = new Event('click');
|
||||
editCell[0].dispatchEvent(event);
|
||||
rowEditCell[0].dispatchEvent(event);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1661,11 +1661,11 @@ define([
|
||||
var idx = ctx.indexOf(m);
|
||||
if (idx > -1) {
|
||||
var row = grid.body.rows[idx],
|
||||
editCell = row.$el.find('.subnode-edit-in-process').parent();
|
||||
rowEditCell = row.$el.find('.subnode-edit-in-process').parent();
|
||||
// Only close row if it's open.
|
||||
if (editCell.length > 0) {
|
||||
if (rowEditCell.length > 0) {
|
||||
var event = new Event('click');
|
||||
editCell[0].dispatchEvent(event);
|
||||
rowEditCell[0].dispatchEvent(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1716,11 +1716,11 @@ define([
|
||||
if (canAddRow) {
|
||||
// Close any existing expanded row before adding new one.
|
||||
_.each(grid.body.rows, function(row) {
|
||||
var editCell = row.$el.find('.subnode-edit-in-process').parent();
|
||||
var rowEditCell = row.$el.find('.subnode-edit-in-process').parent();
|
||||
// Only close row if it's open.
|
||||
if (editCell.length > 0) {
|
||||
if (rowEditCell.length > 0) {
|
||||
var event = new Event('click');
|
||||
editCell[0].dispatchEvent(event);
|
||||
rowEditCell[0].dispatchEvent(event);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ import pgBrowser from 'pgadmin.browser';
|
||||
|
||||
export function url(itemData, item, treeHierarchy) {
|
||||
let treeNode = pgBrowser.treeMenu.findNodeByDomElement(item);
|
||||
let url = null;
|
||||
let return_url = null;
|
||||
|
||||
if (treeNode) {
|
||||
treeNode.anyFamilyMember(
|
||||
@@ -27,11 +27,11 @@ export function url(itemData, item, treeHierarchy) {
|
||||
browserNode, [node, nodeData, treeHierarchy]
|
||||
);
|
||||
}
|
||||
url = isString(dashboardURL) ? dashboardURL : null;
|
||||
return_url = isString(dashboardURL) ? dashboardURL : null;
|
||||
|
||||
return (url !== null);
|
||||
return (return_url !== null);
|
||||
});
|
||||
}
|
||||
|
||||
return url;
|
||||
return return_url;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user