You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by el...@apache.org on 2025/06/29 13:09:16 UTC

(maven-enforcer) branch contains created (now e8a28ce)

This is an automated email from the ASF dual-hosted git repository.

elharo pushed a change to branch contains
in repository https://gitbox.apache.org/repos/asf/maven-enforcer.git


      at e8a28ce  remove unneeded contains check as add already does that

This branch includes the following new commits:

     new e8a28ce  remove unneeded contains check as add already does that

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(maven-enforcer) 01/01: remove unneeded contains check as add already does that

Posted by el...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

elharo pushed a commit to branch contains
in repository https://gitbox.apache.org/repos/asf/maven-enforcer.git

commit e8a28cec914f45870f4f9d686dd3c24957c1a1b5
Author: Elliotte Rusty Harold <el...@ibiblio.org>
AuthorDate: Sun Jun 29 09:09:03 2025 -0400

    remove unneeded contains check as add already does that
---
 .../maven/enforcer/rules/RequirePluginVersions.java     | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/enforcer-rules/src/main/java/org/apache/maven/enforcer/rules/RequirePluginVersions.java b/enforcer-rules/src/main/java/org/apache/maven/enforcer/rules/RequirePluginVersions.java
index 324749a..6dcd8b2 100644
--- a/enforcer-rules/src/main/java/org/apache/maven/enforcer/rules/RequirePluginVersions.java
+++ b/enforcer-rules/src/main/java/org/apache/maven/enforcer/rules/RequirePluginVersions.java
@@ -363,22 +363,19 @@ public final class RequirePluginVersions extends AbstractStandardEnforcerRule {
     /**
      * Add the additional plugins if they don't exist yet.
      *
-     * @param existing   the existing
-     * @param additional the additional
-     * @return the sets the
+     * @param existing   the existing plugins
+     * @param additional the additional plugins
+     * @return the additional and existing plugins
      * @throws EnforcerRuleError the enforcer error
      */
     public Set<Plugin> addAdditionalPlugins(Set<Plugin> existing, List<String> additional) throws EnforcerRuleError {
         if (additional != null) {
+            if (existing == null) {
+                existing = new HashSet<>();
+            }
             for (String pluginString : additional) {
                 Plugin plugin = parsePluginString(pluginString, "AdditionalPlugins");
-
-                if (existing == null) {
-                    existing = new HashSet<>();
-                    existing.add(plugin);
-                } else if (!existing.contains(plugin)) {
-                    existing.add(plugin);
-                }
+                existing.add(plugin);
             }
         }
         return existing;