Clover coverage report - PMD - 3.9 Coverage timestamp: Tue Dec 19 2006 09:38:44 EST FRAMES NO FRAMES |
file stats: | LOC: | 26 |  | Methods: | 2
| NCLOC: | 19 |  | Classes: | 1
Source file | Conditionals | Statements | Methods | TOTAL
AvoidFieldNameMatchingTypeName.java | 100% | 100% | 100% | 100% |

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.ASTFieldDeclaration;
9 |  |
10 |  | public class AvoidFieldNameMatchingTypeName extends AbstractRule {
11 |  |
12 | 7 | public Object visit(ASTClassOrInterfaceDeclaration node, Object data) {
13 | 7 | if (node.isInterface()) {
14 | 1 | return data;
15 |  | }
16 | 6 | return super.visit(node, data);
17 |  | }
18 |  |
19 | 4 | public Object visit(ASTFieldDeclaration node, Object data) {
20 | 4 | ASTClassOrInterfaceDeclaration cl = (ASTClassOrInterfaceDeclaration) node.getFirstParentOfType(ASTClassOrInterfaceDeclaration.class);
21 | 4 | if (cl != null && node.getVariableName().toLowerCase().equals(cl.getImage().toLowerCase())) {
22 | 3 | addViolation(data, node);
23 |  | }
24 | 4 | return data;
25 |  | }
26 |  | }