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

Functions, methods and lambdas should not have too many mandatory parameters

    XMLWordPrintable

    Details

    • Message:
      [Function|Constructor|Method|Lambda] "XXXX" has {0} mandatory parameters, which is greater than the {1} authorized.
    • Highlighting:
      • Primary location: The function/method name or the lambda keyword
      • Secondary location: Mandatory parameters. No message.
    • List of parameters:
      • key: max
        • Description: Maximum authorized number of mandatory parameters
        • default: 7
    • Default Severity:
      Major
    • Impact:
      Low
    • Likelihood:
      High
    • Default Quality Profiles:
      Sonar way
    • Targeted languages:
      Python
    • Remediation Function:
      Constant/Issue
    • Constant Cost:
      20min
    • Analysis Level:
      Syntactic Analysis
    • Analysis Scope:
      Main Sources, Test Sources

      Description

      Function, methods and lambdas should not have too many mandatory parameters, i.e. parameters with no default value. Calling them will require code difficult to read and maintain. To solve this problem you could wrap some parameters in an object, split the function into simpler functions with less parameters or provide default values for some parameters.

        Attachments

          Issue Links

          1.
          Python RSPEC-5879 Language-Specification Active Unassigned

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              nicolas.harraudeau Nicolas Harraudeau (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated: