Clover coverage report - PMD - 3.9 Coverage timestamp: Tue Dec 19 2006 09:38:44 EST FRAMES NO FRAMES |
file stats: | LOC: | 33 |  | Methods: | 2
| NCLOC: | 23 |  | 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.typeresolution.rules;
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 |  | /**
15 |  | * This is a separate rule, uses the type resolution facade
16 |  | */
17 |  | public class LooseCoupling extends AbstractRule {
18 |  |
19 | 2 | public LooseCoupling() {
20 | 2 | super();
21 |  | }
22 |  |
23 | 21 | public Object visit(ASTClassOrInterfaceType node, Object data) {
24 | 21 | Node parent = node.jjtGetParent().jjtGetParent().jjtGetParent();
25 | 21 | Class clazzType = node.getType();
26 | 21 | boolean isType = CollectionUtil.isCollectionType(clazzType, false);
27 | 21 | if (isType
28 |  | && (parent instanceof ASTFieldDeclaration || parent instanceof ASTFormalParameter || parent instanceof ASTResultType)) {
29 | 10 | addViolation(data, node, node.getImage());
30 |  | }
31 | 21 | return data;
32 |  | }
33 |  | }