resources.report.rules.pmd.CyclomaticComplexity20.html Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sanity4j Show documentation
Show all versions of sanity4j Show documentation
Sanity4J was created to simplify running multiple static code
analysis tools on the Java projects. It provides a single entry
point to run all the selected tools and produce a consolidated
report, which presents all findings in an easily accessible
manner.
CyclomaticComplexity
CyclomaticComplexity (20)
Complexity is determined by the number of decision points in a method plus one for the
method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally,
1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity,
and 11+ is very high complexity.
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
© 2015 - 2024 Weber Informatics LLC | Privacy Policy