From: David Gageot Date: Tue, 17 Jul 2012 19:53:15 +0000 (+0200) Subject: Remove violation X-Git-Tag: 3.2~31 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=3f4129f964551e8886aac88f508f434b2b152a82;p=sonarqube.git Remove violation --- diff --git a/sonar-batch/src/main/java/org/sonar/batch/index/MeasurePersister.java b/sonar-batch/src/main/java/org/sonar/batch/index/MeasurePersister.java index 54da51497f0..6d68a0b6478 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/index/MeasurePersister.java +++ b/sonar-batch/src/main/java/org/sonar/batch/index/MeasurePersister.java @@ -109,14 +109,10 @@ public final class MeasurePersister { @VisibleForTesting static boolean isBestValueMeasure(Measure measure, Metric metric) { - return measure.getId() == null - && metric.isOptimizedBestValue() == Boolean.TRUE + return metric.isOptimizedBestValue() == Boolean.TRUE && metric.getBestValue() != null && (measure.getValue() == null || NumberUtils.compare(metric.getBestValue(), measure.getValue()) == 0) - && measure.getAlertStatus() == null - && measure.getDescription() == null - && measure.getTendency() == null - && measure.getUrl() == null + && allNull(measure.getId(), measure.getAlertStatus(), measure.getDescription(), measure.getTendency(), measure.getUrl()) && !measure.hasData() && isZeroVariation(measure.getVariation1()) && isZeroVariation(measure.getVariation2()) @@ -129,6 +125,15 @@ public final class MeasurePersister { return (variation == null) || NumberUtils.compare(variation.doubleValue(), 0.0) == 0; } + private static boolean allNull(Object... values) { + for (Object value : values) { + if (null != value) { + return false; + } + } + return true; + } + private List getMeasuresToSave() { List measures = Lists.newArrayList();