From 7ab23ab0a54a6391f4c6bb37733fe10fc9e33a3f Mon Sep 17 00:00:00 2001 From: ramverma Date: Fri, 27 Jul 2018 10:40:01 +0100 Subject: Fixing sonar bugs in apex-pdp Sonar was complaining about direct comparision of double values. Changed the comparision to Double.compare(d1,d2). Change-Id: I3821924e606180626434d5bc41e29b9a8451a9b2 Issue-ID: POLICY-861 Signed-off-by: ramverma --- .../java/AnomalyDetectionPolicy_Decide_TaskSelectionLogic.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'examples/examples-adaptive/src') diff --git a/examples/examples-adaptive/src/main/java/org/onap/policy/apex/examples/adaptive/model/java/AnomalyDetectionPolicy_Decide_TaskSelectionLogic.java b/examples/examples-adaptive/src/main/java/org/onap/policy/apex/examples/adaptive/model/java/AnomalyDetectionPolicy_Decide_TaskSelectionLogic.java index a0b2a8f40..a044ad14b 100644 --- a/examples/examples-adaptive/src/main/java/org/onap/policy/apex/examples/adaptive/model/java/AnomalyDetectionPolicy_Decide_TaskSelectionLogic.java +++ b/examples/examples-adaptive/src/main/java/org/onap/policy/apex/examples/adaptive/model/java/AnomalyDetectionPolicy_Decide_TaskSelectionLogic.java @@ -230,7 +230,7 @@ public class AnomalyDetectionPolicy_Decide_TaskSelectionLogic { while (pValue < significanceLevel) { // takes approx 20% of method time // the score value as the anomaly probability final double score = (significanceLevel - pValue) / significanceLevel; - if (v == currentV) { + if (Double.compare(v, currentV) == 0) { return score; } // do the critical check again for the left values @@ -326,7 +326,7 @@ public class AnomalyDetectionPolicy_Decide_TaskSelectionLogic { */ private static Double[] removevalue(final Double[] lValues, final double v) { for (int i = 0; i < lValues.length; i++) { - if (lValues[i] == v) { + if (Double.compare(lValues[i], v) == 0) { final Double[] ret = new Double[lValues.length - 1]; System.arraycopy(lValues, 0, ret, 0, i); System.arraycopy(lValues, i + 1, ret, i, lValues.length - i - 1); @@ -389,7 +389,7 @@ public class AnomalyDetectionPolicy_Decide_TaskSelectionLogic { private static boolean isAllEqual(final List lValues) { final double first = lValues.get(0); for (final Double d : lValues) { - if (d != first) { + if (Double.compare(d, first) != 0) { return false; } } @@ -405,7 +405,7 @@ public class AnomalyDetectionPolicy_Decide_TaskSelectionLogic { private static boolean isAllEqual(final Double[] lValues) { final double first = lValues[0]; for (final Double d : lValues) { - if (d != first) { + if (Double.compare(d, first) != 0) { return false; } } -- cgit 1.2.3-korg