1 4 package net.sourceforge.pmd.rules; 5 6 import net.sourceforge.pmd.ast.ASTCompilationUnit; 7 import net.sourceforge.pmd.ast.ASTFieldDeclaration; 8 import net.sourceforge.pmd.ast.ASTMethodDeclarator; 9 import net.sourceforge.pmd.ast.AccessNode; 10 import net.sourceforge.pmd.rules.design.ExcessiveNodeCountRule; 11 import net.sourceforge.pmd.util.NumericConstants; 12 13 27 public class ExcessivePublicCount extends ExcessiveNodeCountRule { 28 29 public ExcessivePublicCount() { 30 super(ASTCompilationUnit.class); 31 } 32 33 36 public Object visit(ASTMethodDeclarator node, Object data) { 37 return this.getTallyOnAccessType((AccessNode) node.jjtGetParent()); 38 } 39 40 44 public Object visit(ASTFieldDeclaration node, Object data) { 45 if (node.isFinal() && node.isStatic()) { 46 return NumericConstants.ZERO; 47 } 48 return this.getTallyOnAccessType(node); 49 } 50 51 57 private Integer getTallyOnAccessType(AccessNode node) { 58 if (node.isPublic()) { 59 return NumericConstants.ONE; 60 } 61 return NumericConstants.ZERO; 62 } 63 } 64 | Popular Tags |