Skip to content
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

Change the calculation of cyclomatic complexity #353

Merged
merged 2 commits into from
Jul 9, 2018

Conversation

UFOMelkor
Copy link
Member

The changes in detail:

  • xor has not been covered yet.
  • The ternary operator and the coalesce operator has been count both
    as 2. Also the default case of a switch statement has been counted.
    But as the else statement is not counted because it represents the
    default path (and can be elimated), the default case should not be
    counted (corresponds to else) and both the ternary and the coalesce
    operator should be counted as 1, because they can be exchanged by
    if-else / if which would be counted as 1.
    The spaceship operator by contrast is now counted as 2, because it
    would need if-elseif-else to replace it.
  • continue does not increase the cyclomatic complexity as its no
    decision. It's the if around the continue which increases the ccn.

I would be very thankfully about any thoughts to this changes.

 - xor has not been covered yet.
 - The ternary operator and the coalesce operator has been count both
   as 2. Also the default case of a switch statement has been counted.
   But as the else statement is not counted because it represents the
   default path (and can be elimated), the default case should not be
   counted (corresponds to else) and both the ternary and the coalesce
   operator should be counted as 1, because they can be exchanged by
   if-else / if which would be counted as 1.
   The spaceship operator by contrast is now counted as 2, because it
   would need if-elseif-else to replace it.
 - continue does not increase the cyclomatic complexity as its no
   decision. It's the if around the continue which increases the ccn.
 - Add documentation about cc and wmc.
 - Change calculation of wmc. Until now the base path has been added
   just once per class, this has been changed to once per method to
   strictly follow wmc.

Additional changes:
 - Code clean up for the touched classes (should now follow PSR-2)
@UFOMelkor UFOMelkor merged commit 0086da0 into phpmetrics:master Jul 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant