SonarQube JavaScript
  1. SonarQube JavaScript
  2. SONARJS-97

Rule: Function argument names should be unique

    Details

    • Type: New Feature New Feature
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.2
    • Component/s: None
    • Labels:
      None
    • Number of attachments :
      0

      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

          Activity

          Hide
          Fabrice Bellingard added a comment -

          Manually tested.

          Show
          Fabrice Bellingard added a comment - Manually tested.

            People

            • Assignee:
              Evgeny Mandrikov
              Reporter:
              Evgeny Mandrikov
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: