diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/oom/metrics/CycloMetric.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/oom/metrics/CycloMetric.java index 8641ee4b0c..842e08c2aa 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/oom/metrics/CycloMetric.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/oom/metrics/CycloMetric.java @@ -25,23 +25,20 @@ import net.sourceforge.pmd.lang.java.oom.metrics.visitors.StandardCycloVisitor; *
The standard version of the metric complies with McCabe's original definition: * *
Version {@link Version#IGNORE_BOOLEAN_PATHS}: Boolean operators are not counted, which means that empty * fall-through cases in {@code switch} statements are not counted as well. * - *
References: - *
References:
[1] Lanza. Object-Oriented Metrics in Practice.
*
diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/oom/metrics/visitors/CycloPathUnawareOperationVisitor.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/oom/metrics/visitors/CycloPathUnawareOperationVisitor.java
index 827d34623e..31a6789861 100644
--- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/oom/metrics/visitors/CycloPathUnawareOperationVisitor.java
+++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/oom/metrics/visitors/CycloPathUnawareOperationVisitor.java
@@ -15,6 +15,7 @@ import net.sourceforge.pmd.lang.java.ast.ASTForStatement;
import net.sourceforge.pmd.lang.java.ast.ASTIfStatement;
import net.sourceforge.pmd.lang.java.ast.ASTSwitchLabel;
import net.sourceforge.pmd.lang.java.ast.ASTSwitchStatement;
+import net.sourceforge.pmd.lang.java.ast.ASTThrowStatement;
import net.sourceforge.pmd.lang.java.ast.ASTWhileStatement;
import net.sourceforge.pmd.lang.java.ast.JavaParserVisitorAdapter;
@@ -75,14 +76,6 @@ public class CycloPathUnawareOperationVisitor extends JavaParserVisitorAdapter {
}
- @Override
- public Object visit(ASTCatchStatement node, Object data) {
- ((MutableInt) data).increment();
- super.visit(node, data);
- return data;
- }
-
-
@Override
public Object visit(ASTForStatement node, Object data) {
((MutableInt) data).increment();
@@ -97,4 +90,21 @@ public class CycloPathUnawareOperationVisitor extends JavaParserVisitorAdapter {
super.visit(node, data);
return data;
}
+
+
+ @Override
+ public Object visit(ASTCatchStatement node, Object data) {
+ ((MutableInt) data).increment();
+ super.visit(node, data);
+ return data;
+ }
+
+
+ @Override
+ public Object visit(ASTThrowStatement node, Object data) {
+ ((MutableInt) data).increment();
+ super.visit(node, data);
+ return data;
+ }
+
}
diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/oom/metrics/visitors/DefaultNcssVisitor.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/oom/metrics/visitors/DefaultNcssVisitor.java
index a1e2c8e21e..f626572b83 100644
--- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/oom/metrics/visitors/DefaultNcssVisitor.java
+++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/oom/metrics/visitors/DefaultNcssVisitor.java
@@ -44,19 +44,6 @@ import net.sourceforge.pmd.lang.java.ast.JavaParserVisitorAdapter;
*/
public class DefaultNcssVisitor extends JavaParserVisitorAdapter {
- @Override
- public Object visit(ASTImportDeclaration node, Object data) {
- ((MutableInt) data).increment();
- return data;
- }
-
-
- @Override
- public Object visit(ASTPackageDeclaration node, Object data) {
- ((MutableInt) data).increment();
- return data;
- }
-
@Override
public Object visit(ASTClassOrInterfaceDeclaration node, Object data) {
diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/oom/metrics/visitors/StandardCycloVisitor.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/oom/metrics/visitors/StandardCycloVisitor.java
index 70cde74873..ffe8ed9923 100644
--- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/oom/metrics/visitors/StandardCycloVisitor.java
+++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/oom/metrics/visitors/StandardCycloVisitor.java
@@ -97,4 +97,5 @@ public class StandardCycloVisitor extends CycloPathUnawareOperationVisitor {
}
return data;
}
+
}
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
index b34eb7a44d..e7302c2c1a 100644
--- 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
@@ -4,6 +4,20 @@