diff options
author | Zipeng WU <zipeng.wu@sonarsource.com> | 2020-12-08 16:19:22 +0100 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2020-12-09 20:07:21 +0000 |
commit | 296343a51973cf51be21c66964aad2dce7fe7f1e (patch) | |
tree | 0677ae66ce919e8dda47f554d1775d1707ab9e59 /server | |
parent | 99afeb0ec5899418eec90c2370230d03855b86c1 (diff) | |
download | sonarqube-296343a51973cf51be21c66964aad2dce7fe7f1e.tar.gz sonarqube-296343a51973cf51be21c66964aad2dce7fe7f1e.zip |
fix floating point equality
Diffstat (limited to 'server')
4 files changed, 4 insertions, 4 deletions
diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/TrackerRawInputFactory.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/TrackerRawInputFactory.java index c0229977074..5a3a6872bcb 100644 --- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/TrackerRawInputFactory.java +++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/TrackerRawInputFactory.java @@ -180,7 +180,7 @@ public class TrackerRawInputFactory { if (reportIssue.getSeverity() != Severity.UNSET_SEVERITY) { issue.setSeverity(reportIssue.getSeverity().name()); } - if (reportIssue.getGap() != 0) { + if (Double.compare(reportIssue.getGap(), 0D) != 0) { issue.setGap(reportIssue.getGap()); } DbIssues.Locations.Builder dbLocationsBuilder = DbIssues.Locations.newBuilder(); diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/measure/LiveMeasureDtoToMeasure.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/measure/LiveMeasureDtoToMeasure.java index 0481d5a85e9..20e03b81675 100644 --- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/measure/LiveMeasureDtoToMeasure.java +++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/measure/LiveMeasureDtoToMeasure.java @@ -84,7 +84,7 @@ public class LiveMeasureDtoToMeasure { 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(LiveMeasureDto measureDto, @Nullable String data) { diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/measure/DebtRatingGrid.java b/server/sonar-server-common/src/main/java/org/sonar/server/measure/DebtRatingGrid.java index 222b60e0566..e8892cb9965 100644 --- a/server/sonar-server-common/src/main/java/org/sonar/server/measure/DebtRatingGrid.java +++ b/server/sonar-server-common/src/main/java/org/sonar/server/measure/DebtRatingGrid.java @@ -98,7 +98,7 @@ public class DebtRatingGrid { private Bounds(double lowerBound, double higherBound) { this.lowerBound = lowerBound; this.higherBound = higherBound; - this.isLowerBoundInclusive = lowerBound == 0; + this.isLowerBoundInclusive = Double.compare(lowerBound, 0D) == 0; } boolean match(double value) { diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/custom/ws/CustomMeasureJsonWriter.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/custom/ws/CustomMeasureJsonWriter.java index 7f3635d4b45..dc71e211e5f 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/custom/ws/CustomMeasureJsonWriter.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/custom/ws/CustomMeasureJsonWriter.java @@ -88,7 +88,7 @@ public class CustomMeasureJsonWriter { switch (metricType) { case BOOL: - return doubleValue == 1.0d ? "true" : "false"; + return Double.compare(doubleValue, 1.0D) == 0 ? "true" : "false"; case INT: case MILLISEC: return String.valueOf((int) doubleValue); |