01 package net.sourceforge.pmd.lang.java.rule.codesize;
02
03 import net.sourceforge.pmd.lang.java.ast.ASTMethodDeclaration;
04 import net.sourceforge.pmd.stat.DataPoint;
05
06 /**
07 * Non-commented source statement counter for methods.
08 *
09 * @author Jason Bennett
10 */
11 public class NcssMethodCountRule extends AbstractNcssCountRule {
12
13 /**
14 * Count the size of all non-constructor methods.
15 */
16 public NcssMethodCountRule() {
17 super(ASTMethodDeclaration.class);
18 setProperty(MINIMUM_DESCRIPTOR, 100d);
19 }
20
21 @Override
22 public Object visit(ASTMethodDeclaration node, Object data) {
23 return super.visit(node, data);
24 }
25
26 @Override
27 public Object[] getViolationParameters(DataPoint point) {
28 return new String[] { ((ASTMethodDeclaration) point.getNode()).getMethodName(),
29 String.valueOf((int) point.getScore()) };
30 }
31 }
|