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

Cognitive Complexity of functions should not be too high

    Details

    • Type: Code Smell Detection
    • Status: Active
    • Resolution: Unresolved
    • Labels:
    • Message:
      Refactor this method to reduce its Cognitive Complexity from x to the y allowed.
    • Highlighting:
      • primary: Method/function name
      • secondary: Keywords & operators that cause increments
    • List of parameters:
      Hide
      • key: threshold
      • default: 15
      • description: The maximum authorized complexity.

      c-family:

      • key: maximumFunctionCognitiveComplexityThreshold
      • default: 25
      • description: The maximum authorized complexity.

      abap:

      • key: threshold
      • default: 60
      • description: The maximum authorized complexity.
      Show
      key: threshold default: 15 description: The maximum authorized complexity. c-family: key: maximumFunctionCognitiveComplexityThreshold default: 25 description: The maximum authorized complexity. abap: key: threshold default: 60 description: The maximum authorized complexity.
    • Default Severity:
      Critical
    • Impact:
      High
    • Likelihood:
      Low
    • Default Quality Profiles:
      Sonar way
    • Targeted languages:
      APEX, Cobol, Flex, PL/I, PL/SQL, RPG, Rust, Solidity, T-SQL, VB6
    • Covered Languages:
      ABAP, C#, C, C++, Go, Java, JavaScript, Kotlin, Objective-C, PHP, Python, Ruby, Scala, Swift, TypeScript, VB.Net
    • Irrelevant for Languages:
      HTML, XML
    • Remediation Function:
      Linear with offset
    • Linear Argument Description:
      per complexity point over the threshold
    • Linear Factor:
      1min
    • Linear Offset:
      5min
    • Analysis Level:
      Syntactic Analysis
    • Analysis Scope:
      Main Sources, Test Sources
    • Common Rule:
      Yes
    • ESLint-SonarJS:
      cognitive-complexity
    • FxCop:
      AvoidUnmantainableCode, CA1505
    • TSLint-SonarTS:
      cognitive-complexity

      Description

      Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

      See

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                elena.vilchik Elena Vilchik
                Reporter:
                ann.campbell.2 Ann Campbell
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated: