View Javadoc

    1   package net.sourceforge.pmd.lang.java.rule.codesize;
    2
    3   import net.sourceforge.pmd.lang.java.ast.ASTMethodDeclaration;
    4   import net.sourceforge.pmd.stat.DataPoint;
    5
    6   /**
    7    * Non-commented source statement counter for methods.
    8    *
    9    * @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  }