use full name instead of abbreviation for classfanout & fix spelling
This commit is contained in:
@ -82,7 +82,7 @@ public enum JavaClassMetricKey implements MetricKey<ASTAnyTypeDeclaration> {
|
||||
*
|
||||
* @see ClassFanOutClassMetric
|
||||
*/
|
||||
CFO(new ClassFanOutClassMetric());
|
||||
CLASS_FAN_OUT(new ClassFanOutClassMetric());
|
||||
|
||||
|
||||
private final JavaClassMetric calculator;
|
||||
|
@ -9,7 +9,7 @@ import org.apache.commons.lang3.mutable.MutableInt;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTAnyTypeDeclaration;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceBodyDeclaration;
|
||||
import net.sourceforge.pmd.lang.java.ast.MethodLikeNode;
|
||||
import net.sourceforge.pmd.lang.java.metrics.impl.internal.CfoVisitor;
|
||||
import net.sourceforge.pmd.lang.java.metrics.impl.internal.ClassFanOutVisitor;
|
||||
import net.sourceforge.pmd.lang.metrics.MetricOption;
|
||||
import net.sourceforge.pmd.lang.metrics.MetricOptions;
|
||||
|
||||
@ -23,7 +23,7 @@ import net.sourceforge.pmd.lang.metrics.MetricOptions;
|
||||
public final class ClassFanOutMetric {
|
||||
|
||||
public enum ClassFanOutOption implements MetricOption {
|
||||
/** Weather to include Classes in the java.lang package. */
|
||||
/** Whether to include Classes in the java.lang package. */
|
||||
INCLUDE_JAVA_LANG("includeJavaLang");
|
||||
|
||||
private final String vName;
|
||||
@ -42,7 +42,7 @@ public final class ClassFanOutMetric {
|
||||
|
||||
@Override
|
||||
public double computeFor(ASTAnyTypeDeclaration node, MetricOptions options) {
|
||||
MutableInt cfo = (MutableInt) node.jjtAccept(new CfoVisitor(options, node), new MutableInt(0));
|
||||
MutableInt cfo = (MutableInt) node.jjtAccept(new ClassFanOutVisitor(options, node), new MutableInt(0));
|
||||
return (double) cfo.getValue();
|
||||
}
|
||||
}
|
||||
@ -60,9 +60,9 @@ public final class ClassFanOutMetric {
|
||||
// look at the parent to catch annotations
|
||||
if (node.jjtGetParent() instanceof ASTClassOrInterfaceBodyDeclaration) {
|
||||
ASTClassOrInterfaceBodyDeclaration parent = (ASTClassOrInterfaceBodyDeclaration) node.jjtGetParent();
|
||||
cfo = (MutableInt) parent.jjtAccept(new CfoVisitor(options, node), new MutableInt(0));
|
||||
cfo = (MutableInt) parent.jjtAccept(new ClassFanOutVisitor(options, node), new MutableInt(0));
|
||||
} else {
|
||||
cfo = (MutableInt) node.jjtAccept(new CfoVisitor(options, node), new MutableInt(0));
|
||||
cfo = (MutableInt) node.jjtAccept(new ClassFanOutVisitor(options, node), new MutableInt(0));
|
||||
}
|
||||
|
||||
return (double) cfo.getValue();
|
||||
|
@ -11,26 +11,26 @@ import org.apache.commons.lang3.mutable.MutableInt;
|
||||
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceType;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTName;
|
||||
import net.sourceforge.pmd.lang.java.ast.AbstractJavaTypeNode;
|
||||
import net.sourceforge.pmd.lang.java.ast.JavaNode;
|
||||
import net.sourceforge.pmd.lang.java.ast.JavaParserVisitorAdapter;
|
||||
import net.sourceforge.pmd.lang.java.ast.TypeNode;
|
||||
import net.sourceforge.pmd.lang.java.metrics.impl.ClassFanOutMetric.ClassFanOutOption;
|
||||
import net.sourceforge.pmd.lang.metrics.MetricOptions;
|
||||
|
||||
|
||||
/**
|
||||
* Visitor for the Cfo metric.
|
||||
* Visitor for the ClassFanOut metric.
|
||||
*
|
||||
* @author Andreas Pabst
|
||||
*/
|
||||
public class CfoVisitor extends JavaParserVisitorAdapter {
|
||||
public class ClassFanOutVisitor extends JavaParserVisitorAdapter {
|
||||
|
||||
private static final String JAVA_LANG_PACKAGE_NAME = "java.lang";
|
||||
protected Set<Class> classes = new HashSet<>();
|
||||
private final boolean includeJavaLang;
|
||||
|
||||
@SuppressWarnings("PMD.UnusedFormalParameter")
|
||||
public CfoVisitor(MetricOptions options, JavaNode topNode) {
|
||||
public ClassFanOutVisitor(MetricOptions options, JavaNode topNode) {
|
||||
includeJavaLang = options.getOptions().contains(ClassFanOutOption.INCLUDE_JAVA_LANG);
|
||||
// topNode is unused, but we'll need it if we want to discount lambdas
|
||||
// if we add it later, we break binary compatibility
|
||||
@ -48,7 +48,7 @@ public class CfoVisitor extends JavaParserVisitorAdapter {
|
||||
return super.visit(node, data);
|
||||
}
|
||||
|
||||
private void check(AbstractJavaTypeNode node, MutableInt counter) {
|
||||
private void check(TypeNode node, MutableInt counter) {
|
||||
if (!classes.contains(node.getType()) && shouldBeIncluded(node.getType())) {
|
||||
classes.add(node.getType());
|
||||
counter.increment();
|
@ -18,7 +18,7 @@ public class CfoTestRule extends AbstractMetricTestRule {
|
||||
|
||||
@Override
|
||||
protected JavaClassMetricKey getClassKey() {
|
||||
return JavaClassMetricKey.CFO;
|
||||
return JavaClassMetricKey.CLASS_FAN_OUT;
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user