]> source.dussan.org Git - sonarqube.git/commitdiff
Floating point numbers should not be tested for equality
authorPhilippe Perrin <philippe.perrin@sonarsource.com>
Fri, 11 Dec 2020 12:36:15 +0000 (13:36 +0100)
committersonartech <sonartech@sonarsource.com>
Mon, 14 Dec 2020 20:07:14 +0000 (20:07 +0000)
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/measure/MeasureDtoToMeasure.java

index a6f8bfa1323ebf04edbe4670b644ff9d8edc609e..3ee23a74b4f14cfa9abd0c14ecc7ad55ed93b44c 100644 (file)
@@ -84,7 +84,7 @@ public class MeasureDtoToMeasure {
     if (value == null) {
       return toNoValueMeasure(measureDto);
     }
-    return of(setCommonProperties(Measure.newMeasureBuilder(), measureDto).create(value == 1.0d, data));
+    return of(setCommonProperties(Measure.newMeasureBuilder(), measureDto).create(Double.compare(value, 1.0D) == 0, data));
   }
 
   private static Optional<Measure> toStringMeasure(MeasureDto measureDto, @Nullable String data) {