1 |
| package net.sourceforge.pmd.rules.codesize; |
2 |
| |
3 |
| import java.util.Iterator; |
4 |
| import java.util.Set; |
5 |
| |
6 |
| import net.sourceforge.pmd.RuleContext; |
7 |
| import net.sourceforge.pmd.ast.ASTConstructorDeclaration; |
8 |
| import net.sourceforge.pmd.ast.ASTExplicitConstructorInvocation; |
9 |
| import net.sourceforge.pmd.stat.DataPoint; |
10 |
| import net.sourceforge.pmd.util.NumericConstants; |
11 |
| |
12 |
| |
13 |
| |
14 |
| |
15 |
| |
16 |
| |
17 |
| public class NcssConstructorCount extends AbstractNcssCount { |
18 |
| |
19 |
| |
20 |
| |
21 |
| |
22 |
13
| public NcssConstructorCount() {
|
23 |
13
| super( ASTConstructorDeclaration.class );
|
24 |
| } |
25 |
| |
26 |
0
| public Object visit(ASTExplicitConstructorInvocation node, Object data) {
|
27 |
0
| return NumericConstants.ONE;
|
28 |
| } |
29 |
| |
30 |
4
| protected void makeViolations(RuleContext ctx, Set p) {
|
31 |
4
| Iterator points = p.iterator();
|
32 |
4
| while ( points.hasNext() ) {
|
33 |
1
| DataPoint point = (DataPoint) points.next();
|
34 |
| |
35 |
1
| addViolation(
|
36 |
| ctx, |
37 |
| point.getNode(), |
38 |
| new String[] { |
39 |
| String.valueOf( ( (ASTConstructorDeclaration) point.getNode() ).getParameterCount() ), |
40 |
| String.valueOf( (int) point.getScore() ) } ); |
41 |
| } |
42 |
| } |
43 |
| } |