01: package net.sourceforge.pmd.rules.codesize;
02:
03: import java.util.Set;
04:
05: import net.sourceforge.pmd.RuleContext;
06: import net.sourceforge.pmd.ast.ASTMethodDeclaration;
07: import net.sourceforge.pmd.stat.DataPoint;
08:
09: /**
10: * Non-commented source statement counter for methods.
11: *
12: * @author Jason Bennett
13: */
14: public class NcssMethodCount extends AbstractNcssCount {
15:
16: /**
17: * Count the size of all non-constructor methods.
18: */
19: public NcssMethodCount() {
20: super (ASTMethodDeclaration.class);
21: }
22:
23: public Object visit(ASTMethodDeclaration node, Object data) {
24: return super .visit(node, data);
25: }
26:
27: protected void makeViolations(RuleContext ctx, Set<DataPoint> p) {
28: for (DataPoint point : p) {
29: addViolation(ctx, point.getNode(), new String[] {
30: ((ASTMethodDeclaration) point.getNode())
31: .getMethodName(),
32: String.valueOf((int) point.getScore()) });
33: }
34: }
35:
36: }
|