Clover coverage report - PMD - 3.9 Coverage timestamp: Tue Dec 19 2006 09:38:44 EST FRAMES NO FRAMES |
file stats: | LOC: | 36 |  | Methods: | 2
| NCLOC: | 21 |  | Classes: | 1
Source file | Conditionals | Statements | Methods | TOTAL
LooseCoupling.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.design;
5 |  |
6 |  | import net.sourceforge.pmd.AbstractRule;
7 |  | import net.sourceforge.pmd.ast.ASTClassOrInterfaceType;
8 |  | import net.sourceforge.pmd.ast.ASTFieldDeclaration;
9 |  | import net.sourceforge.pmd.ast.ASTFormalParameter;
10 |  | import net.sourceforge.pmd.ast.ASTResultType;
11 |  | import net.sourceforge.pmd.ast.Node;
12 |  | import net.sourceforge.pmd.util.CollectionUtil;
13 |  |
14 |  | public class LooseCoupling extends AbstractRule {
15 |  |
16 |  | // TODO - these should be brought in via external properties
17 |  | // private static final Set implClassNames = CollectionUtil.asSet( new Object[] {
18 |  | // "ArrayList", "HashSet", "HashMap", "LinkedHashMap", "LinkedHashSet", "TreeSet", "TreeMap", "Vector",
19 |  | // "java.util.ArrayList", "java.util.HashSet", "java.util.HashMap",
20 |  | // "java.util.LinkedHashMap", "java.util.LinkedHashSet", "java.util.TreeSet",
21 |  | // "java.util.TreeMap", "java.util.Vector"
22 |  | // });
23 |  |
24 | 3 | public LooseCoupling() {
25 | 3 | super();
26 |  | }
27 |  |
28 | 19 | public Object visit(ASTClassOrInterfaceType node, Object data) {
29 | 19 | Node parent = node.jjtGetParent().jjtGetParent().jjtGetParent();
30 | 19 | String typeName = node.getImage();
31 | 19 | if (CollectionUtil.isCollectionType(typeName, false) && (parent instanceof ASTFieldDeclaration || parent instanceof ASTFormalParameter || parent instanceof ASTResultType)) {
32 | 9 | addViolation(data, node, typeName);
33 |  | }
34 | 19 | return data;
35 |  | }
36 |  | }