forked from phoedos/pmd
replaced new Integers with constants
git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@4686 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
@ -21,6 +21,7 @@ import net.sourceforge.pmd.ast.ASTWhileStatement;
|
||||
import net.sourceforge.pmd.ast.SimpleJavaNode;
|
||||
import net.sourceforge.pmd.stat.DataPoint;
|
||||
import net.sourceforge.pmd.stat.StatisticalRule;
|
||||
import net.sourceforge.pmd.util.NumericConstants;
|
||||
|
||||
/**
|
||||
* Abstract superclass for NCSS counting methods. Counts tokens according to <a
|
||||
@ -111,7 +112,7 @@ public abstract class AbstractNcssCount extends StatisticalRule {
|
||||
}
|
||||
|
||||
public Object visit(ASTBreakStatement node, Object data) {
|
||||
return new Integer( 1 );
|
||||
return NumericConstants.ONE;
|
||||
}
|
||||
|
||||
public Object visit(ASTCatchStatement node, Object data) {
|
||||
@ -119,7 +120,7 @@ public abstract class AbstractNcssCount extends StatisticalRule {
|
||||
}
|
||||
|
||||
public Object visit(ASTContinueStatement node, Object data) {
|
||||
return new Integer( 1 );
|
||||
return NumericConstants.ONE;
|
||||
}
|
||||
|
||||
public Object visit(ASTFinallyStatement node, Object data) {
|
||||
@ -139,17 +140,17 @@ public abstract class AbstractNcssCount extends StatisticalRule {
|
||||
}
|
||||
|
||||
public Object visit(ASTThrowStatement node, Object data) {
|
||||
return new Integer( 1 );
|
||||
return NumericConstants.ONE;
|
||||
}
|
||||
|
||||
public Object visit(ASTStatementExpression node, Object data) {
|
||||
|
||||
// "For" update expressions do not count as separate lines of code
|
||||
if ( node.jjtGetParent() instanceof ASTStatementExpressionList ) {
|
||||
return new Integer( 0 );
|
||||
return NumericConstants.ZERO;
|
||||
}
|
||||
|
||||
return new Integer( 1 );
|
||||
return NumericConstants.ONE;
|
||||
}
|
||||
|
||||
public Object visit(ASTLabeledStatement node, Object data) {
|
||||
@ -160,7 +161,7 @@ public abstract class AbstractNcssCount extends StatisticalRule {
|
||||
|
||||
// "For" init declarations do not count as separate lines of code
|
||||
if ( node.jjtGetParent() instanceof ASTForInit ) {
|
||||
return new Integer( 0 );
|
||||
return NumericConstants.ZERO;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -7,6 +7,7 @@ import net.sourceforge.pmd.RuleContext;
|
||||
import net.sourceforge.pmd.ast.ASTConstructorDeclaration;
|
||||
import net.sourceforge.pmd.ast.ASTExplicitConstructorInvocation;
|
||||
import net.sourceforge.pmd.stat.DataPoint;
|
||||
import net.sourceforge.pmd.util.NumericConstants;
|
||||
|
||||
/**
|
||||
* Non-commented source statement counter for constructors.
|
||||
@ -23,7 +24,7 @@ public class NcssConstructorCount extends AbstractNcssCount {
|
||||
}
|
||||
|
||||
public Object visit(ASTExplicitConstructorInvocation node, Object data) {
|
||||
return new Integer( 1 );
|
||||
return NumericConstants.ONE;
|
||||
}
|
||||
|
||||
protected void makeViolations(RuleContext ctx, Set p) {
|
||||
|
@ -13,6 +13,7 @@ import net.sourceforge.pmd.ast.ASTInitializer;
|
||||
import net.sourceforge.pmd.ast.ASTMethodDeclaration;
|
||||
import net.sourceforge.pmd.ast.ASTTypeDeclaration;
|
||||
import net.sourceforge.pmd.stat.DataPoint;
|
||||
import net.sourceforge.pmd.util.NumericConstants;
|
||||
|
||||
/**
|
||||
* Non-commented source statement counter for type declarations.
|
||||
@ -43,7 +44,7 @@ public class NcssTypeCount extends AbstractNcssCount {
|
||||
}
|
||||
|
||||
public Object visit(ASTExplicitConstructorInvocation node, Object data) {
|
||||
return new Integer( 1 );
|
||||
return NumericConstants.ONE;
|
||||
}
|
||||
|
||||
public Object visit(ASTEnumDeclaration node, Object data) {
|
||||
@ -68,7 +69,7 @@ public class NcssTypeCount extends AbstractNcssCount {
|
||||
}
|
||||
|
||||
public Object visit(ASTFieldDeclaration node, Object data) {
|
||||
return new Integer( 1 );
|
||||
return NumericConstants.ONE;
|
||||
}
|
||||
|
||||
protected void makeViolations(RuleContext ctx, Set p) {
|
||||
|
Reference in New Issue
Block a user