Moved interfaces and renamed package

Prepare abstraction of metrics
This commit is contained in:
oowekyala
2017-07-24 16:03:33 +02:00
parent 0265a0c9f1
commit ac89e1420c
60 changed files with 362 additions and 352 deletions

View File

@ -19,7 +19,7 @@ import net.sourceforge.pmd.lang.java.ast.DumpFacade;
import net.sourceforge.pmd.lang.java.ast.JavaNode;
import net.sourceforge.pmd.lang.java.dfa.DataFlowFacade;
import net.sourceforge.pmd.lang.java.dfa.JavaDFAGraphRule;
import net.sourceforge.pmd.lang.java.oom.MetricsVisitorFacade;
import net.sourceforge.pmd.lang.java.metrics.JavaMetricsVisitorFacade;
import net.sourceforge.pmd.lang.java.rule.JavaRuleViolationFactory;
import net.sourceforge.pmd.lang.java.symboltable.SymbolFacade;
import net.sourceforge.pmd.lang.java.typeresolution.TypeResolutionFacade;
@ -102,7 +102,7 @@ public abstract class AbstractJavaHandler extends AbstractLanguageVersionHandler
return new VisitorStarter() {
@Override
public void start(Node rootNode) {
new MetricsVisitorFacade().initializeWith((ASTCompilationUnit) rootNode);
new JavaMetricsVisitorFacade().initializeWith((ASTCompilationUnit) rootNode);
}
};
}

View File

