Details
-
Type:
New Feature
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: JAVASCRIPT-1.2
-
Component/s: JavaScript
-
Labels:None
-
Number of attachments :
Description
Title
Avoid redeclaration of functions
Severity
Major
Description
This rule checks that functions declared in same scope don't have identical names. Indeed, it is possible to declare 2 functions with the same name, but only the last definition will be kept by the JavaScript engine before starting execution of the whole code. The following code illustrates this:
fun(); // prints "bar" // first declaration of the function function fun() { print("foo"); } fun(); // prints "bar" // redeclaration of the "fun" function: this definition overrides the previous one function fun() { print("bar"); } fun(); // prints "bar"
This use of duplicate function name is often unwanted and can lead to bugs and more generally to confusing code.
Message
Rename function '
{0}' as this name is already used.
Activated?
Yes
Cardinality
Single
Manually tested.