You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PMD should report a cyclomatic complexity of 3 (starts at one, then +1 for each branch in the switch). It actually reports a cyclomatic complexity of 1.
Running PMD through:CLI
The text was updated successfully, but these errors were encountered:
I checked this in 7.0.0-rc4 and it has the same behaviour.
adangel
changed the title
[Apex] switch statements do not contribute to Cyclomatic Complexity numbers
[apex] switch statements do not contribute to Cyclomatic Complexity numbers
Mar 21, 2024
I'm happy to fork the repo and have a go at fixing this if you're happy to accept the changes once you're happy with them.
Affects PMD Version: 6.55
Rule:
Cyclomatic Complexity
Description:
The cyclomatic complexity of a method should be increased by adding a
switch
statement, but it does not.Moreover, the documentation states that it covers:
Which is not only not true, but also syntactically incorrect, as in Apex the keyword
when
is used instead ofcase
.Code Sample demonstrating the issue:
Expected outcome:
PMD should report a cyclomatic complexity of 3 (starts at one, then +1 for each branch in the switch). It actually reports a cyclomatic complexity of 1.
Running PMD through: CLI
The text was updated successfully, but these errors were encountered: