From b033efb7eaa75669c8ddd7f02b49490a6fc1bb0a Mon Sep 17 00:00:00 2001 From: depryf Date: Mon, 24 Jul 2023 15:40:15 -0400 Subject: [PATCH] Fixed sonarcloud warnings --- .../java/com/imsweb/seerutils/SeerMath.java | 3 +- .../java/com/imsweb/seerutils/SeerUtils.java | 67 ++++++++++--------- .../com/imsweb/seerutils/SeerUtilsTest.java | 15 ++--- 3 files changed, 46 insertions(+), 39 deletions(-) diff --git a/src/main/java/com/imsweb/seerutils/SeerMath.java b/src/main/java/com/imsweb/seerutils/SeerMath.java index 31f4e42..ce3ae18 100644 --- a/src/main/java/com/imsweb/seerutils/SeerMath.java +++ b/src/main/java/com/imsweb/seerutils/SeerMath.java @@ -14,7 +14,7 @@ public final class SeerMath { /** - * No instanciation for this class! + * No instantiation for this class! *

* Created on Feb 9, 2011 by depryf */ @@ -112,6 +112,7 @@ public static RegressionResult calculateRegressionResult(List * Created on Aug 21, 2011 by Fabian * @author Fabian */ + @SuppressWarnings("unused") public static class RegressionResult { /** diff --git a/src/main/java/com/imsweb/seerutils/SeerUtils.java b/src/main/java/com/imsweb/seerutils/SeerUtils.java index f225402..ff79359 100644 --- a/src/main/java/com/imsweb/seerutils/SeerUtils.java +++ b/src/main/java/com/imsweb/seerutils/SeerUtils.java @@ -15,6 +15,7 @@ import java.io.Writer; import java.net.URL; import java.nio.charset.StandardCharsets; +import java.nio.file.Files; import java.text.DecimalFormat; import java.util.ArrayList; import java.util.Collections; @@ -35,14 +36,14 @@ /** * This class provides shared functionality that can be used by all the other modules in SEER*Utils. */ +@SuppressWarnings("unused") public final class SeerUtils { // cached pattern for the versions - private static final Pattern _VERSION_CLEANUP_PATTERN = Pattern.compile("^v|-(snapshot|beta)$"); private static final Pattern _VERSIONS_PATTERN = Pattern.compile("^\\d+(\\.\\d+){0,3}$"); /** - * Private constructor, no instanciation. + * Private constructor, no instantiation. *

* Created on Feb 7, 2011 by Fabian */ @@ -63,8 +64,14 @@ public static int compareSeerVersions(String version1, String version2) { if (version2 == null) return 1; - String v1 = _VERSION_CLEANUP_PATTERN.matcher(version1.toLowerCase()).replaceAll(""); - String v2 = _VERSION_CLEANUP_PATTERN.matcher(version2.toLowerCase()).replaceAll(""); + String v1 = version1.toLowerCase(); + if (v1.startsWith("v")) + v1 = v1.substring(1); + v1 = v1.replace("-snapshot", "").replace("-beta", ""); + String v2 = version2.toLowerCase(); + if (v2.startsWith("v")) + v2 = v2.substring(1); + v2 = v2.replace("-snapshot", "").replace("-beta", ""); if (!_VERSIONS_PATTERN.matcher(v1).matches()) throw new IllegalArgumentException("Invalid version format: " + v1); @@ -101,7 +108,7 @@ public static int compareSeerVersions(String version1, String version2) { /** * Returns true if the provided string contains only printable ASCII characters, false otherwise. *

- * See http://www.asciitable.com/ + * See http://www.asciitable.com/ *

* Considering byte values from -127 to 128, only the range 32-126 is considered printable ASCII with the following exceptions: *