Pankraz76 commented on code in PR #2349: URL: https://github.com/apache/maven/pull/2349#discussion_r2096344806
########## api/maven-api-core/src/main/java/org/apache/maven/api/JavaPathType.java: ########## @@ -263,7 +263,7 @@ final String[] format(String moduleName, Iterable<? extends Path> paths) { if (option == null) { throw new IllegalStateException("No option is associated to this path type."); } - String prefix = (moduleName == null) ? "" : (moduleName + '='); Review Comment: ### **Parentheses: Explicit Clarity vs. Unnecessary Overhead** Parentheses are useful for turning *implicit* assumptions into *explicit* guarantees. They enforce clarity, especially in complex logic, by making intent unambiguous. When the outcome is rigorously defined, reasoning about the code becomes easier. However, if the language’s behavior is already well-specified (e.g., operator precedence rules), redundant parentheses add *visual noise* and *cognitive overhead*. `Inconsistent` use—where some groupings are meaningful while others are arbitrary—creates a `misleading` pattern. Those extra characters (`(` and `)`) become syntactic bloat, making code harder to skim and implying intentional grouping where none exists. **Key Trade-off:** - **Explicit:** Essential for disambiguating non-obvious logic or overriding default precedence. - **Overhead:** Distracting when rules are universally known (e.g., `(a) + (b)` instead of `a + b`). The core challenge is balancing *intent* (highlighting critical logic) against *brevity* (avoiding clutter in trivial cases). ########## compat/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/ComparableVersion.java: ########## @@ -118,7 +118,7 @@ public boolean isNull() { @Override public int compareTo(Item item) { if (item == null) { - return (value == 0) ? 0 : 1; // 1.0 == 1, 1.1 > 1 + return value == 0 ? 0 : 1; // 1.0 == 1, 1.1 > 1 Review Comment: **What's the benefit of having parentheses here?** For some mathematical terms, parentheses are important and have logical implications. Thus, it can be misleading if parentheses are included without being necessary for an actual logical operation. This makes understanding the code much harder, as one must decipher the deeper reasoning behind them—if there even is any. For example, in math: - `1 + 1` is equivalent to `(1) + (1)` While technically the same, the unnecessary parentheses add visual noise, requiring extra effort to interpret and distracting from the core logic. The key issue is that if parentheses are used inconsistently or without clear intent, it becomes difficult to distinguish between meaningful logic and arbitrary formatting. ########## compat/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/MultipleArtifactsNotFoundException.java: ########## @@ -93,7 +93,7 @@ private static String constructMessage(List<Artifact> artifacts) { int counter = 0; for (Artifact artifact : artifacts) { - String message = (++counter) + ") " + artifact.getId(); + String message = ++counter + ") " + artifact.getId(); Review Comment: **What's the benefit of having parentheses here?** For some mathematical terms, parentheses are important and have logical implications. Thus, it can be misleading if parentheses are included without being necessary for an actual logical operation. This makes understanding the code much harder, as one must decipher the deeper reasoning behind them—if there even is any. For example, in math: - `1 + 1` is equivalent to `(1) + (1)` While technically the same, the unnecessary parentheses add visual noise, requiring extra effort to interpret and distracting from the core logic. The key issue is that if parentheses are used inconsistently or without clear intent, it becomes difficult to distinguish between meaningful logic and arbitrary formatting. -- 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-unsubscr...@maven.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org