Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SonarQube: How to increase the Cognitive Complexity Threshold in Sonar Portal?

Tags:

sonarqube

Do anyone knows how to increase the cognitive complexity threshold in Sonar Portal? I searched in the portal but I could not find any clue on it.

Default is 15, I want to increase it to 25

like image 212
Shubh Rocks Goel Avatar asked May 21 '18 08:05

Shubh Rocks Goel


People also ask

How do you change Cognitive Complexity in SonarQube?

If you're using the Sonar way profile, you'll find that it's not editable there. In that case, you'll need to make a copy of the Sonar way profile and edit the parameter there. Then either set your new profile as the default, or explicitly assign the relevant projects to be analyzed with it.

How does SonarQube determine Cognitive Complexity?

SonarQube calculates the number of “if” conditions, nested loops like “for”, “forEach”, “do-while” and also “&&” and “||”. So, we have here complexity of 4 conditions. One of the possible solutions — move the logic of && conditions to another separate method. and call it like this.


1 Answers

You need to edit the value of the rule parameter in the appropriate profile. If you're using the Sonar way profile, you'll find that it's not editable there. In that case, you'll need to make a copy of the Sonar way profile and edit the parameter there. Then either set your new profile as the default, or explicitly assign the relevant projects to be analyzed with it.

like image 132
G. Ann - SonarSource Team Avatar answered Dec 15 '22 00:12

G. Ann - SonarSource Team