My sonarqube version is Community Edition Version 8.9.5 (build 50698)
I need to count the cyclomatic complexity of each projects scanned in Sonarqube into the report.
As shown in the diagram：
On the left side of the display is the cyclomatic complexity of the project total.
On the right is the cyclomatic complexity value for each code file.
Should I use cyclomatic complexity of the whole project total value or a single file complexity of the highest? If i use the total value that is too big.And we have a lot of projects,Report will look horrible, many projects total cyclomatic complexity are too big！
One should be the sum of the other, so just using the project value will be easier.
Could you explain what you’re trying to accomplish with this report?
That’s entirely subjective, and - at least IMO - very much up for debate.
And one thing you’re dealing with here is that Cyclomatic Complexity increments for every method. So if you start reporting on this and calling some project’s values “too big,” you will incent the wrong behavior: drop the score by combining methods.
If you must do this, I urge you to look at Cognitive Complexity instead.
I’m glad you reply to me.
I want to know which value can be representative of the entire project code cyclomatic complexity.
I heard someone say that we can use this project all the files under the corresponding code cyclomatic complexity of the biggest, rather than the total value.
Is that so?
I just want to choose a value from these values can represent the complexity of the whole project, rather than the sum of all files complexity or someone file of complexity.
Cyclomatic Complexity correlates pretty closely to LOC. Based on that, one option to get a non-literal gauge of project complexity would be the size labels SonarQube assigns to projects based on LOC.
Another option would be Cognitive Complexity which has a less-strong correlation to LOC.