Clover coverage report - PMD - 3.7 Coverage timestamp: Wed May 31 2006 09:25:59 EDT FRAMES NO FRAMES |
file stats: | LOC: | 81 |  | Methods: | 2
| NCLOC: | 52 |  | Classes: | 1
Source file | Conditionals | Statements | Methods | TOTAL
DaaRule.java | 0% | 0% | 0% | 0% |

1 |  | /*
2 |  | * Created on 20.07.2004
3 |  | */
4 |  | package net.sourceforge.pmd.dfa;
5 |  |
6 |  | import net.sourceforge.pmd.AbstractRule;
7 |  | import net.sourceforge.pmd.RuleContext;
8 |  | import net.sourceforge.pmd.ast.ASTMethodDeclaration;
9 |  | import net.sourceforge.pmd.dfa.pathfinder.CurrentPath;
10 |  | import net.sourceforge.pmd.dfa.pathfinder.DAAPathFinder;
11 |  | import net.sourceforge.pmd.dfa.pathfinder.Executable;
12 |  | import net.sourceforge.pmd.dfa.variableaccess.VariableAccess;
13 |  |
14 |  | import java.util.ArrayList;
15 |  | import java.util.Hashtable;
16 |  | import java.util.Iterator;
17 |  | import java.util.List;
18 |  |
19 |  | /**
20 |  | * @author raik
21 |  | * <p/>
22 |  | * Starts path search for each method and runs code if found.
23 |  | */
24 |  | public class DaaRule extends AbstractRule implements Executable {
25 |  |
26 |  | private RuleContext rc;
27 |  | private int counter;
28 |  | private static final int MAX_PATHS = 5000;
29 |  |
30 | 0 | public Object visit(ASTMethodDeclaration node, Object data) {
31 | 0 | this.rc = (RuleContext) data;
32 | 0 | counter = 0;
33 |  |
34 | 0 | IDataFlowNode n = (IDataFlowNode) node.getDataFlowNode().getFlow().get(0);
35 | 0 | System.out.println("In DaaRule, IDataFlowNode n = " + n);
36 |  |
37 | 0 | DAAPathFinder a = new DAAPathFinder(n, this);
38 | 0 | a.run();
39 |  |
40 | 0 | super.visit(node, data);
41 | 0 | return data;
42 |  | }
43 |  |
44 | 0 | public void execute(CurrentPath path) {
45 | 0 | Hashtable hash = new Hashtable();
46 | 0 | counter++;
47 | 0 | if (counter == 5000) {
48 | 0 | System.out.print("|");
49 | 0 | counter = 0;
50 |  | }
51 | 0 | for (Iterator d = path.iterator(); d.hasNext();) {
52 | 0 | IDataFlowNode inode = (IDataFlowNode) d.next();
53 | 0 | if (inode.getVariableAccess() != null) {
54 | 0 | for (int g = 0; g < inode.getVariableAccess().size(); g++) {
55 | 0 | VariableAccess va = (VariableAccess) inode.getVariableAccess().get(g);
56 |  |
57 | 0 | Object o = hash.get(va.getVariableName());
58 | 0 | if (o != null) {
59 | 0 | List array = (List) o;
60 | 0 | int last = ((Integer) array.get(0)).intValue();
61 |  | // TODO - at some point investigate and possibly reintroduce this line2 thing
62 |  | //int line2 = ((Integer) array.get(1)).intValue();
63 |  | /*
64 |  | if (va.accessTypeMatches(last) && va.isDefinition()) { // DD
65 |  | this.rc.getReport().addRuleViolation(createRuleViolation(rc, inode.getSimpleNode(), va.getVariableName(), "DD"));
66 |  | } else if (last == VariableAccess.UNDEFINITION && va.isReference()) { // UR
67 |  | this.rc.getReport().addRuleViolation(createRuleViolation(rc, inode.getSimpleNode(), va.getVariableName(), "UR"));
68 |  | } else if (last == VariableAccess.DEFINITION && va.isUndefinition()) { // DU
69 |  | this.rc.getReport().addRuleViolation(createRuleViolation(rc, inode.getSimpleNode(), va.getVariableName(), "DU"));
70 |  | }
71 |  | */
72 |  | }
73 | 0 | List array = new ArrayList();
74 | 0 | array.add(new Integer(va.getAccessType()));
75 | 0 | array.add(new Integer(inode.getLine()));
76 | 0 | hash.put(va.getVariableName(), array);
77 |  | }
78 |  | }
79 |  | }
80 |  | }
81 |  | }