How to enable cognitive complexity via CI analysis?

I have my codebase analyzed by CI. I’d like to have “Cognitive Complexity” analyzed as well. I am unable to find any docs how/where to enable such analysis.

Hey there.

All of SonarCloud’s rules related to Cognitive Complexity are enabled in the built-in (and by default, default) Quality Profile – so unless you’ve turned them off, you should get issues raised if Cognitive Complexity surpasses the threshold defined by the rule.

Look for rules titled Cognitive Complexity of methods should not be too high in yoru Quality Profiles. For example, here is that rule for Java.

Thanks Colin,

Seems I misunderstood “Cognitive complexity” thing.

Is it a rule that triggers a Code Smell?

Is it possible to see some kind of report/summary of cognitive complexity per repository/file/class? (similar to how we can see summary lines coverage etc.)?

You can check the Measures tab of yorur project and get down to a project/folder/file level… although this is not super useful (a rocket launcher will be more complex than a calculator app)