View Javadoc

    1   package net.sourceforge.pmd.rules.codesize;
    2
    3   import java.util.Set;
    4
    5   import net.sourceforge.pmd.RuleContext;
    6   import net.sourceforge.pmd.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 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() ).getMethodName(),
    31            String.valueOf( (int) point.getScore() ) } );
    32      }
    33    }
    34
    35  }