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
Function argument names should be unique
description
Function arguments should all have different names to prevent any ambiguity. Indeed, if arguments have the same name, the last duplicated argument hides all the previous arguments with the same name (those previous arguments remain available through <code>arguments[i]</code>, so they're not completely inaccessible). This hiding makes no sense, clearly reduces understandability and maintainability, and obvioulsy can be error prone.
Furthermore, in JavaScript strict mode, declaring arguments with the same name produces an error.
The following code snippet illustrates this rule :
function compute(a, a, c) { // non-compliant
...
}
function computeBis(a, b, c) { // compliant
...
}
message
Rename or remove duplicate function argument '
{0}'.
severity
Critical
in Sonar way?
Yes
Issue Links
- is related to
-
SONARPLUGINS-2515
Update the SQALE mapping for new rules
-
- relates to
-
SONARPLUGINS-2508
Rule : Source should comply with the javascript strict mode
-
Manually tested.