Skip to content

Conversation

@Pankraz76
Copy link

@Pankraz76 Pankraz76 commented Aug 9, 2025

@Pankraz76 Pankraz76 marked this pull request as ready for review August 9, 2025 12:10
@Pankraz76
Copy link
Author

if you consider this let me know i need to revert the maven suggestions then if these could not be applied as well.

@Pankraz76 Pankraz76 force-pushed the refasterrules-rewrite branch from 6d65a5c to 1650af1 Compare August 9, 2025 12:37
@Pankraz76
Copy link
Author

[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for Guava Maven Parent 999.0.0-HEAD-jre-SNAPSHOT:
[INFO]
[INFO] Guava Maven Parent ................................. SUCCESS [ 0.114 s]
[INFO] Guava: Google Core Libraries for Java .............. SUCCESS [ 3.942 s]
[INFO] Guava BOM .......................................... SUCCESS [ 0.000 s]
[INFO] Guava Testing Library .............................. SUCCESS [01:40 min]
[INFO] Guava Unit Tests ................................... SUCCESS [07:29 min]
[INFO] Guava GWT compatible libs .......................... SUCCESS [ 6.779 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 09:20 min
[INFO] Finished at: 2025-08-09T14:33:11+02:00
[INFO] ------------------------------------------------------------------------

Copy link
Contributor

@Stephan202 Stephan202 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pom.xml changes seem unrelated to the application of the Refaster rules. Just some drive-by comments.

@Pankraz76
Copy link
Author

Pankraz76 commented Aug 10, 2025

The pom.xml changes seem unrelated

yes sorry, had dirty working copy including:

Will undo/assuming we gonna merge this dedicated:

@Pankraz76
Copy link
Author

of course this change should not be merges this way, considering simple replication of the UnnecessaryParentheses in dedicated branch, pulling this upfront.

@cpovirk
Copy link
Member

cpovirk commented Aug 11, 2025

I'd be happy to take the UnnecessaryParentheses changes if you're interested in creating a PR for just them. Some of the library changes look like things that we can't take for Android reasons, but length() == 0 -> isEmpty() would also be good, as would (I think) BigDecimal.valueOf.

@cpovirk cpovirk self-assigned this Aug 11, 2025
@Pankraz76 Pankraz76 changed the title Add errorprone.refasterrules Apply UnnecessaryParentheses Aug 11, 2025
@Pankraz76
Copy link
Author

Can rebase at any time, but due to the code density, conflicts are likely to arise soon. This is another good example why the plugin is in need to avoid spending time on issues like this. As it will be happen very soon after its fixed once but not forever. Making the whole effort most efficient if fixed for the future as well.

It's either a one-time effort to fix it now, or dealing with it constantly—which is inefficient until it's properly resolved once.

@cpovirk
Copy link
Member

cpovirk commented Aug 11, 2025

The best way to avoid spending time on this level of issue is often just to ignore it, sadly. I do think that the mass fix here (which looks to be more aggressive than Error Prone was in #7696 and #7771) is worthwhile, and I have sent it for review internally. Still, I think the cost of the first breakage from a build-time check here would outweigh the benefits of the backsliding protection, and I am happy to leave the checking off. If we want to clean up such errors in the future, I think the most efficient way to do that will be another mass run of the check.

@Pankraz76
Copy link
Author

sadly

What about tools like Checkstyle? Looking at large-scale projects like PMD and Checkstyle, they don’t have this issue. Maven also uses Spotless to automate these tedious tasks and discussions, no offence. Its about fixing issues like you mentioning not about ignoring stuff. Its not an improvement leaving the flaws open considering this hindering to an easy access of the code.

Investing all the time spent on manual formatting fixes would be better spent on a single commit with a plugin.

We’re past the era where formatting errors require:

  • Worst case: Being ignored
  • Bad case: Manual fixes
  • Best case: Automation via tools like Spotless

Major projects like Maven, Quarkus, and Spring all rely on automation—because at scale, there’s no other practical way.

@Pankraz76
Copy link
Author

This could be made simply by merging and activating the failOnDryRunResults param afterwards making the commit easy and reproducible for everyone.

@cpovirk
Copy link
Member

cpovirk commented Aug 11, 2025

There is a lot that can be said about both the importance of code simplifications/improvements and the way to make those improvements at the lowest cost (e.g., build errors/warnings vs. automated code-review comments vs. human action vs. periodic cleanups vs. presubmits). (I think that there may be a presentation of one perspective on this in https://storage.googleapis.com/gweb-research2023-media/pubtools/4365.pdf.) Our situation is more complicated still because our Maven build is sort of "secondary" in our normal workflow. Breakages that are delayed to that phase need to provide a lot of value before they pay off.

@cpovirk
Copy link
Member

cpovirk commented Aug 11, 2025

As I should probably have anticipated, and as I hinted at in #7934 (comment), there's some disagreement over the value of parentheses on ternary conditions. (Opinions range from "always" to "never," with space for intermediate options like "only if the conditional is 'complex' (e.g., foo == bar || foo instanceof Baz)" or "not if there's a lot of parenthesization already on the line.") It seems to fall into the range of "not controversial enough that we need to force a rule to prevent discussions but controversial enough that a rule would annoy people." I'm making an attempt to revert those changes and take what's left, but I may end up erring in one direction or the other.

@Pankraz76
Copy link
Author

As I should probably have anticipated, and as I hinted at in #7934 (comment), there's some disagreement over the value of parentheses on ternary conditions. (Opinions range from "always" to "never," with space for intermediate options like "only if the conditional is 'complex' (e.g., foo == bar || foo instanceof Baz)" or "not if there's a lot of parenthesization already on the line.") It seems to fall into the range of "not controversial enough that we need to force a rule to prevent discussions but controversial enough that a rule would annoy people." I'm making an attempt to revert those changes and take what's left, but I may end up erring in one direction or the other.

yes "unfortunately" thats true, theres always the need for some exception, using suppression serving both parties.

Having a little freedom, while not having to strive in chaos.

copybara-service bot pushed a commit that referenced this pull request Aug 11, 2025
And sneak in a few other simplifications, mostly to remove explicit type arguments.

Fixes #7930

RELNOTES=n/a
PiperOrigin-RevId: 793670129
@Pankraz76
Copy link
Author

Assuming something much broader like RemoveUnusedPrivateMethods is someone most ppl. would agree upon to avoid. Even tho still some like to preserve making software archeology.

@Pankraz76 Pankraz76 force-pushed the refasterrules-rewrite branch from 02bcc72 to 87719ee Compare August 11, 2025 19:26
@cpovirk
Copy link
Member

cpovirk commented Aug 11, 2025

I forgot to also post: A teammate referred me to https://google.github.io/styleguide/javaguide.html#s4.7-grouping-parentheses, which is the standard we're up against.

The Java changes in #7938 look good except for the ones that appear to be removing serialization methods that Java calls automatically.

@Pankraz76
Copy link
Author

serialization methods that Java calls automatically

Thanks very interesting. Need to ignore these, in the recipe, if this is actually true/good.

@Pankraz76
Copy link
Author

Pankraz76 commented Aug 12, 2025

but again this effort is considered waste, as its not done, it will happen again.

We should try to stop starting and start finishing. As this obsolete stuff will occur anytime again if there is no quality gate imposed. Currently its bug/issue/flaw eldorado. I have fixed bugs in maven due to this kind of issue, so please dont argue its not important.

@Pankraz76
Copy link
Author

Pankraz76 commented Aug 12, 2025

serialization methods that Java calls automatically

Thanks very interesting. Need to ignore these, in the recipe, if this is actually true/good.

Is this something real or just some random google stuff? @timtebeek

https://github.com/search?q=repo%3Agoogle%2Fguava%20writeReplace&type=code

Inconsistent again. Its private. Is it called via reflection then or how should this work in runtime ?

image

Not even the code format is working, its really sad to see this important project in such conditions.

image

@Pankraz76
Copy link
Author

@timtebeek
Copy link

serialization methods that Java calls automatically

Thanks very interesting. Need to ignore these, in the recipe, if this is actually true/good.

Is this something real or just some random google stuff? @timtebeek

This case was missed; fixed now and likely released later today: openrewrite/rewrite-static-analysis@976d366

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants