Uploaded image for project: 'SonarSlang'
  1. SonarSlang
  2. SONARSLANG-342

Cognitive Complexity is not computed correctly for ternary operator

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.4
    • Component/s: None
    • Labels:
      None

      Description

      Complexity of a ternary operator should be like complexity of a "if" except there's no increment on the ":" (else) of the ternary expression.
      E.g.:

      if (condition) // +1
        foo();
      else // +1
        bar();
      
      int a = condition
              ? // +1
              v1
              : // not increment
              v2;
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                alban.auzeill Alban Auzeill
                Reporter:
                alban.auzeill Alban Auzeill
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Due:
                  Created:
                  Updated:
                  Resolved: