aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-batch/src
diff options
context:
space:
mode:
Diffstat (limited to 'sonar-batch/src')
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/index/MeasurePersister.java17
1 files 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<MeasureModel> getMeasuresToSave() {
List<MeasureModel> measures = Lists.newArrayList();