org.sonar.l10n.javascript.rules.javascript.VariableShadowing.html Maven / Gradle / Ivy
Overriding a variable declared in an outer scope can strongly impact the readability, and therefore the maintainability, of a piece of code. Further, it could lead maintainers to introduce bugs because they think they're using one variable but are really using another.
Noncompliant Code Example
show: function(point, element) {
if (!this.drops.length) return;
var drop, affected = [];
this.drops.each( function(drop) { // Non-Compliant; defines a new 'drop' parameter
if(Droppables.isAffected(point, element, drop))
affected.push(drop);
});
Compliant Solution
show: function(point, element) {
if (!this.drops.length) return;
var drop, affected = [];
this.drops.each( function(aDrop) {
if(Droppables.isAffected(point, element, aDrop))
affected.push(aDrop);
});
© 2015 - 2024 Weber Informatics LLC | Privacy Policy