Report implements Iterable<RuleViolation> { @Deprecated public Iterator<RuleViolation> treeIterator() { return violationTree.iterator(); }  static Report createReport(RuleContext ctx, String fileName); void suppress(Map<Integer, String> lines); @Deprecated Map<String, Integer> getCountSummary(); @Deprecated ReportTree getViolationTree(); @Deprecated Map<String, Integer> getSummary(); void addListener(ThreadSafeReportListener listener); @Deprecated List<SuppressedViolation> getSuppressedRuleViolations(); void addRuleViolation(RuleViolation violation); @Deprecated void addMetric(Metric metric); void addConfigError(ConfigurationError error); void addError(ProcessingError error); void merge(Report r); @Deprecated boolean hasMetrics(); @Deprecated Iterator<Metric> metrics(); @Deprecated boolean isEmpty(); @Deprecated boolean hasErrors(); @Deprecated boolean hasConfigErrors(); @Deprecated boolean treeIsEmpty(); @Deprecated Iterator<RuleViolation> treeIterator(); @Deprecated @Override Iterator<RuleViolation> iterator(); final List<SuppressedViolation> getSuppressedViolations(); final List<RuleViolation> getViolations(); final List<ProcessingError> getProcessingErrors(); final List<ConfigurationError> getConfigurationErrors(); @Deprecated Iterator<ProcessingError> errors(); @Deprecated Iterator<ConfigurationError> configErrors(); @Deprecated int treeSize(); @Deprecated int size(); @Deprecated void start(); @Deprecated void end(); @Deprecated long getElapsedTimeInMillis(); List<ThreadSafeReportListener> getListeners(); void addListeners(List<ThreadSafeReportListener> allListeners);  }
@Test public void testTreeIterator() { Report r = new Report(); RuleContext ctx = new RuleContext(); Rule rule = new MockRule("name", "desc", "msg", "rulesetname"); Node node1 = getNode(5, 5, true); r.addRuleViolation(new ParametricRuleViolation<>(rule, ctx, node1, rule.getMessage())); Node node2 = getNode(5, 6, true); r.addRuleViolation(new ParametricRuleViolation<>(rule, ctx, node2, rule.getMessage())); Iterator<RuleViolation> violations = r.iterator(); int violationCount = 0; while (violations.hasNext()) { violations.next(); violationCount++; } assertEquals(2, violationCount); Iterator<RuleViolation> treeIterator = r.treeIterator(); int treeCount = 0; while (treeIterator.hasNext()) { treeIterator.next(); treeCount++; } assertEquals(2, treeCount); }