@Test public void testReferenceToConditionals() throws Exception { final Set<Violation> violations = new WhileLoopRules(toDocument("reference-to-conditionals.xml")) .doMeasuredAnalysis(); assertThat(violations).hasSize(0); }
@Override protected Set<Violation> doMeasuredAnalysis() throws JDOMException { final Set<Violation> violations = new HashSet<Violation>(); final List<Element> whileLoops = selectNodesByName("WHILE."); for (final Element whileLoop : whileLoops) { List<Attribute> nameAttributes = selectAttributes(whileLoop, "./*[1]/descendant-or-self::NAME/@text"); boolean found = false; for (Attribute nameAttribute : nameAttributes) { if (!selectNodes(whileLoop, "./COMMA. .isEmpty()) { found = true; break; } if (!selectNodes(whileLoop, "./COMMA. .isEmpty()) { found = true; break; } } if (!found) { violations.add(new InfiniteLoopViolation(getLineNumber(whileLoop))); } } return violations; }
WhileLoopRules extends TimedDelegate { @Override protected Set<Violation> doMeasuredAnalysis() throws JDOMException { final Set<Violation> violations = new HashSet<Violation>(); final List<Element> whileLoops = selectNodesByName("WHILE."); for (final Element whileLoop : whileLoops) { List<Attribute> nameAttributes = selectAttributes(whileLoop, "./*[1]/descendant-or-self::NAME/@text"); boolean found = false; for (Attribute nameAttribute : nameAttributes) { if (!selectNodes(whileLoop, "./COMMA. .isEmpty()) { found = true; break; } if (!selectNodes(whileLoop, "./COMMA. .isEmpty()) { found = true; break; } } if (!found) { violations.add(new InfiniteLoopViolation(getLineNumber(whileLoop))); } } return violations; } }
WhileLoopRules extends TimedDelegate { @Override protected Set<Violation> doMeasuredAnalysis() throws JDOMException { final Set<Violation> violations = new HashSet<Violation>(); final List<Element> whileLoops = selectNodesByName("WHILE."); for (final Element whileLoop : whileLoops) { List<Attribute> nameAttributes = selectAttributes(whileLoop, "./*[1]/descendant-or-self::NAME/@text"); boolean found = false; for (Attribute nameAttribute : nameAttributes) { if (!selectNodes(whileLoop, "./COMMA. .isEmpty()) { found = true; break; } if (!selectNodes(whileLoop, "./COMMA. .isEmpty()) { found = true; break; } } if (!found) { violations.add(new InfiniteLoopViolation(getLineNumber(whileLoop))); } } return violations; } WhileLoopRules(final Document document); }
WhileLoopRules extends TimedDelegate { @Override protected Set<Violation> doMeasuredAnalysis() throws JDOMException { final Set<Violation> violations = new HashSet<Violation>(); final List<Element> whileLoops = selectNodesByName("WHILE."); for (final Element whileLoop : whileLoops) { List<Attribute> nameAttributes = selectAttributes(whileLoop, "./*[1]/descendant-or-self::NAME/@text"); boolean found = false; for (Attribute nameAttribute : nameAttributes) { if (!selectNodes(whileLoop, "./COMMA. .isEmpty()) { found = true; break; } if (!selectNodes(whileLoop, "./COMMA. .isEmpty()) { found = true; break; } } if (!found) { violations.add(new InfiniteLoopViolation(getLineNumber(whileLoop))); } } return violations; } WhileLoopRules(final Document document); @Override Set<Violation> getCheckedViolations(); }
WhileLoopRules extends TimedDelegate { @Override protected Set<Violation> doMeasuredAnalysis() throws JDOMException { final Set<Violation> violations = new HashSet<Violation>(); final List<Element> whileLoops = selectNodesByName("WHILE."); for (final Element whileLoop : whileLoops) { List<Attribute> nameAttributes = selectAttributes(whileLoop, "./*[1]/descendant-or-self::NAME/@text"); boolean found = false; for (Attribute nameAttribute : nameAttributes) { if (!selectNodes(whileLoop, "./COMMA. .isEmpty()) { found = true; break; } if (!selectNodes(whileLoop, "./COMMA. .isEmpty()) { found = true; break; } } if (!found) { violations.add(new InfiniteLoopViolation(getLineNumber(whileLoop))); } } return violations; } WhileLoopRules(final Document document); @Override Set<Violation> getCheckedViolations();  }