-
Notifications
You must be signed in to change notification settings - Fork 259
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
V2.4.0: Cyclomatic complexity calculation for a class fails #359
Comments
Please help me understandig the problem. Are you graph the CCN over time or why is this a problem? |
You can try to run PHPMetrics on a single class containing no conditions nor decision points, but 20 methods into. The CCN should be 1 but PHPMetrics will say 20. Currently, the CCN for a class is the sum of the CCN for all its methods, which must not be the case. |
Yes, the formula until 2.4 was I could not find any way use case for calculating the CC on classes. All papers / books i consulted applied the CC to procedures / methods. The only way to apply it to classes is the Weighted Method Count with the CC as weight metric, which is But perhaps it's better to add the WMC as own metric and drop the ccn for classes in a major release? |
I agree about the use cases on CC Classes, I also found only references on CC for functions/methods. Perhaps another metric should be used in the PHPMetrics bubble graph in a major release, but for now, we should keep using the ccn for classes for this graph and create the WMC as its own metric, like you purposed. Thanks a lot. |
Another way to define a cyclomatic complexity for a class could be the average of the CCN for all methods. It also offers consistancy with the average CC project displayed in the HTML output, as the average CC_Classes must be the average CC_Project. This could be used as a CC_Class metrics for the PHPMetrics bubble graph without having a change in the reports between 2.3.x and 2.4.x (no compatibility failure) and the WMC could still be stored in another metrics |
CCN by Class is deprecated and will be removed in v3. WMC should be used instead. To be BC compatible the CCN by Class will be retained until v3. Fixes phpmetrics#359
Average CCN sounds interesting too, but would also need a rebalance of the bublbe graph because of another value range. Please have a look at #362 |
I understand about rebalancing the bubble graph. Thanks again. |
Hi guys,
With the release of the version 2.4.0 today, I saw that my classes have a higher cyclomatic complexity level.
This is due to the fact that methods are increasing the CCN for a class, although it shouldn't.
(See In the CyclomaticComplexityVisitor, after running the $cb lambda function).
Can you please fix this?
Thanks a lot.
Best regards,
The text was updated successfully, but these errors were encountered: