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
The result from the Cyclomatic Complexity (CC_CYCLOMATIC_COMPLEXITY) detector (CyclomaticComplexity.java) reports 6 for the following method:
int f(int i, int j) {
int result;
if(i % 2 == 0) {
result = i + j;
}
else {
if(j % 2 == 0) {
result = i * j;
}
else {
result = i - j;
}
}
return result;
}
It seems to be quite consistent, that the reported CC is higher than the real CC, Unfortunately my understanding of the control flow graph in Spotbugs is insufficient to suggest how to fix this.
The text was updated successfully, but these errors were encountered:
riverwinddk
changed the title
Cyclomatic complexity calculation is wrong
CC_CYCLOMATIC_COMPLEXITY calculation is wrong
Aug 31, 2020
The result from the Cyclomatic Complexity (CC_CYCLOMATIC_COMPLEXITY) detector (CyclomaticComplexity.java) reports 6 for the following method:
The result should be 3, as documented here.
It seems to be quite consistent, that the reported CC is higher than the real CC, Unfortunately my understanding of the control flow graph in Spotbugs is insufficient to suggest how to fix this.
The text was updated successfully, but these errors were encountered: