-
Notifications
You must be signed in to change notification settings - Fork 363
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
implement explanation for cyclomatic complexity checks #1537
implement explanation for cyclomatic complexity checks #1537
Conversation
@ivangalkin also here my first question: are there relevant changes to to resulting metric values after the changes? |
Hi @guwirth, metrics are not affected, only the checks
For the entire file ( Regards |
@ivangalkin the reason why I'm always asking this: there are teams using the plugin to create hard/automated quality goals in there CI chain. Changing the values (especially increasing) could break their CI. We should at least inform in the release notes about such changes. |
@guwirth yes, I'm aware of that. I didn't change the tests for metrics - they produces the same value. I've added a couple of new test cases for the checks, since I wanted to be sure, that the issue locations are correct. My test installation also shows the same value for complexity metrics. |
Think SQ Java is also doing this. Maybe you can compare it with Java code results. Should be consistent. https://docs.sonarqube.org/plugins/servlet/mobile?contentId=11638440#content/view/11638440
Merged |
Hi @guwirth, you are right about the Java behavior. I've analyzed the official example and made the following conclusions:
For 2 and 3 please see the screenshots. By the way, the difference in cyclomatic and cognitive complexity w.r.t. the function declaration is documented in the official doc https://www.sonarsource.com/docs/CognitiveComplexity.pdf I'll correct my current pull request. The next 3 weeks I'm on vocation and will work on #1494 only sporadically. Regards, |
@ivangalkin wish you a relaxing vacation! |
1. implement multi-location messages for squidsensor * move CxxReportIssue and CxxReportLocation from cxx-sensors to cxx-squid in order to satisfy dependencies 2. introduce CxxCyclomaticComplexityCheck * this class is used for all scoped cyclomatic complexity checks * implement * ClassComplexityCheck * FileComplexityCheck * FunctionComplexityCheck * they respect the scopes (important for nested classes) * they provide detailed information about complexity sources * FileComplexityCheck previously had a wrong calculation: cyclomatic complexity of functions was always <correct score> + 1 -> fixed now This change addresses SonarOpenCommunity#1494: * cyclomatic complexity checks (done) * cognitive complexity checks (todo, depends on SonarOpenCommunity#1535
* apply comment about the cyclomatic complexity of functions: the function defintion is always included in the final complexity score * see https://docs.sonarqube.org/plugins/servlet/mobile?contentId=11638440#content/view/11638440
97a7a9d
to
06def8b
Compare
Hi @guwirth!
Thank you very much! I've applied you comment about the correct calculation of cyclomatic complexity w.r.t. function definition. Now it's done according to the official example and in the same way, Java plugin calculates it. Regards |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ivangalkin thx
Hi All, are there some objections to merge this change? I've already implemented the cognitive complexity check (planned as follow-up PR) and would like to finalize #1494. Thx |
@ivangalkin thx for providing this. Maybe you can have a look to technical debt on https://sonarcloud.io/dashboard?id=org.sonarsource.sonarqube-plugins.cxx%3Acxx and fix it in one of the next PR. Thx. |
@guwirth thank you for the hint; I'll provide the "fix quality flows" change soon |
cxx-sensors to cxx-squid in order to satisfy dependencies
this class is used for all scoped cyclomatic complexity checks
implement
they respect the scopes (important for nested classes)
they provide detailed information about complexity sources
This change addresses #1494:
This change is