diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/JavaParserVisitorReducedAdapter.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/JavaParserVisitorReducedAdapter.java new file mode 100644 index 0000000000..ed3d1c8110 --- /dev/null +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/JavaParserVisitorReducedAdapter.java @@ -0,0 +1,39 @@ +/** + * BSD-style license; for more info see http://pmd.sourceforge.net/license.html + */ + +package net.sourceforge.pmd.lang.java.ast; + +/** + * @author Clément Fournier + */ +public class JavaParserVisitorReducedAdapter extends JavaParserVisitorAdapter { + + public Object visit(ASTClassOrInterfaceDeclaration node, Object data) { + return visit((ASTAnyTypeDeclaration) node, data); + } + + public Object visit(ASTEnumDeclaration node, Object data) { + return visit((ASTAnyTypeDeclaration) node, data); + } + + public Object visit(ASTAnyTypeDeclaration node, Object data) { + return visit((JavaNode) node, data); + } + + public Object visit(ASTMethodDeclaration node, Object data) { + return visit((ASTMethodOrConstructorDeclaration) node, data); + } + + public Object visit(ASTConstructorDeclaration node, Object data) { + return visit((ASTMethodOrConstructorDeclaration) node, data); + } + + public Object visit(ASTMethodOrConstructorDeclaration node, Object data) { + return visit((JavaNode) node, data); + } + + + + +} diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/oom/AbstractMetric.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/oom/AbstractMetric.java index a67e016e75..eeb4381ac1 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/oom/AbstractMetric.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/oom/AbstractMetric.java @@ -8,7 +8,6 @@ import java.util.ArrayList; import java.util.List; import net.sourceforge.pmd.lang.java.ast.ASTAnyTypeDeclaration; -import net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceBody; import net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceBodyDeclaration; import net.sourceforge.pmd.lang.java.ast.ASTMethodOrConstructorDeclaration; import net.sourceforge.pmd.lang.java.ast.AccessNode; @@ -128,9 +127,8 @@ public abstract class AbstractMetric implements Metric { return node.findDescendantsOfType(ASTMethodOrConstructorDeclaration.class); } - ASTClassOrInterfaceBody body = (ASTClassOrInterfaceBody) node.jjtGetChild(0); List outerDecls - = body.findChildrenOfType(ASTClassOrInterfaceBodyDeclaration.class); + = node.jjtGetChild(0).findChildrenOfType(ASTClassOrInterfaceBodyDeclaration.class); List operations = new ArrayList<>(); diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/oom/ClassStats.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/oom/ClassStats.java index d5c10c528e..df7a9ea7f3 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/oom/ClassStats.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/oom/ClassStats.java @@ -12,7 +12,6 @@ import java.util.Map; import java.util.Set; import net.sourceforge.pmd.lang.java.ast.ASTAnyTypeDeclaration; -import net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceDeclaration; import net.sourceforge.pmd.lang.java.ast.ASTMethodOrConstructorDeclaration; import net.sourceforge.pmd.lang.java.ast.QualifiedName; import net.sourceforge.pmd.lang.java.oom.api.ClassMetric; diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/oom/Metrics.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/oom/Metrics.java index f30c056c60..26e940f6a0 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/oom/Metrics.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/oom/Metrics.java @@ -6,7 +6,6 @@ package net.sourceforge.pmd.lang.java.oom; import net.sourceforge.pmd.lang.java.ast.ASTAnyTypeDeclaration; -import net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceDeclaration; import net.sourceforge.pmd.lang.java.ast.ASTMethodOrConstructorDeclaration; import net.sourceforge.pmd.lang.java.oom.api.ClassMetricKey; import net.sourceforge.pmd.lang.java.oom.api.Metric.Version; diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/oom/MetricsVisitor.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/oom/MetricsVisitor.java index 92cc822c59..0491a038e5 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/oom/MetricsVisitor.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/oom/MetricsVisitor.java @@ -6,12 +6,10 @@ package net.sourceforge.pmd.lang.java.oom; import java.util.Stack; -import net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceDeclaration; -import net.sourceforge.pmd.lang.java.ast.ASTConstructorDeclaration; -import net.sourceforge.pmd.lang.java.ast.ASTEnumDeclaration; +import net.sourceforge.pmd.lang.java.ast.ASTAnyTypeDeclaration; import net.sourceforge.pmd.lang.java.ast.ASTFieldDeclaration; -import net.sourceforge.pmd.lang.java.ast.ASTMethodDeclaration; -import net.sourceforge.pmd.lang.java.ast.JavaParserVisitorAdapter; +import net.sourceforge.pmd.lang.java.ast.ASTMethodOrConstructorDeclaration; +import net.sourceforge.pmd.lang.java.ast.JavaParserVisitorReducedAdapter; import net.sourceforge.pmd.lang.java.oom.signature.FieldSignature; import net.sourceforge.pmd.lang.java.oom.signature.OperationSignature; @@ -21,12 +19,12 @@ import net.sourceforge.pmd.lang.java.oom.signature.OperationSignature; * * @author Clément Fournier */ -class MetricsVisitor extends JavaParserVisitorAdapter { +class MetricsVisitor extends JavaParserVisitorReducedAdapter { private Stack stack = new Stack<>(); @Override - public Object visit(ASTClassOrInterfaceDeclaration node, Object data) { + public Object visit(ASTAnyTypeDeclaration node, Object data) { stack.push(((PackageStats) data).getClassStats(node.getQualifiedName(), true)); super.visit(node, data); stack.pop(); @@ -34,26 +32,13 @@ class MetricsVisitor extends JavaParserVisitorAdapter { return data; } - @Override - public Object visit(ASTEnumDeclaration node, Object data) { - stack.push(((PackageStats) data).getClassStats(node.getQualifiedName(), true)); - super.visit(node, data); - stack.pop(); - - return data; - } @Override - public Object visit(ASTConstructorDeclaration node, Object data) { + public Object visit(ASTMethodOrConstructorDeclaration node, Object data) { stack.peek().addOperation(node.getQualifiedName().getOperation(), OperationSignature.buildFor(node)); return super.visit(node, data); } - @Override - public Object visit(ASTMethodDeclaration node, Object data) { - stack.peek().addOperation(node.getQualifiedName().getOperation(), OperationSignature.buildFor(node)); - return super.visit(node, data); - } @Override public Object visit(ASTFieldDeclaration node, Object data) { diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/oom/PackageStats.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/oom/PackageStats.java index b5485639b5..6fafaa1b96 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/oom/PackageStats.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/oom/PackageStats.java @@ -8,7 +8,6 @@ import java.util.HashMap; import java.util.Map; import net.sourceforge.pmd.lang.java.ast.ASTAnyTypeDeclaration; -import net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceDeclaration; import net.sourceforge.pmd.lang.java.ast.ASTMethodOrConstructorDeclaration; import net.sourceforge.pmd.lang.java.ast.QualifiedName; import net.sourceforge.pmd.lang.java.oom.api.ClassMetricKey; diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/oom/api/ClassMetricKey.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/oom/api/ClassMetricKey.java index e0f55c130f..8e8293a51e 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/oom/api/ClassMetricKey.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/oom/api/ClassMetricKey.java @@ -4,7 +4,7 @@ package net.sourceforge.pmd.lang.java.oom.api; -import net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceDeclaration; +import net.sourceforge.pmd.lang.java.ast.ASTAnyTypeDeclaration; import net.sourceforge.pmd.lang.java.oom.metrics.AtfdMetric; import net.sourceforge.pmd.lang.java.oom.metrics.CycloMetric; import net.sourceforge.pmd.lang.java.oom.metrics.LocMetric; @@ -37,7 +37,7 @@ public enum ClassMetricKey implements MetricKey { return calculator; } - public boolean supports(ASTClassOrInterfaceDeclaration node) { + public boolean supports(ASTAnyTypeDeclaration node) { return calculator.supports(node); } diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/AbstractJavaMetricsRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/AbstractJavaMetricsRule.java new file mode 100644 index 0000000000..2106ff6711 --- /dev/null +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/AbstractJavaMetricsRule.java @@ -0,0 +1,47 @@ +/** + * BSD-style license; for more info see http://pmd.sourceforge.net/license.html + */ + +package net.sourceforge.pmd.lang.java.rule; + +import net.sourceforge.pmd.lang.java.ast.ASTAnyTypeDeclaration; +import net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceDeclaration; +import net.sourceforge.pmd.lang.java.ast.ASTConstructorDeclaration; +import net.sourceforge.pmd.lang.java.ast.ASTEnumDeclaration; +import net.sourceforge.pmd.lang.java.ast.ASTMethodDeclaration; +import net.sourceforge.pmd.lang.java.ast.ASTMethodOrConstructorDeclaration; +import net.sourceforge.pmd.lang.java.ast.JavaNode; + +/** + * Java Rule with convenient visit methods to e.g. treat contructors and methods the same. + * + * @author Clément Fournier + */ +public abstract class AbstractJavaMetricsRule extends AbstractJavaRule { + + public Object visit(ASTClassOrInterfaceDeclaration node, Object data) { + return visit((ASTAnyTypeDeclaration) node, data); + } + + public Object visit(ASTEnumDeclaration node, Object data) { + return visit((ASTAnyTypeDeclaration) node, data); + } + + public Object visit(ASTAnyTypeDeclaration node, Object data) { + return visit((JavaNode) node, data); + } + + public Object visit(ASTMethodDeclaration node, Object data) { + return visit((ASTMethodOrConstructorDeclaration) node, data); + } + + public Object visit(ASTConstructorDeclaration node, Object data) { + return visit((ASTMethodOrConstructorDeclaration) node, data); + } + + public Object visit(ASTMethodOrConstructorDeclaration node, Object data) { + return visit((JavaNode) node, data); + } + + +} diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/oom/SignatureTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/oom/SignatureTest.java index 99771dbe75..6efeae43e4 100644 --- a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/oom/SignatureTest.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/oom/SignatureTest.java @@ -124,7 +124,6 @@ public class SignatureTest extends ParserTst { compilationUnit.jjtAccept(new JavaParserVisitorAdapter() { @Override public Object visit(ASTMethodDeclaration node, Object data) { - System.err.println(node.getMethodName()); assertEquals(Role.GETTER_OR_SETTER, Role.get(node)); return data; } diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/oom/metrics/AbstractMetricTestRule.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/oom/metrics/AbstractMetricTestRule.java index 616c01b7ea..52b64d6e7b 100644 --- a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/oom/metrics/AbstractMetricTestRule.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/oom/metrics/AbstractMetricTestRule.java @@ -4,41 +4,37 @@ package net.sourceforge.pmd.lang.java.oom.metrics; -import net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceDeclaration; +import net.sourceforge.pmd.lang.java.ast.ASTAnyTypeDeclaration; import net.sourceforge.pmd.lang.java.ast.ASTCompilationUnit; -import net.sourceforge.pmd.lang.java.ast.ASTConstructorDeclaration; -import net.sourceforge.pmd.lang.java.ast.ASTMethodDeclaration; import net.sourceforge.pmd.lang.java.ast.ASTMethodOrConstructorDeclaration; import net.sourceforge.pmd.lang.java.oom.Metrics; import net.sourceforge.pmd.lang.java.oom.api.ClassMetricKey; -import net.sourceforge.pmd.lang.java.oom.api.Metric; +import net.sourceforge.pmd.lang.java.oom.api.Metric.Version; import net.sourceforge.pmd.lang.java.oom.api.MetricVersion; import net.sourceforge.pmd.lang.java.oom.api.OperationMetricKey; import net.sourceforge.pmd.lang.java.oom.api.ResultOption; -import net.sourceforge.pmd.lang.java.rule.AbstractJavaRule; +import net.sourceforge.pmd.lang.java.rule.AbstractJavaMetricsRule; import net.sourceforge.pmd.lang.rule.properties.BooleanProperty; import net.sourceforge.pmd.lang.rule.properties.DoubleProperty; /** - * Abstract test for a metric. + * Abstract test rule for a metric. Tests of metrics use the standard framework for rule testing, using one dummy rule + * per metric. Default parameters can be overriden by overriding the protected methods of this class. * * @author Clément Fournier */ -public abstract class AbstractMetricTestRule extends AbstractJavaRule { +public abstract class AbstractMetricTestRule extends AbstractJavaMetricsRule { - public static final BooleanProperty REPORT_CLASSES_DESCRIPTOR = new BooleanProperty( - "reportClasses", "Add class violations to the report", true, 2.0f); - public static final BooleanProperty REPORT_METHODS_DESCRIPTOR = new BooleanProperty( - "reportMethods", "Add method violations to the report", true, 3.0f); - - public static final DoubleProperty REPORT_LEVEL_DESCRIPTOR = new DoubleProperty( - "reportLevel", "Minimum value required to report", -1., Double.POSITIVE_INFINITY, 0., 3.0f); - - - protected boolean reportClasses = true; - protected boolean reportMethods = true; - protected double reportLevel = 0.; - protected MetricVersion version = Metric.Version.STANDARD; + private final BooleanProperty reportClassesDescriptor = new BooleanProperty( + "reportClasses", "Add class violations to the report", isReportClasses(), 2.0f); + private final BooleanProperty reportMethodsDescriptor = new BooleanProperty( + "reportMethods", "Add method violations to the report", isReportMethods(), 3.0f); + private final DoubleProperty reportLevelDescriptor = new DoubleProperty( + "reportLevel", "Minimum value required to report", -1., Double.POSITIVE_INFINITY, defaultReportLevel(), 3.0f); + protected MetricVersion version; + private boolean reportClasses; + private boolean reportMethods; + private double reportLevel; private ClassMetricKey classKey; private OperationMetricKey opKey; @@ -46,26 +42,71 @@ public abstract class AbstractMetricTestRule extends AbstractJavaRule { classKey = getClassKey(); opKey = getOpKey(); - definePropertyDescriptor(REPORT_CLASSES_DESCRIPTOR); - definePropertyDescriptor(REPORT_METHODS_DESCRIPTOR); - definePropertyDescriptor(REPORT_LEVEL_DESCRIPTOR); + definePropertyDescriptor(reportClassesDescriptor); + definePropertyDescriptor(reportMethodsDescriptor); + definePropertyDescriptor(reportLevelDescriptor); } public Object visit(ASTCompilationUnit node, Object data) { - reportClasses = getProperty(REPORT_CLASSES_DESCRIPTOR); - reportMethods = getProperty(REPORT_METHODS_DESCRIPTOR); - reportLevel = getProperty(REPORT_LEVEL_DESCRIPTOR); + reportClasses = getProperty(reportClassesDescriptor); + reportMethods = getProperty(reportMethodsDescriptor); + reportLevel = getProperty(reportLevelDescriptor); return super.visit(node, data); } + /** + * Sets the default for reportClasses descriptor. + * + * @return The default for reportClasses descriptor + */ + protected boolean isReportClasses() { + return true; + } + /** + * Sets the default for reportMethods descriptor. + * + * @return The default for reportMethods descriptor + */ + protected boolean isReportMethods() { + return true; + } + + /** + * Sets the version to test + * + * @return The version to test + */ + protected MetricVersion version() { + return Version.STANDARD; + } + + /** + * Returns the class metric key to test, or null if we shouldn't test classes. + * + * @return The class metric key to test. + */ protected abstract ClassMetricKey getClassKey(); + /** + * Returns the class metric key to test, or null if we shouldn't test classes. + * + * @return The class metric key to test. + */ protected abstract OperationMetricKey getOpKey(); + /** + * Default report level, which is 0. + * + * @return The default report level. + */ + protected double defaultReportLevel() { + return 0.; + } + @Override - public Object visit(ASTClassOrInterfaceDeclaration node, Object data) { + public Object visit(ASTAnyTypeDeclaration node, Object data) { if (classKey != null && reportClasses && classKey.supports(node)) { int classValue = (int) Metrics.get(classKey, node, version); @@ -82,17 +123,9 @@ public abstract class AbstractMetricTestRule extends AbstractJavaRule { return super.visit(node, data); } - @Override - public Object visit(ASTMethodDeclaration node, Object data) { - return processMethodOrConstructorDeclaration(node, data); - } @Override - public Object visit(ASTConstructorDeclaration node, Object data) { - return processMethodOrConstructorDeclaration(node, data); - } - - protected Object processMethodOrConstructorDeclaration(ASTMethodOrConstructorDeclaration node, Object data) { + public Object visit(ASTMethodOrConstructorDeclaration node, Object data) { if (opKey != null && reportMethods && opKey.supports(node)) { int methodValue = (int) Metrics.get(opKey, node, version); if (methodValue >= reportLevel) { diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/oom/metrics/AllMetricsTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/oom/metrics/AllMetricsTest.java index c32c631efe..aa8c135be3 100644 --- a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/oom/metrics/AllMetricsTest.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/oom/metrics/AllMetricsTest.java @@ -15,9 +15,9 @@ public class AllMetricsTest extends SimpleAggregatorTst { @Override public void setUp() { - addRule(RULESET, "CyclomaticComplexity"); + addRule(RULESET, "CycloTest"); + addRule(RULESET, "NcssTest"); } - } diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/oom/metrics/NcssTestRule.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/oom/metrics/NcssTestRule.java new file mode 100644 index 0000000000..7095c7c1dc --- /dev/null +++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/oom/metrics/NcssTestRule.java @@ -0,0 +1,29 @@ +/** + * BSD-style license; for more info see http://pmd.sourceforge.net/license.html + */ + +package net.sourceforge.pmd.lang.java.oom.metrics; + +import net.sourceforge.pmd.lang.java.oom.api.ClassMetricKey; +import net.sourceforge.pmd.lang.java.oom.api.OperationMetricKey; + +/** + * @author Clément Fournier + */ +public class NcssTestRule extends AbstractMetricTestRule { + + @Override + protected boolean isReportClasses() { + return false; + } + + @Override + protected ClassMetricKey getClassKey() { + return ClassMetricKey.NCSS; + } + + @Override + protected OperationMetricKey getOpKey() { + return OperationMetricKey.NCSS; + } +} diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/oom/metrics/xml/CycloTest.xml b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/oom/metrics/xml/CycloTest.xml new file mode 100644 index 0000000000..82d39f9ebc --- /dev/null +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/oom/metrics/xml/CycloTest.xml @@ -0,0 +1,185 @@ + + + + + + + + + Complicated method + 2 + + '.Complicated' has value 18 highest 17. + '.Complicated#example()' has value 17. + + + + + + Empty methods should count 1 + false + 1 + + '.Foo#foo()' has value 1. + + + + + + + + Empty class should count 1 + 1 + + '.Foo' has value 0 highest 0. + + + + + + + + + + + + + #984 Cyclomatic complexity should treat constructors like methods + + false + 1 + + '.Test#Test()' has value 4. + + + + + + + + + + + Standard Cyclo should count empty switch labels too + false + 2 + 1 + + '.Foo#switchCase()' has value 3. + + + + + + 2 || y < 4) { + while (x++ < 10 && !(y-- < 0)); + } else if (a && b || x < 4) { + return; + } + } + } + ]]> + + + + Standard Cyclo should count boolean paths + 1 + false + + '.Foo#foo()' has value 8. + + + + + + Avoid division by 0 when averaging a metric over no operations + -1 + 1 + '.Foo' has value NaN. + + + + + + + diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/oom/metrics/xml/NcssTest.xml b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/oom/metrics/xml/NcssTest.xml new file mode 100644 index 0000000000..0dd9d3d71d --- /dev/null +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/oom/metrics/xml/NcssTest.xml @@ -0,0 +1,312 @@ + + + + + + + + + Full example + true + 3 + + '.Foo' has value 35 highest 18. + '.Foo#foo()' has value 1. + '.Foo#main(String)' has value 18. + + + + + + Empty method + 1 + + '.Foo#foo()' has value 1. + + + + + + + + Empty class + true + 1 + + '.Moo' has value 1 highest 0. + + + + + + + + Switch + 1 + + '.Boo#foo()' has value 11. + + + + + + + + Multiple local variable declarations + 1 + + '.Boo#foo()' has value 2. + + + + + + + + First catch is not counted + 1 + + '.Boo#foo()' has value 3. + + + + + + + + Empty statements are not counted + 1 + + '.Boo#foo()' has value 2. + + + + + + + + Blocks are not counted + 1 + + '.Boo#foo()' has value 3. + + + + + + + + For initialisations are not counted + 1 + + '.Hoo#foo()' has value 3. + + + + + + + + Nested classes are counted + true + false + 2 + + '.Boo' has value 8 highest 2. + '.Boo$Barnabee' has value 5 highest 2. + + + + + + + + Nested classes are counted + true + false + 2 + + '.Boo' has value 8 highest 2. + '.Boo$Barnabee' has value 5 highest 2. + + + + + + + + Enum constants are not counted + true + false + 1 + + '.Shoo' has value 1 highest 0. + + + + + + + diff --git a/pmd-java/src/test/resources/rulesets/java/metrics_test.xml b/pmd-java/src/test/resources/rulesets/java/metrics_test.xml index bcc9d33dae..4cbdec77e6 100644 --- a/pmd-java/src/test/resources/rulesets/java/metrics_test.xml +++ b/pmd-java/src/test/resources/rulesets/java/metrics_test.xml @@ -9,9 +9,16 @@ Metrics testing ruleset. - + + + +