aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>2015-06-23 13:17:08 +0200
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>2015-06-23 13:25:28 +0200
commit0199d646efb6260d2aa6fc8705d940a3ef89285c (patch)
treeeece25c8ca0fb3edf999681a3f75ef959bb06b67
parent34f120e8723a1746305f591b642a85e186b40602 (diff)
downloadsonarqube-0199d646efb6260d2aa6fc8705d940a3ef89285c.tar.gz
sonarqube-0199d646efb6260d2aa6fc8705d940a3ef89285c.zip
SONAR-6646 no_value measure can not be a best value optimized measure
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/measure/BestValueOptimization.java3
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/measure/BestValueOptimizationTest.java7
2 files changed, 9 insertions, 1 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/measure/BestValueOptimization.java b/server/sonar-server/src/main/java/org/sonar/server/computation/measure/BestValueOptimization.java
index c9786bbef99..d28a516cfa2 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/measure/BestValueOptimization.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/measure/BestValueOptimization.java
@@ -61,7 +61,8 @@ public class BestValueOptimization implements Predicate<Measure> {
&& measure.getData() == null
&& !measure.hasQualityGateStatus()
&& hasNoVariation(measure)
- && (measure.getValueType() == NO_VALUE || isBestValue(measure, metric.getBestValue()));
+ && measure.getValueType() != NO_VALUE
+ && isBestValue(measure, metric.getBestValue());
}
private static boolean hasNoVariation(Measure measure) {
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/measure/BestValueOptimizationTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/measure/BestValueOptimizationTest.java
index c2d02d91d03..e3fda46f280 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/measure/BestValueOptimizationTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/measure/BestValueOptimizationTest.java
@@ -164,6 +164,13 @@ public class BestValueOptimizationTest {
assertThat(underTest.apply(newMeasureBuilder().create(Measure.Level.OK))).isFalse();
}
+ @Test
+ public void apply_returns_false_when_type_is_NO_VALUE() {
+ Predicate<Measure> underTest = BestValueOptimization.from(createMetric(Metric.MetricType.STRING, 36.5d), FILE_COMPONENT);
+
+ assertThat(underTest.apply(newMeasureBuilder().createNoValue())).isFalse();
+ }
+
private static MetricImpl createMetric(Metric.MetricType metricType, double bestValue) {
return new MetricImpl(metricType.hashCode() + (int) bestValue, "key" + metricType + bestValue, "name" + metricType + bestValue, metricType, bestValue, true);
}