Fixed the SoanrQube code smell 'Variables should not be shadowed'.
parent
b5f0190799
commit
80ab596992
|
@ -347,11 +347,11 @@ define('pgadmin.node.fts_configuration', [
|
|||
idx = -1;
|
||||
|
||||
// Find if token exists in grid
|
||||
self.collection.each(function(m) {
|
||||
self.collection.each(function(local_model) {
|
||||
_.each(checkVars, function(v) {
|
||||
var val = m.get(v);
|
||||
var val = local_model.get(v);
|
||||
if(val == token) {
|
||||
idx = coll.indexOf(m);
|
||||
idx = coll.indexOf(local_model);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -203,29 +203,29 @@ define('pgadmin.node.foreign_key', [
|
|||
formatter: Backform.ControlFormatter,
|
||||
template: headerSelectControlTemplate,
|
||||
render: function() {
|
||||
var self = this,
|
||||
url = self.field.get('url') || self.defaults.url,
|
||||
m = self.model,
|
||||
var self_referenced = this,
|
||||
url = self_referenced.field.get('url') || self_referenced.defaults.url,
|
||||
m = self_referenced.model,
|
||||
tid = m.get('references');
|
||||
// Store name for selected table
|
||||
var a = $('select[name="references"]').find(':selected').text();
|
||||
this.model.set('references_table_name', a,{silent: true});
|
||||
|
||||
// Clear any existing value before setting new options.
|
||||
m.set(self.field.get('name'), null, {silent: true});
|
||||
m.set(self_referenced.field.get('name'), null, {silent: true});
|
||||
|
||||
if (url && !_.isUndefined(tid) && !_.isNull(tid) && tid != '') {
|
||||
var node = this.field.get('schema_node'),
|
||||
var schema_node = this.field.get('schema_node'),
|
||||
node_info = this.field.get('node_info'),
|
||||
full_url = node.generate_url.apply(
|
||||
node, [
|
||||
full_url = schema_node.generate_url.apply(
|
||||
schema_node, [
|
||||
null, url, this.field.get('node_data'),
|
||||
this.field.get('url_with_id') || false, node_info,
|
||||
]),
|
||||
data = [];
|
||||
|
||||
if (this.field.get('version_compatible')) {
|
||||
m.trigger('pgadmin:view:fetching', m, self.field);
|
||||
m.trigger('pgadmin:view:fetching', m, self_referenced.field);
|
||||
$.ajax({
|
||||
async: false,
|
||||
data : {tid:tid},
|
||||
|
@ -235,24 +235,24 @@ define('pgadmin.node.foreign_key', [
|
|||
data = res.data;
|
||||
})
|
||||
.fail(function() {
|
||||
m.trigger('pgadmin:view:fetch:error', m, self.field);
|
||||
m.trigger('pgadmin:view:fetch:error', m, self_referenced.field);
|
||||
});
|
||||
m.trigger('pgadmin:view:fetched', m, self.field);
|
||||
m.trigger('pgadmin:view:fetched', m, self_referenced.field);
|
||||
}
|
||||
/*
|
||||
* Transform the data
|
||||
*/
|
||||
var transform = this.field.get('transform') || self.defaults.transform;
|
||||
var transform = this.field.get('transform') || self_referenced.defaults.transform;
|
||||
if (transform && _.isFunction(transform)) {
|
||||
// We will transform the data later, when rendering.
|
||||
// It will allow us to generate different data based on the
|
||||
// dependencies.
|
||||
self.field.set('options', transform.bind(self, data));
|
||||
self_referenced.field.set('options', transform.bind(self_referenced, data));
|
||||
} else {
|
||||
self.field.set('options', data);
|
||||
self_referenced.field.set('options', data);
|
||||
}
|
||||
} else {
|
||||
self.field.set('options', []);
|
||||
self_referenced.field.set('options', []);
|
||||
}
|
||||
Backform.Select2Control.prototype.render.apply(this, arguments);
|
||||
return this;
|
||||
|
@ -555,8 +555,8 @@ define('pgadmin.node.foreign_key', [
|
|||
coveringindex = null,
|
||||
url_jump_after_node = 'schema';
|
||||
|
||||
self.collection.each(function(m){
|
||||
cols.push(m.get('local_column'));
|
||||
self.collection.each(function(local_model){
|
||||
cols.push(local_model.get('local_column'));
|
||||
});
|
||||
|
||||
if (cols.length > 0) {
|
||||
|
|
|
@ -616,8 +616,8 @@ define('pgadmin.node.table', [
|
|||
var removedCols = primary_key_column_coll.where({column:column_name});
|
||||
if (removedCols.length > 0) {
|
||||
primary_key_column_coll.remove(removedCols);
|
||||
_.each(removedCols, function(m) {
|
||||
m.destroy();
|
||||
_.each(removedCols, function(local_model) {
|
||||
local_model.destroy();
|
||||
});
|
||||
if (primary_key_column_coll.length == 0) {
|
||||
/* Ideally above line of code should be "primary_key_coll.reset()".
|
||||
|
|
|
@ -11,10 +11,10 @@ export default function (options) {
|
|||
* The trick is, ajax: {} will also work even if you're actually not
|
||||
* using ajax.
|
||||
*/
|
||||
let ScrollDataAdapter = function ($element, options) {
|
||||
let ScrollDataAdapter = function ($element, dropdownOptions) {
|
||||
this.$element = $element;
|
||||
this.options = options;
|
||||
this._dataToConvert = options.get('data') || [];
|
||||
this.options = dropdownOptions;
|
||||
this._dataToConvert = dropdownOptions.get('data') || [];
|
||||
};
|
||||
|
||||
let BaseAdapter = null;
|
||||
|
|
|
@ -142,12 +142,12 @@ define([
|
|||
function shouldScrollToRightmostColumn() { return anchorActiveCell.cell === newSelectedRange.fromCell; }
|
||||
|
||||
function getMobileCellFromRange(range, activeCell) {
|
||||
var mobileCell = {};
|
||||
var localMobileCell = {};
|
||||
|
||||
mobileCell.row = range.fromRow === activeCell.row ? range.toRow : range.fromRow;
|
||||
mobileCell.cell = range.fromCell === activeCell.cell ? range.toCell : range.fromCell;
|
||||
localMobileCell.row = range.fromRow === activeCell.row ? range.toRow : range.fromRow;
|
||||
localMobileCell.cell = range.fromCell === activeCell.cell ? range.toCell : range.fromCell;
|
||||
|
||||
return mobileCell;
|
||||
return localMobileCell;
|
||||
}
|
||||
|
||||
function getNewRange(rangeCorner, oppositeCorner) {
|
||||
|
|
|
@ -230,9 +230,9 @@ let FilterDialog = {
|
|||
self.showFilterProgress[0]
|
||||
).addClass('d-none');
|
||||
|
||||
let response = result.data.data;
|
||||
let filterResponse = result.data.data;
|
||||
|
||||
if (response.status) {
|
||||
if (filterResponse.status) {
|
||||
setTimeout(
|
||||
function() {
|
||||
self.close(); // Close the dialog now
|
||||
|
@ -243,7 +243,7 @@ let FilterDialog = {
|
|||
} else {
|
||||
Alertify.alert(
|
||||
gettext('Validation Error'),
|
||||
response.result
|
||||
filterResponse.result
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -12,22 +12,22 @@ let getWindowOpener = (opener) => {
|
|||
};
|
||||
|
||||
let pgWindow = function() {
|
||||
let pgWindow = null;
|
||||
let localPgWindow = null;
|
||||
try {
|
||||
if(window.opener && window.opener.pgAdmin) {
|
||||
/* Windows can be opened at multiple levels */
|
||||
pgWindow = getWindowOpener(window.opener);
|
||||
localPgWindow = getWindowOpener(window.opener);
|
||||
} else if(window.parent && window.parent.pgAdmin){
|
||||
pgWindow = window.parent;
|
||||
localPgWindow = window.parent;
|
||||
} else if(window.top && window.top.pgAdmin){
|
||||
pgWindow = window.top;
|
||||
localPgWindow = window.top;
|
||||
} else {
|
||||
pgWindow = window;
|
||||
localPgWindow = window;
|
||||
}
|
||||
} catch (error) {
|
||||
pgWindow = window;
|
||||
localPgWindow = window;
|
||||
}
|
||||
return pgWindow;
|
||||
return localPgWindow;
|
||||
}();
|
||||
|
||||
export default pgWindow;
|
||||
|
|
|
@ -57,13 +57,13 @@
|
|||
}
|
||||
|
||||
var column = this.column, model = this.model, $el = this.$el;
|
||||
this.listenTo(column, "change:renderable", function (column, renderable) {
|
||||
this.listenTo(column, "change:renderable", function (col, renderable) {
|
||||
$el.toggleClass("renderable", renderable);
|
||||
});
|
||||
|
||||
if (Backgrid.callByNeed(column.renderable(), column, model)) $el.addClass("renderable");
|
||||
|
||||
this.listenTo(model, "backgrid:select", function (model, selected) {
|
||||
this.listenTo(model, "backgrid:select", function (mod, selected) {
|
||||
this.checkbox().prop("checked", selected).change();
|
||||
});
|
||||
},
|
||||
|
@ -214,7 +214,7 @@
|
|||
});
|
||||
|
||||
var column = this.column, $el = this.$el;
|
||||
this.listenTo(column, "change:renderable", function (column, renderable) {
|
||||
this.listenTo(column, "change:renderable", function (col, renderable) {
|
||||
$el.toggleClass("renderable", renderable);
|
||||
});
|
||||
|
||||
|
|
|
@ -1158,7 +1158,7 @@ define([
|
|||
self.releaseObjects();
|
||||
self.close();
|
||||
},
|
||||
error: function(m, jqxhr) {
|
||||
error: function(model, jqxhr) {
|
||||
Alertify.pgNotifier(
|
||||
'error', jqxhr,
|
||||
gettext('Error saving properties')
|
||||
|
|
|
@ -373,8 +373,8 @@ export default class SchemaDiffUI {
|
|||
|
||||
// Grid filter
|
||||
self.filter = function (item) {
|
||||
let self = this;
|
||||
if (self.sel_filters.indexOf(item.status) !== -1) return true;
|
||||
let self_local = this;
|
||||
if (self_local.sel_filters.indexOf(item.status) !== -1) return true;
|
||||
return false;
|
||||
};
|
||||
|
||||
|
@ -586,12 +586,12 @@ export default class SchemaDiffUI {
|
|||
placeholder: gettext('Select database...'),
|
||||
},
|
||||
disabled: function(m) {
|
||||
let self = this;
|
||||
let self_local = this;
|
||||
if (!_.isUndefined(m.get('source_sid')) && !_.isNull(m.get('source_sid'))
|
||||
&& m.get('source_sid') !== '') {
|
||||
setTimeout(function() {
|
||||
if (self.options.length > 0) {
|
||||
m.set('source_did', self.options[0].value);
|
||||
if (self_local.options.length > 0) {
|
||||
m.set('source_did', self_local.options[0].value);
|
||||
}
|
||||
}, 10);
|
||||
return false;
|
||||
|
@ -620,12 +620,12 @@ export default class SchemaDiffUI {
|
|||
placeholder: gettext('Select schema...'),
|
||||
},
|
||||
disabled: function(m) {
|
||||
let self = this;
|
||||
let self_local = this;
|
||||
if (!_.isUndefined(m.get('source_did')) && !_.isNull(m.get('source_did'))
|
||||
&& m.get('source_did') !== '') {
|
||||
setTimeout(function() {
|
||||
if (self.options.length > 0) {
|
||||
m.set('source_scid', self.options[0].value);
|
||||
if (self_local.options.length > 0) {
|
||||
m.set('source_scid', self_local.options[0].value);
|
||||
}
|
||||
}, 10);
|
||||
return false;
|
||||
|
|
|
@ -89,10 +89,10 @@ define([
|
|||
if (!alertify.ChangePassword) {
|
||||
alertify.dialog('ChangePassword', function factory() {
|
||||
return {
|
||||
main: function(title, url) {
|
||||
main: function(alertTitle, alertUrl) {
|
||||
this.set({
|
||||
'title': title,
|
||||
'url': url,
|
||||
'title': alertTitle,
|
||||
'url': alertUrl,
|
||||
});
|
||||
},
|
||||
build: function() {
|
||||
|
@ -195,10 +195,10 @@ define([
|
|||
if(!alertify.PgaLogin) {
|
||||
alertify.dialog('PgaLogin' ,function factory() {
|
||||
return {
|
||||
main: function(title, url) {
|
||||
main: function(alertTitle, alertUrl) {
|
||||
this.set({
|
||||
'title': title,
|
||||
'url': url,
|
||||
'title': alertTitle,
|
||||
'url': alertUrl,
|
||||
});
|
||||
},
|
||||
build: function() {
|
||||
|
@ -241,11 +241,11 @@ define([
|
|||
// create the iframe element
|
||||
var self = this,
|
||||
iframe = document.createElement('iframe'),
|
||||
url = this.setting('url');
|
||||
frameUrl = this.setting('url');
|
||||
|
||||
iframe.onload = function() {
|
||||
var doc = this.contentDocument || this.contentWindow.document;
|
||||
if (doc.location.href.indexOf(url) == -1) {
|
||||
if (doc.location.href.indexOf(frameUrl) == -1) {
|
||||
// login successful.
|
||||
|
||||
this.contentWindow.stop();
|
||||
|
@ -260,7 +260,7 @@ define([
|
|||
iframe.frameBorder = 'no';
|
||||
iframe.width = '100%';
|
||||
iframe.height = '100%';
|
||||
iframe.src = url;
|
||||
iframe.src = frameUrl;
|
||||
// add it to the dialog
|
||||
self.elements.content.appendChild(iframe);
|
||||
},
|
||||
|
|
|
@ -378,10 +378,10 @@ describe('ColumnSelector', function () {
|
|||
});
|
||||
});
|
||||
|
||||
function setupGrid(columns) {
|
||||
function setupGrid(gridColumns) {
|
||||
var columnSelector = new ColumnSelector();
|
||||
columns = columnSelector.getColumnDefinitions(columns);
|
||||
var grid = new SlickGrid(container, data, columns, options);
|
||||
gridColumns = columnSelector.getColumnDefinitions(gridColumns);
|
||||
var grid = new SlickGrid(container, data, gridColumns, options);
|
||||
|
||||
var cellSelectionModel = new XCellSelectionModel();
|
||||
grid.setSelectionModel(cellSelectionModel);
|
||||
|
|
|
@ -839,13 +839,13 @@ describe('ExecuteQuery', () => {
|
|||
errormsg: 'Some error in JSON',
|
||||
};
|
||||
let errorMessageText = 'Some plain text error';
|
||||
let response;
|
||||
let res;
|
||||
|
||||
describe('when the connection to the server was lost', () => {
|
||||
describe('when JSON response is available', () => {
|
||||
beforeEach(() => {
|
||||
response = {responseJSON: errorMessageJson};
|
||||
networkMock.onGet('/sqleditor/query_tool/poll/123').reply(401, response);
|
||||
res = {responseJSON: errorMessageJson};
|
||||
networkMock.onGet('/sqleditor/query_tool/poll/123').reply(401, res);
|
||||
|
||||
executeQuery.poll();
|
||||
});
|
||||
|
@ -906,8 +906,8 @@ describe('ExecuteQuery', () => {
|
|||
});
|
||||
describe('when no JSON response is available', () => {
|
||||
beforeEach(() => {
|
||||
response = {errormsg: errorMessageText};
|
||||
networkMock.onGet('/sqleditor/query_tool/poll/123').reply(401, response);
|
||||
res = {errormsg: errorMessageText};
|
||||
networkMock.onGet('/sqleditor/query_tool/poll/123').reply(401, res);
|
||||
|
||||
executeQuery.poll();
|
||||
});
|
||||
|
|
|
@ -607,9 +607,9 @@ describe('queryToolActions', () => {
|
|||
});
|
||||
});
|
||||
|
||||
function setUpSpies(selectedQueryString, entireQueryString) {
|
||||
getValueSpy = jasmine.createSpy('getValueSpy').and.returnValue(entireQueryString);
|
||||
getSelectionSpy = jasmine.createSpy('getSelectionSpy').and.returnValue(selectedQueryString);
|
||||
function setUpSpies(selectedQueryStringArg, entireQueryStringArg) {
|
||||
getValueSpy = jasmine.createSpy('getValueSpy').and.returnValue(entireQueryStringArg);
|
||||
getSelectionSpy = jasmine.createSpy('getSelectionSpy').and.returnValue(selectedQueryStringArg);
|
||||
replaceSelectionSpy = jasmine.createSpy('replaceSelectionSpy');
|
||||
|
||||
sqlEditorController = {
|
||||
|
@ -622,7 +622,7 @@ describe('queryToolActions', () => {
|
|||
uncomment: jasmine.createSpy('uncommentSpy'),
|
||||
replaceSelection: replaceSelectionSpy,
|
||||
getCursor: (isFrom) => {
|
||||
return entireQueryString.indexOf(selectedQueryString) + (isFrom ? 0 : selectedQueryString.length);
|
||||
return entireQueryStringArg.indexOf(selectedQueryStringArg) + (isFrom ? 0 : selectedQueryStringArg.length);
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue