rspec/rules/S1519/rule.adoc
2022-02-04 16:28:24 +00:00

32 lines
564 B
Plaintext

This rule checks that the var keyword is not used to declare a variable with a name that is already in use. It applies to already defined variables as well as to function parameters.
This use of duplicate name is often unwanted and can lead to bugs and more generally to confusing code :
== Noncompliant Code Example
[source,text]
----
var a = 'foo';
var a = 'bar'; // Noncompliant
function f(e) {
var e = "event"; // Noncompliant
}
----
== Compliant Solution
[source,text]
----
var a = 'foo';
var b = 'bar';
function f(e) {
var g = "event";
}
----