This rule is defined by the following Java class: net.sourceforge.pmd.rules.CyclomaticComplexity
Example:
// Cyclomatic Complexity = 12 public class Foo { 1 public void example() { 2 if (a == b) { 3 if (a1 == b1) { fiddle(); 4 } else if a2 == b2) { fiddle(); } else { fiddle(); } 5 } else if (c == d) { 6 while (c == d) { fiddle(); } 7 } else if (e == f) { 8 for (int n = 0; n < h; n++) { fiddle(); } } else{ switch (z) { 9 case 1: fiddle(); break; 10 case 2: fiddle(); break; 11 case 3: fiddle(); break; 12 default: fiddle(); break; } } } }
This rule has the following properties:
Name | Default value | Description |
---|---|---|
reportLevel | 20 | The Cyclomatic Complexity reporting threshold |
showClassesComplexity | true | Indicate if class average violation should be added to the report |
showMethodsComplexity | true | Indicate if class average violation should be added to the report |