Clover coverage report - PMD - 3.7
Coverage timestamp: Wed May 31 2006 09:25:59 EDT

file stats: | LOC: | 49 |  | Methods: | 3
| NCLOC: | 39 |  | Classes: | 1

Source file | Conditionals | Statements | Methods | TOTAL

UnusedFormalParameterRule.java

83.3%

100%

100%

93.3%

1 |  | /**
2 |  | * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3 |  | */
4 |  | package net.sourceforge.pmd.rules;
5 |  |
6 |  | import net.sourceforge.pmd.AbstractRule;
7 |  | import net.sourceforge.pmd.ast.ASTClassOrInterfaceDeclaration;
8 |  | import net.sourceforge.pmd.ast.ASTConstructorDeclaration;
9 |  | import net.sourceforge.pmd.ast.ASTMethodDeclaration;
10 |  | import net.sourceforge.pmd.ast.Node;
11 |  | import net.sourceforge.pmd.ast.SimpleNode;
12 |  | import net.sourceforge.pmd.symboltable.VariableNameDeclaration;
13 |  |
14 |  | import java.util.Iterator;
15 |  | import java.util.List;
16 |  | import java.util.Map;
17 |  |
18 |  | public class UnusedFormalParameterRule extends AbstractRule {
19 |  |
20 | 1 | public Object visit(ASTConstructorDeclaration node, Object data) {
21 | 1 | check(node, data);
22 | 1 | return data;
23 |  | }
24 |  |
25 | 9 | public Object visit(ASTMethodDeclaration node, Object data) {
26 | 9 | if (!node.isPrivate() && !hasProperty("checkall")) {
27 | 5 | return data;
28 |  | }
29 | 4 | if (!node.isNative()) {
30 | 4 | check(node, data);
31 |  | }
32 | 4 | return data;
33 |  | }
34 |  |
35 | 5 | private void check(SimpleNode node, Object data) {
36 | 5 | Node parent = node.jjtGetParent().jjtGetParent().jjtGetParent();
37 | 5 | if (parent instanceof ASTClassOrInterfaceDeclaration && !((ASTClassOrInterfaceDeclaration) parent).isInterface()) {
38 | 5 | Map vars = node.getScope().getVariableDeclarations();
39 | 5 | for (Iterator i = vars.keySet().iterator(); i.hasNext();) {
40 | 5 | VariableNameDeclaration nameDecl = (VariableNameDeclaration) i.next();
41 | 5 | if (!((List) vars.get(nameDecl)).isEmpty()) {
42 | 2 | continue;
43 |  | }
44 | 3 | addViolation(data, node, new Object[]{node instanceof ASTMethodDeclaration ? "method" : "constructor", nameDecl.getImage()});
45 |  | }
46 |  | }
47 |  | }
48 |  |
49 |  | }