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