There's a metrics plugin in eclipse that measures cyclomatic complexity by counting the decisions (independent paths), specifically:
(if, for, while, do, case, catch and the ?: ternary operator, as well as the && and || conditional logic operators in expressions)
For example, here's a method that would score 14. (1 + each decision path)
String getMonthName (int month) {
switch (month) {
case 0: return "January";
case 1: return "February";
case 2: return "March";
case 3: return "April";
case 4: return "May";
case 5: return "June";
case 6: return "July";
case 7: return "August";
case 8: return "September";
case 9: return "October";
case 10: return "November";
case 11: return "December";
default: throw new IllegalArgumentException();
}
}
I'm wondering if there's a way to have decisions without the mentioned branches in java, which would undermine the assessment. Basically, I want to have different decisions without the plugin detecting them as such. The metrics would show a lower cyclomatic complexity (independent paths/decisions) than there actually are.