From d2e50d6b560578dcc2edfe0a6aa78a6bd4f3cfdc Mon Sep 17 00:00:00 2001 From: Aliaksandr Pinchuk Date: Thu, 30 Jan 2025 20:17:43 +0100 Subject: [PATCH] Fix sonar issues to pass quality gate --- .../openapidiff/core/compare/ParametersDiff.java | 4 +++- .../core/model/schema/ChangedNumericRange.java | 9 +++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/core/src/main/java/org/openapitools/openapidiff/core/compare/ParametersDiff.java b/core/src/main/java/org/openapitools/openapidiff/core/compare/ParametersDiff.java index 352be4bf1..6de3b4c28 100644 --- a/core/src/main/java/org/openapitools/openapidiff/core/compare/ParametersDiff.java +++ b/core/src/main/java/org/openapitools/openapidiff/core/compare/ParametersDiff.java @@ -114,7 +114,9 @@ public boolean pathUnchangedParametersChanged( boolean samePathDifferentParameter = !newParameterRealized.equals(parameter); newParameterRealized.setName( newParameterName); // Important:: MUST Reset the name as this is not a copy - return samePathDifferentParameter; + if (samePathDifferentParameter) { + return true; + } } return false; } diff --git a/core/src/main/java/org/openapitools/openapidiff/core/model/schema/ChangedNumericRange.java b/core/src/main/java/org/openapitools/openapidiff/core/model/schema/ChangedNumericRange.java index cbb7b713d..151c12fb6 100644 --- a/core/src/main/java/org/openapitools/openapidiff/core/model/schema/ChangedNumericRange.java +++ b/core/src/main/java/org/openapitools/openapidiff/core/model/schema/ChangedNumericRange.java @@ -1,5 +1,6 @@ package org.openapitools.openapidiff.core.model.schema; +import static org.apache.commons.lang3.BooleanUtils.isTrue; import static org.openapitools.openapidiff.core.model.BackwardIncompatibleProp.REQUEST_NUMERIC_RANGE_DECREASED; import static org.openapitools.openapidiff.core.model.BackwardIncompatibleProp.RESPONSE_NUMERIC_RANGE_INCREASED; @@ -34,10 +35,10 @@ public DiffResult isChanged() { return DiffResult.COMPATIBLE; } - boolean exclusiveMaxOld = oldMaximumExclusiveValue != null && oldMaximumExclusiveValue; - boolean exclusiveMinOld = oldMinimumExclusiveValue != null && oldMinimumExclusiveValue; - boolean exclusiveMaxNew = newMaximumExclusiveValue != null && newMaximumExclusiveValue; - boolean exclusiveMinNew = newMinimumExclusiveValue != null && newMinimumExclusiveValue; + boolean exclusiveMaxOld = isTrue(oldMaximumExclusiveValue); + boolean exclusiveMinOld = isTrue(oldMinimumExclusiveValue); + boolean exclusiveMaxNew = isTrue(newMaximumExclusiveValue); + boolean exclusiveMinNew = isTrue(newMinimumExclusiveValue); int diffMax = compare(oldMaximumValue, newMaximumValue, false); int diffMin = compare(oldMinimumValue, newMinimumValue, true);