Is there a way to filter by methods with the highest cognitive complexity?

Hi!

Using SonarQube, I can find under the tap ‘Measures’ within the category ‘Complexity’ on the left side, the metric ‘Cognitive Complexity’.

Is there any way, so that I could make SonarQube show the methods with the highest cognitive complexity in descending order?
Or maybe I could specify to show me all methods which have a higher cognitive complexity than a certain value?

I am grateful for any help on this matter.

Best wishes
Abegail

Hey @Abegail_Bar!

This is unfortunately not a feature of SonarQube, although I would find it useful!

I have used another solution to do this in the past: the IntelliJ plugin MetricsReloaded. It can compute the Cognitive Complexity of every method in your project and you can then sort from highest to lowest. The plugin links to our whitepaper on Cognitive Complexity. However, it is not a solution provided by Sonar, so I cannot guarantee its accuracy and reliability. It will also only work if you are using Java (I think).

Cheers,
Sylvain

1 Like

Thanks a lot!
Pitty, that this plugin is not for Eclipse.

Anyway, thanks a lot and also for the link to your white-paper regarding cognitive complexity.