Complexity indicator in editor ignores indention

Please provide

  • Operating system: Windows 10 Pro (22H2)
  • SonarQube for IntelliJ plugin version: 10.16.0.80450
  • IntelliJ version: rider 2024.3.4
  • Programming language you’re coding in: C#
  • Is connected mode used: yes
    • SonarQube Cloud, SonarQube Server, or SonarQube Community Build? (if one of the latter two, which version?): Community Edition - Version 10.3 (build 82913)

And a thorough description of the problem / question:
A method I wrote was detected to have 34 out of 15 allowed cognitive complexity but when I jump to the method in the editor it only shows a cognitive complexity count of 12 at the end of the method because no indentation was counted. I’m not sure if I accidentally changed settings somewhere or if it’s just broken in the editor. The same seems to be true for all cognitive complexity warnings I get, the score in the sonarqube tab/page in the IDE is always higher than the indicators in the editor.

EDIT: I just noticed that the numbering in the editor doesn’t count up the to the cognitive complexity score. If I hover over keywords next to the numbers it shows the correct values. Is there a preference to have it show every +1 in the editor?

Hey @Miacelium, thanks for reaching out to us about this.

Could you please show a concrete example of the behavior you’re explaining? The numbering in the editor shows the different secondary locations of the issue. To see the related complexity score, you can check the Locations tab.

EDIT: I just noticed that the numbering in the editor doesn’t count up the to the cognitive complexity score. If I hover over keywords next to the numbers it shows the correct values. Is there a preference to have it show every +1 in the editor?

If you check the Locations tab on the right panel, you will see the different locations where the Cognitive Complexity adds up. Next to each item, there’s a message explaining the computation.

In the example above, if you add up the complexity from all locations, you end up with 1+2+3+4+5+6, which equals 21, as reported by the issue.

Let me know if something does not seem correct!