1 package net.sourceforge.pmd.rules.codesize; 2 3 import java.util.Iterator ; 4 import java.util.Set ; 5 6 import net.sourceforge.pmd.RuleContext; 7 import net.sourceforge.pmd.ast.ASTConstructorDeclaration; 8 import net.sourceforge.pmd.ast.ASTExplicitConstructorInvocation; 9 import net.sourceforge.pmd.stat.DataPoint; 10 import net.sourceforge.pmd.util.NumericConstants; 11 12 17 public class NcssConstructorCount extends AbstractNcssCount { 18 19 22 public NcssConstructorCount() { 23 super( ASTConstructorDeclaration.class ); 24 } 25 26 public Object visit(ASTExplicitConstructorInvocation node, Object data) { 27 return NumericConstants.ONE; 28 } 29 30 protected void makeViolations(RuleContext ctx, Set p) { 31 Iterator points = p.iterator(); 32 while ( points.hasNext() ) { 33 DataPoint point = (DataPoint) points.next(); 34 addViolation( 36 ctx, 37 point.getNode(), 38 new String [] { 39 String.valueOf( ( (ASTConstructorDeclaration) point.getNode() ).getParameterCount() ), 40 String.valueOf( (int) point.getScore() ) } ); 41 } 42 } 43 } 44 | Popular Tags |