private void flaggAllAsNew(final List<Item> newFindings) { for (Item item : newFindings) { if (item.getSeverity().getPenalty() > 0 && item.getSeverity() != Severity.COVERAGE) { flagAsNew(item); } } }
private void addAsOld(List<Item> newFindings, Item item) { if (item.getSeverity().getPenalty() > 0 && item.getSeverity() != Severity.COVERAGE) { item.setSeverity(Severity.OK); item.unsetNew(); item.setOld(true); newFindings.add(item); } }
private void filterLowSeverity(final List<Item> newFindings) { final Iterator<Item> i = newFindings.iterator(); while (i.hasNext()) { final Item item = i.next(); if (item.getSeverity().getPenalty() == 0 || item.getSeverity() == Severity.COVERAGE) { i.remove(); } } }
private void filterFullMatches(final List<Item> newFindings, final List<Item> oldFindings) { // Filter 100% matches: final Iterator<Item> newIterator = newFindings.iterator(); while (newIterator.hasNext()) { final Item newItem = newIterator.next(); final Iterator<Item> oldIterator = oldFindings.iterator(); while (oldIterator.hasNext()) { final Item oldItem = oldIterator.next(); if (isSameFinding(newItem, oldItem)) { newItem.setSince(oldItem.getSince()); newIterator.remove(); oldIterator.remove(); break; } } } }
private void filterPartialMatches(final List<Item> newFindings, final List<Item> oldFindings) { // Filter matches that 'moved' within the file. // There is for sure a better algorithm possible.. final Iterator<Item> newIterator = newFindings.iterator(); while (newIterator.hasNext()) { final Item newItem = newIterator.next(); final Iterator<Item> oldIterator = oldFindings.iterator(); while (oldIterator.hasNext()) { final Item oldItem = oldIterator.next(); if (isPartialSameFinding(newItem, oldItem)) { newItem.setSince(oldItem.getSince()); newIterator.remove(); oldIterator.remove(); break; } } } }
private void flagAsNew(Item item) { item.unsetOld(); item.setNew(true); item.setSince(mReportDate); }
private boolean isPartialSameFinding(Item newItem, Item oldItem) { final boolean result; if (oldItem.getFindingType().equals(newItem.getFindingType())) { if (oldItem.getOrigin().equals(Origin.CPD)) { // Fuzzy compare CPD Findings // see also http://www.jcoderz.org/fawkez/ticket/71 // The or is by intention due to resistant findings // reported as new frequently. result = oldItem.getLine() == newItem.getLine() || oldItem .getMessage() .regionMatches(0, newItem.getMessage(), 0, CPD_UNIQUE_STRING_LENGTH); } else { result = oldItem.getMessage().equals(newItem.getMessage()) && oldItem.getCounter() <= newItem.getCounter(); } } else { result = false; } return result; }
/* private */ static boolean isSameFinding(Item newItem, Item oldItem) { final boolean result; if (oldItem.getFindingType().equals(newItem.getFindingType())) { if (oldItem.getOrigin().equals(Origin.CPD)) { // Fuzzy compare CPD Findings // see also http://www.jcoderz.org/fawkez/ticket/71 result = oldItem.getLine() == newItem.getLine() && oldItem .getMessage() .regionMatches(0, newItem.getMessage(), 0, CPD_UNIQUE_STRING_LENGTH); } else { result = oldItem.getLine() == newItem.getLine() && oldItem.getColumn() == newItem.getColumn() && oldItem.getMessage().equals(newItem.getMessage()) && oldItem.getCounter() <= newItem.getCounter(); } } else { result = false; } return result; }