KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > pmd > rules > codesize > NcssMethodCount


1 package net.sourceforge.pmd.rules.codesize;
2
3 import java.util.Iterator JavaDoc;
4 import java.util.Set JavaDoc;
5
6 import net.sourceforge.pmd.RuleContext;
7 import net.sourceforge.pmd.ast.ASTMethodDeclaration;
8 import net.sourceforge.pmd.stat.DataPoint;
9
10 /**
11  * Non-commented source statement counter for methods.
12  *
13  * @author Jason Bennett
14  */

15 public class NcssMethodCount extends AbstractNcssCount {
16
17   /**
18    * Count the size of all non-constructor methods.
19    */

20   public NcssMethodCount() {
21     super( ASTMethodDeclaration.class );
22   }
23
24   public Object JavaDoc visit(ASTMethodDeclaration node, Object JavaDoc data) {
25     return super.visit( node, data );
26   }
27
28   protected void makeViolations(RuleContext ctx, Set JavaDoc p) {
29     Iterator JavaDoc points = p.iterator();
30     while ( points.hasNext() ) {
31       DataPoint point = (DataPoint) points.next();
32       addViolation( ctx, point.getNode(), new String JavaDoc[] {
33           ( (ASTMethodDeclaration) point.getNode() ).getMethodName(),
34           String.valueOf( (int) point.getScore() ) } );
35     }
36   }
37
38 }
39
Popular Tags