View Javadoc

1   /**
2    * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3    */
4   package net.sourceforge.pmd.lang.java.rule.codesize;
5   
6   import net.sourceforge.pmd.lang.java.ast.ASTMethodDeclaration;
7   import net.sourceforge.pmd.stat.DataPoint;
8   
9   /**
10   * Non-commented source statement counter for methods.
11   * 
12   * @author Jason Bennett
13   */
14  public class NcssMethodCountRule extends AbstractNcssCountRule {
15  
16      /**
17       * Count the size of all non-constructor methods.
18       */
19      public NcssMethodCountRule() {
20          super(ASTMethodDeclaration.class);
21          setProperty(MINIMUM_DESCRIPTOR, 100d);
22      }
23  
24      @Override
25      public Object visit(ASTMethodDeclaration node, Object data) {
26          return super.visit(node, data);
27      }
28  
29      @Override
30      public Object[] getViolationParameters(DataPoint point) {
31          return new String[] { ((ASTMethodDeclaration) point.getNode()).getMethodName(),
32                  String.valueOf((int) point.getScore()) };
33      }
34  }