@ -2,7 +2,7 @@
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.oom;
package net.sourceforge.pmd.lang.java.metrics;
import java.util.ArrayList;
import java.util.List;
@ -10,18 +10,18 @@ import java.util.List;
import net.sourceforge.pmd.lang.ast.Node;
import net.sourceforge.pmd.lang.java.ast.ASTMethodOrConstructorDeclaration;
import net.sourceforge.pmd.lang.java.ast.QualifiedName;
import net.sourceforge.pmd.lang.java.oom.api.Metric;
import net.sourceforge.pmd.lang.metrics.api.Metric;
/**
* Base class for metrics. Metric objects encapsulate the computational logic required to compute a metric from a
* PackageStats and node. They're stateless.
* JavaPackageStats and node. They're stateless.
*
* @param <N> Type of node the metric can be computed on
*
* @author Clément Fournier
*/
public abstract class AbstractMetric<N extends Node> implements Metric<N> {
public abstract class AbstractJavaMetric<N extends Node> implements Metric<N> {
protected List<QualifiedName> findAllCalls(ASTMethodOrConstructorDeclaration node) {
List<QualifiedName> result = new ArrayList<>();
@ -35,10 +35,10 @@ public abstract class AbstractMetric<N extends Node> implements Metric<N> {
/**
* Gives access to the toplevel package stats to metrics without having to pass them as a parameter to metrics.
*
* @return The toplevel package stats (singleton contained within {@link Metrics}).
* @return The toplevel package stats (singleton contained within {@link JavaMetrics}).
*/
protected static PackageStats getTopLevelPackageStats() {
return Metrics.getTopLevelPackageStats();
protected static JavaPackageStats getTopLevelPackageStats() {
return JavaMetrics.getTopLevelPackageStats();
}
}

View File

@ -2,7 +2,7 @@
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.oom;
package net.sourceforge.pmd.lang.java.metrics;
import java.util.ArrayList;
import java.util.HashMap;
@ -15,29 +15,30 @@ import net.sourceforge.pmd.lang.java.ast.ASTAnyTypeBodyDeclaration;
import net.sourceforge.pmd.lang.java.ast.ASTAnyTypeDeclaration;
import net.sourceforge.pmd.lang.java.ast.ASTMethodOrConstructorDeclaration;
import net.sourceforge.pmd.lang.java.ast.QualifiedName;
import net.sourceforge.pmd.lang.java.oom.api.MetricKey;
import net.sourceforge.pmd.lang.java.oom.api.MetricVersion;
import net.sourceforge.pmd.lang.java.oom.api.ResultOption;
import net.sourceforge.pmd.lang.java.oom.signature.FieldSigMask;
import net.sourceforge.pmd.lang.java.oom.signature.FieldSignature;
import net.sourceforge.pmd.lang.java.oom.signature.OperationSigMask;
import net.sourceforge.pmd.lang.java.oom.signature.OperationSignature;
import net.sourceforge.pmd.lang.metrics.ParameterizedMetricKey;
import net.sourceforge.pmd.lang.metrics.api.MetricKey;
import net.sourceforge.pmd.lang.metrics.api.MetricVersion;
import net.sourceforge.pmd.lang.metrics.api.ResultOption;
import net.sourceforge.pmd.lang.java.metrics.signature.FieldSigMask;
import net.sourceforge.pmd.lang.java.metrics.signature.FieldSignature;
import net.sourceforge.pmd.lang.java.metrics.signature.OperationSigMask;
import net.sourceforge.pmd.lang.java.metrics.signature.OperationSignature;
/**
* Statistics about a class, enum, interface, or annotation. Gathers information about the contained members and their
* signatures. This class does not provide methods to operate directly on its nested classes, but only on itself. To
* operate on a nested class, retrieve the correct ClassStats with
* {@link PackageStats#getClassStats(QualifiedName, boolean)} then use the methods of ClassStats.
* operate on a nested class, retrieve the correct JavaClassStats with
* {@link JavaPackageStats#getClassStats(QualifiedName, boolean)} then use the methods of JavaClassStats.
*
* <p>Note that at this level, entities of the data structure do not manipulate QualifiedNames anymore, only Strings.
*
* @author Clément Fournier
*/
/* default */ class ClassStats {
/* default */ class JavaClassStats {
private Map<OperationSignature, Map<String, OperationStats>> operations = new HashMap<>();
private Map<OperationSignature, Map<String, JavaOperationStats>> operations = new HashMap<>();
private Map<FieldSignature, Set<String>> fields = new HashMap<>();
private Map<String, ClassStats> nestedClasses = new HashMap<>();
private Map<String, JavaClassStats> nestedClasses = new HashMap<>();
private Map<ParameterizedMetricKey, Double> memo = new HashMap<>();
@ -48,13 +49,13 @@ import net.sourceforge.pmd.lang.java.oom.signature.OperationSignature;
/**
* Finds a ClassStats in the direct children of this class. This can only be a directly nested class, for example
* Finds a JavaClassStats in the direct children of this class. This can only be a directly nested class, for example
* in the following snippet, A can get B and B can get C but A cannot get C without asking B.
* <pre>
* {@code
* class MyClass { // ClassStats A
* class MyNested { // ClassStats B
* class MyDeeplyNested { // ClassStats C
* class MyClass { // JavaClassStats A
* class MyNested { // JavaClassStats B
* class MyDeeplyNested { // JavaClassStats C
* }
* }
* }
@ -62,13 +63,13 @@ import net.sourceforge.pmd.lang.java.oom.signature.OperationSignature;
* </pre>
*
* @param className Name of the nested class
* @param createIfNotFound Create the requested ClassStats if missing
* @param createIfNotFound Create the requested JavaClassStats if missing
*
* @return The new ClassStats or the one that was found. Can return null if createIfNotFound is unset
* @return The new JavaClassStats or the one that was found. Can return null if createIfNotFound is unset
*/
/* default */ ClassStats getNestedClassStats(String className, boolean createIfNotFound) {
/* default */ JavaClassStats getNestedClassStats(String className, boolean createIfNotFound) {
if (createIfNotFound && !nestedClasses.containsKey(className)) {
nestedClasses.put(className, new ClassStats());
nestedClasses.put(className, new JavaClassStats());
}
return nestedClasses.get(className);
}
@ -82,9 +83,9 @@ import net.sourceforge.pmd.lang.java.oom.signature.OperationSignature;
*/
/* default */ void addOperation(String name, OperationSignature sig) {
if (!operations.containsKey(sig)) {
operations.put(sig, new HashMap<String, OperationStats>());
operations.put(sig, new HashMap<String, JavaOperationStats>());
}
operations.get(sig).put(name, new OperationStats(name));
operations.get(sig).put(name, new JavaOperationStats(name));
}
@ -188,13 +189,13 @@ import net.sourceforge.pmd.lang.java.oom.signature.OperationSignature;
String name, boolean force, MetricVersion version) {
// TODO:cf the operation signature might be built many times, consider storing it in the node
Map<String, OperationStats> sigMap = operations.get(OperationSignature.buildFor(node));
Map<String, JavaOperationStats> sigMap = operations.get(OperationSignature.buildFor(node));
if (sigMap == null) {
return Double.NaN;
}
OperationStats stats = sigMap.get(name);
JavaOperationStats stats = sigMap.get(name);
return stats == null ? Double.NaN : stats.compute(key, node, force, version);
}

View File

@ -2,15 +2,15 @@
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.oom;
package net.sourceforge.pmd.lang.java.metrics;
import net.sourceforge.pmd.lang.java.ast.ASTAnyTypeDeclaration;
import net.sourceforge.pmd.lang.java.ast.ASTMethodOrConstructorDeclaration;
import net.sourceforge.pmd.lang.java.oom.api.Metric.Version;
import net.sourceforge.pmd.lang.java.oom.api.MetricKey;
import net.sourceforge.pmd.lang.java.oom.api.MetricVersion;
import net.sourceforge.pmd.lang.java.oom.api.ResultOption;
import net.sourceforge.pmd.lang.metrics.api.Metric.Version;
import net.sourceforge.pmd.lang.metrics.api.MetricKey;
import net.sourceforge.pmd.lang.metrics.api.MetricVersion;
import net.sourceforge.pmd.lang.metrics.api.ResultOption;
/**
@ -18,12 +18,12 @@ import net.sourceforge.pmd.lang.java.oom.api.ResultOption;
*
* @author Clément Fournier
*/
public final class Metrics {
public final class JavaMetrics {
private static final PackageStats TOP_LEVEL_PACKAGE = new PackageStats();
private static final JavaPackageStats TOP_LEVEL_PACKAGE = new JavaPackageStats();
private Metrics() { // Cannot be instantiated
private JavaMetrics() { // Cannot be instantiated
}
@ -33,7 +33,7 @@ public final class Metrics {
*
* @return The top level package stats
*/
/* default */ static PackageStats getTopLevelPackageStats() {
/* default */ static JavaPackageStats getTopLevelPackageStats() {
return TOP_LEVEL_PACKAGE;
}

View File

@ -2,7 +2,7 @@
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.oom;
package net.sourceforge.pmd.lang.java.metrics;
import java.util.Stack;
@ -10,23 +10,23 @@ import net.sourceforge.pmd.lang.java.ast.ASTAnyTypeDeclaration;
import net.sourceforge.pmd.lang.java.ast.ASTFieldDeclaration;
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;
import net.sourceforge.pmd.lang.java.metrics.signature.FieldSignature;
import net.sourceforge.pmd.lang.java.metrics.signature.OperationSignature;
/**
* Visitor for the metrics framework, that fills a {@link PackageStats} object with the
* Visitor for the metrics framework, that fills a {@link JavaPackageStats} object with the
* signatures of operations and fields it encounters.
*
* @author Clément Fournier
*/
class MetricsVisitor extends JavaParserVisitorReducedAdapter {
class JavaMetricsVisitor extends JavaParserVisitorReducedAdapter {
private Stack<ClassStats> stack = new Stack<>();
private Stack<JavaClassStats> stack = new Stack<>();
@Override
public Object visit(ASTAnyTypeDeclaration node, Object data) {
stack.push(((PackageStats) data).getClassStats(node.getQualifiedName(), true));
stack.push(((JavaPackageStats) data).getClassStats(node.getQualifiedName(), true));
super.visit(node, data);
stack.pop();

View File

@ -2,7 +2,7 @@
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.oom;
package net.sourceforge.pmd.lang.java.metrics;
import net.sourceforge.pmd.lang.java.ast.ASTCompilationUnit;
import net.sourceforge.pmd.lang.java.ast.JavaParserVisitorAdapter;
@ -12,11 +12,11 @@ import net.sourceforge.pmd.lang.java.ast.JavaParserVisitorAdapter;
*
* @author Clément Fournier
*/
public class MetricsVisitorFacade extends JavaParserVisitorAdapter {
public class JavaMetricsVisitorFacade extends JavaParserVisitorAdapter {
public void initializeWith(ASTCompilationUnit rootNode) {
MetricsVisitor visitor = new MetricsVisitor();
rootNode.jjtAccept(visitor, Metrics.getTopLevelPackageStats());
JavaMetricsVisitor visitor = new JavaMetricsVisitor();
rootNode.jjtAccept(visitor, JavaMetrics.getTopLevelPackageStats());
}
}

View File

@ -2,14 +2,15 @@
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.oom;
package net.sourceforge.pmd.lang.java.metrics;
import java.util.HashMap;
import java.util.Map;
import net.sourceforge.pmd.lang.java.ast.ASTMethodOrConstructorDeclaration;
import net.sourceforge.pmd.lang.java.oom.api.MetricKey;
import net.sourceforge.pmd.lang.java.oom.api.MetricVersion;
import net.sourceforge.pmd.lang.metrics.ParameterizedMetricKey;
import net.sourceforge.pmd.lang.metrics.api.MetricKey;
import net.sourceforge.pmd.lang.metrics.api.MetricVersion;
/**
@ -17,13 +18,13 @@ import net.sourceforge.pmd.lang.java.oom.api.MetricVersion;
*
* @author Clément Fournier
*/
/* default */ class OperationStats {
/* default */ class JavaOperationStats {
private final String name;
private final Map<ParameterizedMetricKey, Double> memo = new HashMap<>();
/* default */ OperationStats(String name) {
/* default */ JavaOperationStats(String name) {
this.name = name;
}
@ -66,7 +67,7 @@ import net.sourceforge.pmd.lang.java.oom.api.MetricVersion;
return false;
}
OperationStats stats = (OperationStats) o;
JavaOperationStats stats = (JavaOperationStats) o;
return name != null ? name.equals(stats.name) : stats.name == null;
}

View File

@ -2,7 +2,7 @@
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.oom;
package net.sourceforge.pmd.lang.java.metrics;
import java.util.HashMap;
import java.util.Map;
@ -10,11 +10,11 @@ import java.util.Map;
import net.sourceforge.pmd.lang.java.ast.ASTAnyTypeDeclaration;
import net.sourceforge.pmd.lang.java.ast.ASTMethodOrConstructorDeclaration;
import net.sourceforge.pmd.lang.java.ast.QualifiedName;
import net.sourceforge.pmd.lang.java.oom.api.MetricKey;
import net.sourceforge.pmd.lang.java.oom.api.MetricVersion;
import net.sourceforge.pmd.lang.java.oom.api.ResultOption;
import net.sourceforge.pmd.lang.java.oom.signature.FieldSigMask;
import net.sourceforge.pmd.lang.java.oom.signature.OperationSigMask;
import net.sourceforge.pmd.lang.metrics.api.MetricKey;
import net.sourceforge.pmd.lang.metrics.api.MetricVersion;
import net.sourceforge.pmd.lang.metrics.api.ResultOption;
import net.sourceforge.pmd.lang.java.metrics.signature.FieldSigMask;
import net.sourceforge.pmd.lang.java.metrics.signature.OperationSigMask;
/**
@ -22,18 +22,18 @@ import net.sourceforge.pmd.lang.java.oom.signature.OperationSigMask;
* project and stores information about the classes and subpackages it contains.
*
* @author Clément Fournier
* @see ClassStats
* @see JavaClassStats
*/
public final class PackageStats {
public final class JavaPackageStats {
private final Map<String, PackageStats> subPackages = new HashMap<>();
private final Map<String, ClassStats> classes = new HashMap<>();
private final Map<String, JavaPackageStats> subPackages = new HashMap<>();
private final Map<String, JavaClassStats> classes = new HashMap<>();
/**
* Default constructor.
*/
/* default */ PackageStats() {
/* default */ JavaPackageStats() {
}
@ -57,23 +57,23 @@ public final class PackageStats {
* @return True if the signature of the operation designated by the qualified name is covered by the mask
*/
public boolean hasMatchingSig(QualifiedName qname, OperationSigMask sigMask) {
ClassStats clazz = getClassStats(qname, false);
JavaClassStats clazz = getClassStats(qname, false);
return clazz != null && clazz.hasMatchingSig(qname.getOperation(), sigMask);
}
/**
* Gets the ClassStats corresponding to the named resource. The class can be nested. If the
* Gets the JavaClassStats corresponding to the named resource. The class can be nested. If the
* createIfNotFound parameter is set, the method also creates the hierarchy if it doesn't exist.
*
* @param qname The qualified name of the class
* @param createIfNotFound Create hierarchy if missing
*
* @return The new ClassStats, or the one that was found. Can return null only if createIfNotFound is unset
* @return The new JavaClassStats, or the one that was found. Can return null only if createIfNotFound is unset
*/
/* default */ ClassStats getClassStats(QualifiedName qname, boolean createIfNotFound) {
PackageStats container = getSubPackage(qname, createIfNotFound);
/* default */ JavaClassStats getClassStats(QualifiedName qname, boolean createIfNotFound) {
JavaPackageStats container = getSubPackage(qname, createIfNotFound);
if (container == null) {
return null;
@ -81,10 +81,10 @@ public final class PackageStats {
String topClassName = qname.getClasses()[0];
if (createIfNotFound && classes.get(topClassName) == null) {
classes.put(topClassName, new ClassStats());
classes.put(topClassName, new JavaClassStats());
}
ClassStats next = classes.get(topClassName);
JavaClassStats next = classes.get(topClassName);
if (next == null) {
return null;
@ -93,7 +93,7 @@ public final class PackageStats {
String[] nameClasses = qname.getClasses();
for (int i = 1; i < nameClasses.length && next != null; i++) {
// Delegate search for nested classes to ClassStats
// Delegate search for nested classes to JavaClassStats
next = next.getNestedClassStats(nameClasses[i], createIfNotFound);
}
@ -102,25 +102,25 @@ public final class PackageStats {
/**
* Returns the deepest PackageStats that contains the named resource. If the second parameter is
* set, creates the missing PackageStats along the way.
* Returns the deepest JavaPackageStats that contains the named resource. If the second parameter is
* set, creates the missing JavaPackageStats along the way.
*
* @param qname The qualified name of the resource
* @param createIfNotFound If set to true, the hierarch is created if non existent
*
* @return The deepest package that contains this resource. Can only return null if createIfNotFound is unset
*/
private PackageStats getSubPackage(QualifiedName qname, boolean createIfNotFound) {
private JavaPackageStats getSubPackage(QualifiedName qname, boolean createIfNotFound) {
if (qname.getPackages() == null) {
return this; // the toplevel
}
String[] packagePath = qname.getPackages();
PackageStats next = this;
JavaPackageStats next = this;
for (int i = 0; i < packagePath.length && next != null; i++) {
if (createIfNotFound && next.subPackages.get(packagePath[i]) == null) {
next.subPackages.put(packagePath[i], new PackageStats());
next.subPackages.put(packagePath[i], new JavaPackageStats());
}
next = next.subPackages.get(packagePath[i]);
@ -141,7 +141,7 @@ public final class PackageStats {
* @return True if the signature of the field is covered by the mask
*/
public boolean hasMatchingSig(QualifiedName qname, String fieldName, FieldSigMask sigMask) {
ClassStats clazz = getClassStats(qname, false);
JavaClassStats clazz = getClassStats(qname, false);
return clazz != null && clazz.hasMatchingSig(fieldName, sigMask);
}
@ -159,7 +159,7 @@ public final class PackageStats {
*/
/* default */ double compute(MetricKey<ASTAnyTypeDeclaration> key, ASTAnyTypeDeclaration node, boolean force,
MetricVersion version) {
ClassStats container = getClassStats(node.getQualifiedName(), false);
JavaClassStats container = getClassStats(node.getQualifiedName(), false);
return container == null ? Double.NaN
: container.compute(key, node, force, version);
@ -179,7 +179,7 @@ public final class PackageStats {
/* default */ double compute(MetricKey<ASTMethodOrConstructorDeclaration> key, ASTMethodOrConstructorDeclaration node,
boolean force, MetricVersion version) {
QualifiedName qname = node.getQualifiedName();
ClassStats container = getClassStats(qname, false);
JavaClassStats container = getClassStats(qname, false);
return container == null ? Double.NaN
: container.compute(key, node, qname.getOperation(), force, version);
@ -199,7 +199,7 @@ public final class PackageStats {
*/
/* default */ double computeWithResultOption(MetricKey<ASTMethodOrConstructorDeclaration> key, ASTAnyTypeDeclaration node,
boolean force, MetricVersion version, ResultOption option) {
ClassStats container = getClassStats(node.getQualifiedName(), false);
JavaClassStats container = getClassStats(node.getQualifiedName(), false);
return container == null ? Double.NaN
: container.computeWithResultOption(key, node, force, version, option);

View File

@ -2,16 +2,17 @@
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.oom.api;
package net.sourceforge.pmd.lang.java.metrics.api;
import net.sourceforge.pmd.lang.java.ast.ASTAnyTypeDeclaration;
import net.sourceforge.pmd.lang.metrics.api.Metric;
/**
* Metric that can be computed on a class node.
*
* @author Clément Fournier
*/
public interface ClassMetric extends Metric<ASTAnyTypeDeclaration> {
public interface JavaClassMetric extends Metric<ASTAnyTypeDeclaration> {
}

View File

@ -2,24 +2,26 @@
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.oom.api;
package net.sourceforge.pmd.lang.java.metrics.api;
import net.sourceforge.pmd.lang.java.ast.ASTAnyTypeDeclaration;
import net.sourceforge.pmd.lang.java.oom.metrics.AtfdMetric.AtfdClassMetric;
import net.sourceforge.pmd.lang.java.oom.metrics.CycloMetric.CycloClassMetric;
import net.sourceforge.pmd.lang.java.oom.metrics.LocMetric.LocClassMetric;
import net.sourceforge.pmd.lang.java.oom.metrics.NcssMetric.NcssClassMetric;
import net.sourceforge.pmd.lang.java.oom.metrics.WmcMetric;
import net.sourceforge.pmd.lang.java.metrics.metrics.AtfdMetric.AtfdClassMetric;
import net.sourceforge.pmd.lang.java.metrics.metrics.CycloMetric.CycloClassMetric;
import net.sourceforge.pmd.lang.java.metrics.metrics.LocMetric.LocClassMetric;
import net.sourceforge.pmd.lang.java.metrics.metrics.NcssMetric.NcssClassMetric;
import net.sourceforge.pmd.lang.java.metrics.metrics.WmcMetric;
import net.sourceforge.pmd.lang.metrics.api.Metric;
import net.sourceforge.pmd.lang.metrics.api.MetricKey;
/**
* Keys identifying standard class metrics.
*/
public enum ClassMetricKey implements MetricKey<ASTAnyTypeDeclaration> {
public enum JavaClassMetricKey implements MetricKey<ASTAnyTypeDeclaration> {
/**
* Access to Foreign Data.
*
* @see net.sourceforge.pmd.lang.java.oom.metrics.AtfdMetric
* @see net.sourceforge.pmd.lang.java.metrics.metrics.AtfdMetric
*/
ATFD(new AtfdClassMetric()),
@ -33,34 +35,34 @@ public enum ClassMetricKey implements MetricKey<ASTAnyTypeDeclaration> {
/**
* Cyclomatic complexity.
*
* @see net.sourceforge.pmd.lang.java.oom.metrics.CycloMetric
* @see net.sourceforge.pmd.lang.java.metrics.metrics.CycloMetric
*/
CYCLO(new CycloClassMetric()),
/**
* Non Commenting Source Statements.
*
* @see net.sourceforge.pmd.lang.java.oom.metrics.NcssMetric
* @see net.sourceforge.pmd.lang.java.metrics.metrics.NcssMetric
*/
NCSS(new NcssClassMetric()),
/**
* Lines of Code.
*
* @see net.sourceforge.pmd.lang.java.oom.metrics.LocMetric
* @see net.sourceforge.pmd.lang.java.metrics.metrics.LocMetric
*/
LOC(new LocClassMetric());
private final ClassMetric calculator;
private final JavaClassMetric calculator;
ClassMetricKey(ClassMetric m) {
JavaClassMetricKey(JavaClassMetric m) {
calculator = m;
}
@Override
public ClassMetric getCalculator() {
public JavaClassMetric getCalculator() {
return calculator;
}

View File

@ -2,16 +2,17 @@
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.oom.api;
package net.sourceforge.pmd.lang.java.metrics.api;
import net.sourceforge.pmd.lang.java.ast.ASTMethodOrConstructorDeclaration;
import net.sourceforge.pmd.lang.metrics.api.Metric;
/**
* Metric that can be computed on an operation.
*
* @author Clément Fournier
*/
public interface OperationMetric extends Metric<ASTMethodOrConstructorDeclaration> {
public interface JavaOperationMetric extends Metric<ASTMethodOrConstructorDeclaration> {
}

View File

@ -2,57 +2,59 @@
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.oom.api;
package net.sourceforge.pmd.lang.java.metrics.api;
import net.sourceforge.pmd.lang.java.ast.ASTMethodOrConstructorDeclaration;
import net.sourceforge.pmd.lang.java.oom.metrics.AtfdMetric.AtfdOperationMetric;
import net.sourceforge.pmd.lang.java.oom.metrics.CycloMetric.CycloOperationMetric;
import net.sourceforge.pmd.lang.java.oom.metrics.LocMetric.LocOperationMetric;
import net.sourceforge.pmd.lang.java.oom.metrics.NcssMetric.NcssOperationMetric;
import net.sourceforge.pmd.lang.java.metrics.metrics.AtfdMetric.AtfdOperationMetric;
import net.sourceforge.pmd.lang.java.metrics.metrics.CycloMetric.CycloOperationMetric;
import net.sourceforge.pmd.lang.java.metrics.metrics.LocMetric.LocOperationMetric;
import net.sourceforge.pmd.lang.java.metrics.metrics.NcssMetric.NcssOperationMetric;
import net.sourceforge.pmd.lang.metrics.api.Metric;
import net.sourceforge.pmd.lang.metrics.api.MetricKey;
/**
* Keys identifying standard operation metrics.
*/
public enum OperationMetricKey implements MetricKey<ASTMethodOrConstructorDeclaration> {
public enum JavaOperationMetricKey implements MetricKey<ASTMethodOrConstructorDeclaration> {
/**
* Access to Foreign Data.
*
* @see net.sourceforge.pmd.lang.java.oom.metrics.AtfdMetric
* @see net.sourceforge.pmd.lang.java.metrics.metrics.AtfdMetric
*/
ATFD(new AtfdOperationMetric()),
/**
* Cyclomatic complexity.
*
* @see net.sourceforge.pmd.lang.java.oom.metrics.CycloMetric
* @see net.sourceforge.pmd.lang.java.metrics.metrics.CycloMetric
*/
CYCLO(new CycloOperationMetric()),
/**
* Non Commenting Source Statements.
*
* @see net.sourceforge.pmd.lang.java.oom.metrics.NcssMetric
* @see net.sourceforge.pmd.lang.java.metrics.metrics.NcssMetric
*/
NCSS(new NcssOperationMetric()),
/**
* Lines of Code.
*
* @see net.sourceforge.pmd.lang.java.oom.metrics.LocMetric
* @see net.sourceforge.pmd.lang.java.metrics.metrics.LocMetric
*/
LOC(new LocOperationMetric());
private final OperationMetric calculator;
private final JavaOperationMetric calculator;
OperationMetricKey(OperationMetric m) {
JavaOperationMetricKey(JavaOperationMetric m) {
calculator = m;
}
@Override
public OperationMetric getCalculator() {
public JavaOperationMetric getCalculator() {
return calculator;
}

View File

@ -2,19 +2,19 @@
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.oom.metrics;
package net.sourceforge.pmd.lang.java.metrics.metrics;
import net.sourceforge.pmd.lang.java.ast.ASTAnyTypeDeclaration;
import net.sourceforge.pmd.lang.java.ast.ASTAnyTypeDeclaration.TypeKind;
import net.sourceforge.pmd.lang.java.oom.AbstractMetric;
import net.sourceforge.pmd.lang.java.oom.api.ClassMetric;
import net.sourceforge.pmd.lang.java.metrics.AbstractJavaMetric;
import net.sourceforge.pmd.lang.java.metrics.api.JavaClassMetric;
/**
* Base class for class metrics.
*
* @author Clément Fournier
*/
public abstract class AbstractClassMetric extends AbstractMetric<ASTAnyTypeDeclaration> implements ClassMetric {
public abstract class AbstractJavaClassMetric extends AbstractJavaMetric<ASTAnyTypeDeclaration> implements JavaClassMetric {
/**

View File

@ -2,19 +2,19 @@
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.oom.metrics;
package net.sourceforge.pmd.lang.java.metrics.metrics;
import net.sourceforge.pmd.lang.java.ast.ASTMethodOrConstructorDeclaration;
import net.sourceforge.pmd.lang.java.oom.AbstractMetric;
import net.sourceforge.pmd.lang.java.oom.api.OperationMetric;
import net.sourceforge.pmd.lang.java.metrics.AbstractJavaMetric;
import net.sourceforge.pmd.lang.java.metrics.api.JavaOperationMetric;
/**
* Base class for operation metrics.
*
* @author Clément Fournier
*/
public abstract class AbstractOperationMetric extends AbstractMetric<ASTMethodOrConstructorDeclaration>
implements OperationMetric {
public abstract class AbstractJavaOperationMetric extends AbstractJavaMetric<ASTMethodOrConstructorDeclaration>
implements JavaOperationMetric {
/**
* Returns true if the metric can be computed on this operation. By default, abstract operations are filtered out.

View File

@ -2,17 +2,17 @@
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.oom.metrics;
package net.sourceforge.pmd.lang.java.metrics.metrics;
import java.util.List;
import net.sourceforge.pmd.lang.java.ast.ASTAnyTypeDeclaration;
import net.sourceforge.pmd.lang.java.ast.ASTMethodOrConstructorDeclaration;
import net.sourceforge.pmd.lang.java.ast.QualifiedName;
import net.sourceforge.pmd.lang.java.oom.api.MetricVersion;
import net.sourceforge.pmd.lang.java.oom.signature.OperationSigMask;
import net.sourceforge.pmd.lang.java.oom.signature.OperationSignature.Role;
import net.sourceforge.pmd.lang.java.oom.signature.Signature.Visibility;
import net.sourceforge.pmd.lang.metrics.api.MetricVersion;
import net.sourceforge.pmd.lang.java.metrics.signature.OperationSigMask;
import net.sourceforge.pmd.lang.java.metrics.signature.OperationSignature.Role;
import net.sourceforge.pmd.lang.java.metrics.signature.Signature.Visibility;
/**
* Access to Foreign Data. Quantifies the number of foreign fields accessed directly or via accessors.
@ -22,7 +22,7 @@ import net.sourceforge.pmd.lang.java.oom.signature.Signature.Visibility;
public final class AtfdMetric {
public static final class AtfdOperationMetric extends AbstractOperationMetric {
public static final class AtfdOperationMetric extends AbstractJavaOperationMetric {
@Override // TODO:cf
public double computeFor(ASTMethodOrConstructorDeclaration node, MetricVersion version) {
@ -43,7 +43,7 @@ public final class AtfdMetric {
}
}
public static final class AtfdClassMetric extends AbstractClassMetric {
public static final class AtfdClassMetric extends AbstractJavaClassMetric {
@Override
public double computeFor(ASTAnyTypeDeclaration node, MetricVersion version) {

View File

@ -2,19 +2,19 @@
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.oom.metrics;
package net.sourceforge.pmd.lang.java.metrics.metrics;
import org.apache.commons.lang3.mutable.MutableInt;
import net.sourceforge.pmd.lang.java.ast.ASTAnyTypeDeclaration;
import net.sourceforge.pmd.lang.java.ast.ASTMethodOrConstructorDeclaration;
import net.sourceforge.pmd.lang.java.ast.JavaParserVisitor;
import net.sourceforge.pmd.lang.java.oom.Metrics;
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.oom.metrics.visitors.CycloPathUnawareOperationVisitor;
import net.sourceforge.pmd.lang.java.oom.metrics.visitors.StandardCycloVisitor;
import net.sourceforge.pmd.lang.java.metrics.JavaMetrics;
import net.sourceforge.pmd.lang.metrics.api.MetricVersion;
import net.sourceforge.pmd.lang.java.metrics.api.JavaOperationMetricKey;
import net.sourceforge.pmd.lang.metrics.api.ResultOption;
import net.sourceforge.pmd.lang.java.metrics.metrics.visitors.CycloPathUnawareOperationVisitor;
import net.sourceforge.pmd.lang.java.metrics.metrics.visitors.StandardCycloVisitor;
/**
* McCabe's Cyclomatic Complexity. Number of independent paths through a block of code [1, 2]. Formally, given that the
@ -57,7 +57,7 @@ public final class CycloMetric {
IGNORE_BOOLEAN_PATHS
}
public static final class CycloOperationMetric extends AbstractOperationMetric {
public static final class CycloOperationMetric extends AbstractJavaOperationMetric {
@Override
public double computeFor(ASTMethodOrConstructorDeclaration node, MetricVersion version) {
@ -71,11 +71,11 @@ public final class CycloMetric {
}
}
public static final class CycloClassMetric extends AbstractClassMetric {
public static final class CycloClassMetric extends AbstractJavaClassMetric {
@Override
public double computeFor(ASTAnyTypeDeclaration node, MetricVersion version) {
return 1 + Metrics.get(OperationMetricKey.CYCLO, node, version, ResultOption.AVERAGE);
return 1 + JavaMetrics.get(JavaOperationMetricKey.CYCLO, node, version, ResultOption.AVERAGE);
}
}
}

View File

@ -2,11 +2,11 @@
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.oom.metrics;
package net.sourceforge.pmd.lang.java.metrics.metrics;
import net.sourceforge.pmd.lang.java.ast.ASTAnyTypeDeclaration;
import net.sourceforge.pmd.lang.java.ast.ASTMethodOrConstructorDeclaration;
import net.sourceforge.pmd.lang.java.oom.api.MetricVersion;
import net.sourceforge.pmd.lang.metrics.api.MetricVersion;
/**
* Lines of Code. Equates the length in lines of code of the measured entity, counting everything including blank lines
@ -20,7 +20,7 @@ import net.sourceforge.pmd.lang.java.oom.api.MetricVersion;
public final class LocMetric {
public static final class LocOperationMetric extends AbstractOperationMetric {
public static final class LocOperationMetric extends AbstractJavaOperationMetric {
@Override
public boolean supports(ASTMethodOrConstructorDeclaration node) {
@ -34,7 +34,7 @@ public final class LocMetric {
}
}
public static final class LocClassMetric extends AbstractClassMetric {
public static final class LocClassMetric extends AbstractJavaClassMetric {
@Override
public boolean supports(ASTAnyTypeDeclaration node) {

View File

@ -2,16 +2,16 @@
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.oom.metrics;
package net.sourceforge.pmd.lang.java.metrics.metrics;
import org.apache.commons.lang3.mutable.MutableInt;
import net.sourceforge.pmd.lang.java.ast.ASTAnyTypeDeclaration;
import net.sourceforge.pmd.lang.java.ast.ASTMethodOrConstructorDeclaration;
import net.sourceforge.pmd.lang.java.ast.JavaParserVisitor;
import net.sourceforge.pmd.lang.java.oom.api.MetricVersion;
import net.sourceforge.pmd.lang.java.oom.metrics.visitors.DefaultNcssVisitor;
import net.sourceforge.pmd.lang.java.oom.metrics.visitors.JavaNcssVisitor;
import net.sourceforge.pmd.lang.metrics.api.MetricVersion;
import net.sourceforge.pmd.lang.java.metrics.metrics.visitors.DefaultNcssVisitor;
import net.sourceforge.pmd.lang.java.metrics.metrics.visitors.JavaNcssVisitor;
/**
* Non Commenting Source Statements. Similar to LOC but only counts statements, which is roughly equivalent to counting
@ -36,7 +36,7 @@ public final class NcssMetric {
JAVANCSS
}
public static final class NcssClassMetric extends AbstractClassMetric {
public static final class NcssClassMetric extends AbstractJavaClassMetric {
@Override
public boolean supports(ASTAnyTypeDeclaration node) {
@ -56,7 +56,7 @@ public final class NcssMetric {
}
public static final class NcssOperationMetric extends AbstractOperationMetric {
public static final class NcssOperationMetric extends AbstractJavaOperationMetric {
@Override
public boolean supports(ASTMethodOrConstructorDeclaration node) {

View File

@ -2,14 +2,14 @@
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.oom.metrics;
package net.sourceforge.pmd.lang.java.metrics.metrics;
import net.sourceforge.pmd.lang.java.ast.ASTAnyTypeDeclaration;
import net.sourceforge.pmd.lang.java.oom.Metrics;
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.oom.metrics.CycloMetric.CycloVersion;
import net.sourceforge.pmd.lang.java.metrics.JavaMetrics;
import net.sourceforge.pmd.lang.metrics.api.MetricVersion;
import net.sourceforge.pmd.lang.java.metrics.api.JavaOperationMetricKey;
import net.sourceforge.pmd.lang.metrics.api.ResultOption;
import net.sourceforge.pmd.lang.java.metrics.metrics.CycloMetric.CycloVersion;
/**
* Weighed Method Count. It is the sum of the statical complexity of all operations of a class. We use
@ -23,11 +23,11 @@ import net.sourceforge.pmd.lang.java.oom.metrics.CycloMetric.CycloVersion;
* @author Clément Fournier
* @since June 2017
*/
public final class WmcMetric extends AbstractClassMetric {
public final class WmcMetric extends AbstractJavaClassMetric {
@Override
public double computeFor(ASTAnyTypeDeclaration node, MetricVersion version) {
return Metrics.get(OperationMetricKey.CYCLO, node, version, ResultOption.SUM);
return JavaMetrics.get(JavaOperationMetricKey.CYCLO, node, version, ResultOption.SUM);
}
}

View File

@ -2,7 +2,7 @@
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.oom.metrics.visitors;
package net.sourceforge.pmd.lang.java.metrics.metrics.visitors;
import org.apache.commons.lang3.mutable.MutableInt;
@ -23,7 +23,7 @@ import net.sourceforge.pmd.lang.java.ast.JavaParserVisitorAdapter;
* Visitor calculating cyclo without counting boolean operators.
*
* @author Clément Fournier
* @see net.sourceforge.pmd.lang.java.oom.metrics.CycloMetric
* @see net.sourceforge.pmd.lang.java.metrics.metrics.CycloMetric
*/
public class CycloPathUnawareOperationVisitor extends JavaParserVisitorAdapter {

View File

@ -2,7 +2,7 @@
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.oom.metrics.visitors;
package net.sourceforge.pmd.lang.java.metrics.metrics.visitors;
import org.apache.commons.lang3.mutable.MutableInt;
@ -38,7 +38,7 @@ import net.sourceforge.pmd.lang.java.ast.JavaParserVisitorAdapter;
* Default visitor for the calculation of Ncss.
*
* @author Clément Fournier
* @see net.sourceforge.pmd.lang.java.oom.metrics.NcssMetric
* @see net.sourceforge.pmd.lang.java.metrics.metrics.NcssMetric
*/
public class DefaultNcssVisitor extends JavaParserVisitorAdapter {

View File

@ -2,7 +2,7 @@
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.oom.metrics.visitors;
package net.sourceforge.pmd.lang.java.metrics.metrics.visitors;
import java.util.List;
@ -17,7 +17,7 @@ import net.sourceforge.pmd.lang.java.ast.ASTPackageDeclaration;
* JavaNcss compliant visitor for the calculation of Ncss.
*
* @author Clément Fournier
* @see net.sourceforge.pmd.lang.java.oom.metrics.NcssMetric
* @see net.sourceforge.pmd.lang.java.metrics.metrics.NcssMetric
*/
public class JavaNcssVisitor extends DefaultNcssVisitor {

View File

@ -2,7 +2,7 @@
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.oom.metrics.visitors;
package net.sourceforge.pmd.lang.java.metrics.metrics.visitors;
import org.apache.commons.lang3.mutable.MutableInt;
@ -21,7 +21,7 @@ import net.sourceforge.pmd.lang.java.rule.codesize.NPathComplexityRule;
* Calculates CYCLO following the standard definition.
*
* @author Clément Fournier
* @see net.sourceforge.pmd.lang.java.oom.metrics.CycloMetric
* @see net.sourceforge.pmd.lang.java.metrics.metrics.CycloMetric
*/
public class StandardCycloVisitor extends CycloPathUnawareOperationVisitor {

View File

@ -8,4 +8,4 @@
* @author Clément Fournier
*/
package net.sourceforge.pmd.lang.java.oom;
package net.sourceforge.pmd.lang.java.metrics;

View File

@ -2,7 +2,7 @@
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.oom.rule;
package net.sourceforge.pmd.lang.java.metrics.rule;
import java.util.HashMap;
import java.util.Map;
@ -11,13 +11,13 @@ import net.sourceforge.pmd.lang.java.ast.ASTAnyTypeDeclaration;
import net.sourceforge.pmd.lang.java.ast.ASTCompilationUnit;
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.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.oom.metrics.CycloMetric.CycloVersion;
import net.sourceforge.pmd.lang.java.metrics.JavaMetrics;
import net.sourceforge.pmd.lang.java.metrics.api.JavaClassMetricKey;
import net.sourceforge.pmd.lang.metrics.api.Metric.Version;
import net.sourceforge.pmd.lang.metrics.api.MetricVersion;
import net.sourceforge.pmd.lang.java.metrics.api.JavaOperationMetricKey;
import net.sourceforge.pmd.lang.metrics.api.ResultOption;
import net.sourceforge.pmd.lang.java.metrics.metrics.CycloMetric.CycloVersion;
import net.sourceforge.pmd.lang.java.rule.AbstractJavaMetricsRule;
import net.sourceforge.pmd.lang.rule.properties.BooleanProperty;
import net.sourceforge.pmd.lang.rule.properties.EnumeratedProperty;
@ -83,9 +83,9 @@ public class CyclomaticComplexityRule extends AbstractJavaMetricsRule {
super.visit(node, data);
if (reportClasses && ClassMetricKey.CYCLO.supports(node)) {
int classCyclo = (int) Metrics.get(ClassMetricKey.CYCLO, node, cycloVersion);
int classHighest = (int) Metrics.get(OperationMetricKey.CYCLO, node, cycloVersion, ResultOption.HIGHEST);
if (reportClasses && JavaClassMetricKey.CYCLO.supports(node)) {
int classCyclo = (int) JavaMetrics.get(JavaClassMetricKey.CYCLO, node, cycloVersion);
int classHighest = (int) JavaMetrics.get(JavaOperationMetricKey.CYCLO, node, cycloVersion, ResultOption.HIGHEST);
if (classCyclo >= reportLevel || classHighest >= reportLevel) {
String[] messageParams = {node.getTypeKind().name().toLowerCase(),
@ -103,7 +103,7 @@ public class CyclomaticComplexityRule extends AbstractJavaMetricsRule {
public final Object visit(ASTMethodOrConstructorDeclaration node, Object data) {
if (reportMethods) {
int cyclo = (int) Metrics.get(OperationMetricKey.CYCLO, node, cycloVersion);
int cyclo = (int) JavaMetrics.get(JavaOperationMetricKey.CYCLO, node, cycloVersion);
if (cyclo >= reportLevel) {
addViolation(data, node, new String[] {node instanceof ASTMethodDeclaration ? "method" : "constructor",
node.getQualifiedName().getOperation(), "" + cyclo, });

View File

@ -2,7 +2,7 @@
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.oom.rule;
package net.sourceforge.pmd.lang.java.metrics.rule;
import java.util.HashMap;
import java.util.Map;
@ -11,13 +11,13 @@ import net.sourceforge.pmd.lang.java.ast.ASTAnyTypeDeclaration;
import net.sourceforge.pmd.lang.java.ast.ASTCompilationUnit;
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.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.oom.metrics.NcssMetric.NcssVersion;
import net.sourceforge.pmd.lang.java.metrics.JavaMetrics;
import net.sourceforge.pmd.lang.java.metrics.api.JavaClassMetricKey;
import net.sourceforge.pmd.lang.metrics.api.Metric;
import net.sourceforge.pmd.lang.metrics.api.MetricVersion;
import net.sourceforge.pmd.lang.java.metrics.api.JavaOperationMetricKey;
import net.sourceforge.pmd.lang.metrics.api.ResultOption;
import net.sourceforge.pmd.lang.java.metrics.metrics.NcssMetric.NcssVersion;
import net.sourceforge.pmd.lang.java.rule.AbstractJavaMetricsRule;
import net.sourceforge.pmd.lang.rule.properties.EnumeratedProperty;
import net.sourceforge.pmd.lang.rule.properties.IntegerProperty;
@ -77,9 +77,9 @@ public final class NcssCountRule extends AbstractJavaMetricsRule {
super.visit(node, data);
if (ClassMetricKey.NCSS.supports(node)) {
int classSize = (int) Metrics.get(ClassMetricKey.NCSS, node, ncssVersion);
int classHighest = (int) Metrics.get(OperationMetricKey.NCSS, node, ncssVersion, ResultOption.HIGHEST);
if (JavaClassMetricKey.NCSS.supports(node)) {
int classSize = (int) JavaMetrics.get(JavaClassMetricKey.NCSS, node, ncssVersion);
int classHighest = (int) JavaMetrics.get(JavaOperationMetricKey.NCSS, node, ncssVersion, ResultOption.HIGHEST);
if (classSize >= classReportLevel) {
String[] messageParams = {node.getTypeKind().name().toLowerCase(),
@ -96,7 +96,7 @@ public final class NcssCountRule extends AbstractJavaMetricsRule {
@Override
public Object visit(ASTMethodOrConstructorDeclaration node, Object data) {
int methodSize = (int) Metrics.get(OperationMetricKey.NCSS, node, ncssVersion);
int methodSize = (int) JavaMetrics.get(JavaOperationMetricKey.NCSS, node, ncssVersion);
if (methodSize >= methodReportLevel) {
addViolation(data, node, new String[] {node instanceof ASTMethodDeclaration ? "method" : "constructor",
node.getQualifiedName().getOperation(), "" + methodSize, });

View File

@ -2,7 +2,7 @@
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.oom.signature;
package net.sourceforge.pmd.lang.java.metrics.signature;
/**
* Signature mask for a field. Newly created masks cover any field.

View File

@ -2,7 +2,7 @@
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.oom.signature;
package net.sourceforge.pmd.lang.java.metrics.signature;
import java.util.HashMap;
import java.util.Map;

View File

@ -2,7 +2,7 @@
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.oom.signature;
package net.sourceforge.pmd.lang.java.metrics.signature;
import java.util.Arrays;
import java.util.HashSet;

View File

@ -2,7 +2,7 @@
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.oom.signature;
package net.sourceforge.pmd.lang.java.metrics.signature;
import java.util.HashMap;
import java.util.List;

Some files were not shown because too many files have changed in this diff Show More