This is an automated email from the ASF dual-hosted git repository.
elharo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-enforcer.git
The following commit(s) were added to refs/heads/master by this push:
new eefa06f remove unneeded contains check as add already does that (#896)
eefa06f is described below
commit eefa06f79fdb6712d4a32d8d5ebc905e98cc485c
Author: Elliotte Rusty Harold <[email protected]>
AuthorDate: Sun Jun 29 22:43:35 2025 +0000
remove unneeded contains check as add already does that (#896)
---
.../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;