From 13eb4d1b08a8aec5b11f08ca9cae0792b2966c45 Mon Sep 17 00:00:00 2001 From: Michael Kemp Date: Fri, 20 Sep 2024 20:57:56 +0200 Subject: [PATCH] DCA11Y-1145: Comment reason for lowercasing the version --- .../maven/plugins/frontend/lib/NodeVersionParser.java | 11 +++++------ .../plugins/frontend/lib/NodeVersionDetectorTest.java | 1 - 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/frontend-plugin-core/src/main/java/com/github/eirslett/maven/plugins/frontend/lib/NodeVersionParser.java b/frontend-plugin-core/src/main/java/com/github/eirslett/maven/plugins/frontend/lib/NodeVersionParser.java index 135fa24c2..0069f7dd6 100644 --- a/frontend-plugin-core/src/main/java/com/github/eirslett/maven/plugins/frontend/lib/NodeVersionParser.java +++ b/frontend-plugin-core/src/main/java/com/github/eirslett/maven/plugins/frontend/lib/NodeVersionParser.java @@ -2,12 +2,12 @@ import com.google.common.annotations.VisibleForTesting; -import java.util.HashSet; import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; +import java.util.stream.Stream; -import static java.util.Arrays.asList; +import static java.util.stream.Collectors.toSet; public class NodeVersionParser { @@ -18,8 +18,7 @@ public class NodeVersionParser { static final Pattern VALID_VERSION_PATTERN = Pattern.compile("^v?\\d*\\.\\d*\\.\\d*$"); static { - UNUSUAL_VALID_VERSIONS = new HashSet<>(); - UNUSUAL_VALID_VERSIONS.addAll(asList( + UNUSUAL_VALID_VERSIONS = Stream.of( "latest", "latest-argon", "latest-boron", @@ -169,7 +168,7 @@ public class NodeVersionParser { "node-v0.6.7", "node-v0.6.8", "node-v0.6.9" - )); + ).collect(toSet()); } public static boolean validateVersion(String version) { @@ -182,7 +181,7 @@ public static boolean validateVersion(String version) { } public static String fixupMinorVersionErrors(String version) { - version = version.toLowerCase(); + version = version.toLowerCase(); // all the versions seem to be lower case if (UNUSUAL_VALID_VERSIONS.contains(version)) { return version; diff --git a/frontend-plugin-core/src/test/java/com/github/eirslett/maven/plugins/frontend/lib/NodeVersionDetectorTest.java b/frontend-plugin-core/src/test/java/com/github/eirslett/maven/plugins/frontend/lib/NodeVersionDetectorTest.java index 42fd9f591..ab2d298cf 100644 --- a/frontend-plugin-core/src/test/java/com/github/eirslett/maven/plugins/frontend/lib/NodeVersionDetectorTest.java +++ b/frontend-plugin-core/src/test/java/com/github/eirslett/maven/plugins/frontend/lib/NodeVersionDetectorTest.java @@ -5,7 +5,6 @@ import org.slf4j.Logger; import java.io.File; -import java.io.IOException; import java.net.URISyntaxException; import java.net.URL; import java.nio.file.Files;