aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-batch/src
diff options
context:
space:
mode:
authorDavid Gageot <david@gageot.net>2012-07-17 21:53:15 +0200
committerDavid Gageot <david@gageot.net>2012-07-17 21:53:15 +0200
commit3f4129f964551e8886aac88f508f434b2b152a82 (patch)
treee1a5ae7729c0987569ae621208cf32d2c7b52556 /sonar-batch/src
parentae729f4a4ebad1a8c0261da4e08892a85227e5cd (diff)
downloadsonarqube-3f4129f964551e8886aac88f508f434b2b152a82.tar.gz
sonarqube-3f4129f964551e8886aac88f508f434b2b152a82.zip
Remove violation
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();