gnodet-bot commented on code in PR #12486:
URL: https://github.com/apache/maven/pull/12486#discussion_r4705492296
##########
api/maven-api-cli/src/main/java/org/apache/maven/api/cli/mvn/MavenOptions.java:
##########
@@ -102,6 +102,15 @@ public interface MavenOptions extends Options {
@Nonnull
Optional<Boolean> failFast();
+ /**
+ * Requests that Maven print the reactor build order and exit, without
executing the build.
+ *
+ * @return an {@link Optional} containing true if the reactor build order
should be printed
+ * and the build skipped, false if not, or empty if not specified.
Review Comment:
⚠️ **Misleading `@return` contract — `false` is unreachable**: The
implementation in `CommonsCliMavenOptions` can only return
`Optional.of(Boolean.TRUE)` or `Optional.empty()`. The `false if not` branch is
dead code that will never be observed by callers.
Suggestion: drop the `false` branch from the Javadoc to match the actual
contract:
```suggestion
* @return an {@link Optional} containing true if the reactor build
order should be printed
* and the build skipped, or empty if not specified.
```
##########
impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvn/CommonsCliMavenOptions.java:
##########
@@ -102,6 +102,14 @@ public Optional<Boolean> failFast() {
return Optional.empty();
}
+ @Override
+ public Optional<Boolean> printBuildOrder() {
+ if (commandLine.hasOption(CLIManager.PRINT_BUILD_ORDER)) {
+ return Optional.of(Boolean.TRUE);
+ }
+ return Optional.empty();
Review Comment:
⚠️ **`false` return case is unreachable**: The flag is a boolean presence
flag — if present on the command line it returns `Optional.of(true)`, otherwise
`Optional.empty()`. There is no code path that returns `Optional.of(false)`.
This matches the pattern of `failFast()` / `failAtEnd()` / `failNever()` — all
presence-only flags. The Javadoc `@return` in `MavenOptions.java` should be
updated to match.
--
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]