You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by GitBox <gi...@apache.org> on 2022/12/29 13:16:12 UTC

[GitHub] [maven-enforcer] slawekjaranowski commented on a diff in pull request #205: [MENFORCER-431] Introduce option to skip specific rules via custom property

slawekjaranowski commented on code in PR #205:
URL: https://github.com/apache/maven-enforcer/pull/205#discussion_r1058946939


##########
maven-enforcer-plugin/src/main/java/org/apache/maven/plugins/enforcer/EnforceMojo.java:
##########
@@ -282,6 +288,22 @@ private Optional<PlexusConfiguration> createRulesFromCommandLineOptions() {
         return Optional.of(configuration);
     }
 
+    /**
+     * Filter our (remove) rules that have been specifically skipped via additional configuration.
+     *
+     * @param allRules list of enforcer rules to go through and filter
+     *
+     * @return list of filtered rules
+     */
+    private List<EnforcerRuleDesc> filterOutSkippedRules(List<EnforcerRuleDesc> allRules) {
+        if (rulesToSkip == null || rulesToSkip.length == 0) {
+            return allRules;
+        }
+        return allRules.stream()
+                .filter(ruleDesc -> !ArrayUtils.contains(rulesToSkip, ruleDesc.getName()))

Review Comment:
   We can use `List<String>` as parameter type, then external library will be not needed 😄 
   There aare more parameter as arrays ... we can improve in next PR



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org