Uploaded image for project: 'Rules Repository'
  1. Rules Repository
  2. RSPEC-3872

Parameter names should not duplicate the names of their methods

    XMLWordPrintable

    Details

    • Type: Code Smell Detection
    • Status: Active
    • Resolution: Unresolved
    • Message:
      Rename the parameter 'xxx' so that it doesn't duplicate the method name.
    • Highlighting:
      Hide

      primary: The parameter name
      secondary: the method name

      Show
      primary: The parameter name secondary: the method name
    • Default Severity:
      Minor
    • Impact:
      Low
    • Likelihood:
      Low
    • Targeted languages:
      C, C++, Flex, Java, JavaScript, Objective-C, PHP, Python, Swift, VB.Net
    • Covered Languages:
      C#
    • Remediation Function:
      Constant/Issue
    • Constant Cost:
      5min
    • Analysis Scope:
      Main Sources, Test Sources
    • FxCop:
      ParameterNamesShouldNotMatchMemberNames, CA1719

      Description

      The name of a method should communicate what it does, and the names of its parameters should indicate how they're used. If a method and its parameter have the same name it is an indication that one of these rules of thumb has been broken, if not both. Even if by some trick of language that's not the case, it is still likely to confuse callers and maintainers.

      Noncompliant Code Example

      public void Login(string login)  // Noncompliant
      {
        //...
      }
      

      Compliant Solution

      public void Login(string userName)
      {
        //...
      }
      

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            ann.campbell.2 Ann Campbell
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated: