gnodet-bot commented on code in PR #13251:
URL: https://github.com/apache/maven/pull/13251#discussion_r4084543322
##########
impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvnup/goals/InferenceStrategy.java:
##########
@@ -159,6 +159,14 @@ public UpgradeResult doApply(UpgradeContext context,
Map<Path, Document> pomMap)
return new UpgradeResult(processedPoms, modifiedPoms, errorPoms);
}
+ private static void logInferenceResult(UpgradeContext context, String
description) {
+ if (context.isDryRun()) {
+ context.action(description + " would be applied");
+ } else {
+ context.success(description + " applied");
+ }
+ }
+
/**
* Applies limited parent-related inference optimizations for Maven 4.0.0+
models.
* Removes redundant child groupId/version that can be inferred from
parent.
Review Comment:
🔹 **Minor inconsistency: private `logInferenceResult` duplicates
`AbstractUpgradeStrategy.logChange`.**
`AbstractUpgradeStrategy` now has `logChange(context, description)` that
does exactly this — appends `" would be applied"` in dry-run, `" applied"`
otherwise. This private copy is redundant and introduces two code paths to
maintain.
Simplify by using the inherited helper:
```suggestion
private void logInferenceResult(UpgradeContext context, String
description) {
logChange(context, description);
}
```
Or better yet, remove `logInferenceResult` entirely and call
`logChange(context, description)` directly at the two call sites.
##########
impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvnup/goals/PluginUpgradeStrategy.java:
##########
@@ -277,7 +277,11 @@ public UpgradeResult doApply(UpgradeContext context,
Map<Path, Document> pomMap)
if (hasUpgrades) {
modifiedPoms.add(pomPath);
- context.success("Plugin upgrades applied");
+ if (context.isDryRun()) {
+ context.action("Plugin upgrades would be applied");
+ } else {
+ context.success("Plugin upgrades applied");
+ }
} else {
Review Comment:
🔹 **Minor inconsistency: inline `if/else` instead of `logChange()`.**
Every other strategy that was updated uses `logChange(context, "...")` from
`AbstractUpgradeStrategy`. This is the only one that keeps the inline pattern.
Use the helper for consistency:
```suggestion
if (hasUpgrades) {
modifiedPoms.add(pomPath);
logChange(context, "Plugin upgrades");
} else {
context.success("No plugin upgrades needed");
}
```
--
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]