psiroky commented on code in PR #205:
URL: https://github.com/apache/maven-enforcer/pull/205#discussion_r1057921554
##########
maven-enforcer-plugin/src/main/java/org/apache/maven/plugins/enforcer/EnforceMojo.java:
##########
@@ -242,22 +253,59 @@ public void execute() throws MojoExecutionException {
// CHECKSTYLE_ON: LineLength
}
- private EnforcerRule[] createRulesFromCommandLineOptions() throws
MojoExecutionException {
- EnforcerRule[] rules = new EnforcerRule[commandLineRules.length];
- for (int i = 0; i < commandLineRules.length; i++) {
- String rule = commandLineRules[i];
- if (!rule.contains(".")) {
- rule = getClass().getPackage().getName() + "." +
Character.toUpperCase(rule.charAt(0))
- + rule.substring(1);
- }
+ private EnforcerRule[] determineRulesToExecute() throws
MojoExecutionException {
+ if (isNullOrEmpty(commandLineRules) &&
isNullOrEmpty(commandLineRulesToSkip)) {
+ return this.rules;
+ }
+ List<EnforcerRule> includedRules;
+ if (commandLineRules != null && commandLineRules.length > 0) {
+ includedRules = new ArrayList<>();
+ for (String commandLineRule : commandLineRules) {
+ String rule = commandLineRule;
+ if (!rule.contains(".")) {
+ rule = ruleNameToFullyQualifiedClassName(rule);
+ }
- try {
- rules[i] = (EnforcerRule) Class.forName(rule).newInstance();
Review Comment:
I am wondering if this is correct. If there is a specific configuration for
any of the rules coming from e.g. `pom.xml`, this would effectively replace it
with the default since we are instantiating new instance here.
Should we maybe check this specific rule is in the `rules` field and if so
then just re-use it?
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]