From 3f4129f964551e8886aac88f508f434b2b152a82 Mon Sep 17 00:00:00 2001 From: David Gageot Date: Tue, 17 Jul 2012 21:53:15 +0200 Subject: [PATCH] Remove violation --- .../org/sonar/batch/index/MeasurePersister.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) 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(); -- 2.39.5