Skip to content

Conversation

Pankraz76
Copy link

@Pankraz76 Pankraz76 commented Aug 6, 2025

PoC for:

[WARNING] Changes have been made to guava-gwt/src-super/com/google/common/cache/super/com/google/common/cache/LocalCache.java by:
[WARNING]     org.openrewrite.staticanalysis.MissingOverrideAnnotation
[WARNING] Please review and commit the results.
[WARNING] Estimate time saved: 2h 30m
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for Guava Maven Parent 999.0.0-HEAD-jre-SNAPSHOT:
[INFO] 
[INFO] Guava Maven Parent ................................. SUCCESS [  0.270 s]
[INFO] Guava: Google Core Libraries for Java .............. SUCCESS [  1.327 s]
[INFO] Guava BOM .......................................... SUCCESS [  0.028 s]
[INFO] Guava Testing Library .............................. SUCCESS [  0.289 s]
[INFO] Guava Unit Tests ................................... SUCCESS [  0.143 s]
[INFO] Guava GWT compatible libs .......................... SUCCESS [ 43.500 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  45.870 s
[INFO] Finished at: 2025-08-06T11:50:37+02:00
[INFO] ------------------------------------------------------------------------

Copy link

google-cla bot commented Aug 6, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@Pankraz76 Pankraz76 force-pushed the rewrite branch 3 times, most recently from 8fd8cf4 to f3fb364 Compare August 6, 2025 10:04
@Pankraz76 Pankraz76 changed the title PoC: Add rewrite support for errorprone.refasterrules PoC: Add rewrite support Aug 6, 2025
@Pankraz76 Pankraz76 marked this pull request as ready for review August 6, 2025 10:04
copybara-service bot pushed a commit that referenced this pull request Aug 6, 2025
…rts.

From #7916 / #7917

RELNOTES=n/a
PiperOrigin-RevId: 791689276
copybara-service bot pushed a commit that referenced this pull request Aug 6, 2025
…rts.

From #7916 / #7917

RELNOTES=n/a
PiperOrigin-RevId: 791773570
@Pankraz76 Pankraz76 changed the title PoC: Add rewrite support Add rewrite support for staticanalysis.RemoveUnused and OrderPomElements Aug 7, 2025
@Pankraz76 Pankraz76 changed the title Add rewrite support for staticanalysis.RemoveUnused and OrderPomElements Add rewrite support for staticanalysis.RemoveUnused and maven.BestPractices Aug 7, 2025
@Pankraz76
Copy link
Author

BUILD SUCCESS

@cpovirk
Copy link
Member

cpovirk commented Aug 8, 2025

Thanks. I'm probably not going to try to figure out what it takes to integrate things fully, but I will try to eventually have a look at the pom.xml changes to see if there's enough benefit there to change my mind.

@Pankraz76
Copy link
Author

Thanks for the response.

integrate things fully

You mean the actual runtime?

To make this opt in and still last, we could simply disable by default the execution via switch rewrite.skip=true.


Just discovered you are (of course) a committer to error-prone as well, so im wondering why are you hesistating?
Im sure you have good intend and reasoning to do so.

Despite the large time consumption, its generally nice to fixes instead of dealing with them bugs manually, right?

@Pankraz76
Copy link
Author

Pankraz76 commented Aug 9, 2025

Hi,

might consider these changes suggested by error.prone. Then talk about possible CI integration depending on the actual time spend. Just a few minuets might be accepbtable as positive tradeoff for the flaws/issues being fixed.

Thanks.

@cpovirk
Copy link
Member

cpovirk commented Aug 11, 2025

There are a lot of changes in this and your other PR, and I would like to manage to spend a bunch of time to think them all through and offer a good response. Unfortunately, I have other responsibilities that I'm falling down on, so I'm trying to focus my Guava time more on changes that are user-facing. So I'll speak a little more generally.

Guava has been, in our experience, a worst-case scenario for static analysis:

  • It's a highly tested codebase with relatively few bugs. (To be completely clear, it has a handful of significant, known bugs, but they are things like subtle concurrency issues that aren't typically caught by static analysis.) This means that the suspicious-looking patterns that survive are frequently the edge cases in which those patterns are actually correct.
  • It has a lot of older code. This means that it may follow practices of an earlier era. Modernizations to that can be welcome, but full modernization is a big project that is not necessarily worth the effort, even with significant automation.
  • Some known problems can't be fixed for API-compatibility reasons.
  • Guava supports a variety of environments (e.g., Java 8, Android, GWT, J2CL, J2ObjC), so it can't use all the libraries that you'd hope for. Even beyond that, it's just used widely in general, so there's an unusually high chance that a "safe" change will cause trouble for someone (example).

So, even as someone who loves static analysis, I am ambivalent about it for Guava. We do occasionally get nice improvements out of it, but when I fix static-analysis warnings, it's usually "so that those warnings will stop getting in our way," not "so that the code gets better." For Error Prone,that's been a long, ongoing process, one that I'm still not sure justifies the time spent (even, again, when much of the process is automated).

Given that, I expect for additional static analysis for Guava to often feel more like a source of interruptions than like a source of improvements that end up justifying the costs. That says less about the static analysis than it does about Guava. (Certainly OpenRewrite has a better reputation than a variety of other static analyzers that I've seen run on Guava over the years, and the results so far have looked better.)

I am likely to still pull some changes out of the PRs (like those for imports, @Override annotations, and the now-useless test.add.args property that you've mentioned). But I don't expect to turn on further static analysis for the project. If there are specific changes you'd like to see enough to go to further effort, I'd suggest trying separate PRs. I want to make clear now that there's still a decent chance that we'll turn down or indefinitely postpone any of them (for the reasons already discussed or because they cause merge conflicts with our slightly different internal copy of Guava or because there are different viewpoints on specific best practices).B ut if there are specific changes that you believe strongly in but that don't catch my eye, that would be the way to go.

@cpovirk cpovirk added P2 and removed P3 no SLO labels Aug 11, 2025
@cpovirk cpovirk self-assigned this Aug 11, 2025
@Pankraz76 Pankraz76 changed the title Add rewrite support for staticanalysis.RemoveUnused and maven.BestPractices Add staticanalysis.UnnecessaryParentheses Aug 11, 2025
@Pankraz76
Copy link
Author

scope adjusted to UnnecessaryParentheses

copybara-service bot pushed a commit that referenced this pull request Aug 11, 2025
It stopped being set in cl/711476575, and it was somewhat incorrect even before that.

Closes #7916

RELNOTES=n/a
PiperOrigin-RevId: 793645777
@cpovirk cpovirk reopened this Aug 11, 2025
@cpovirk
Copy link
Member

cpovirk commented Aug 11, 2025

I am confusing myself a bit with the PRs here, sorry. I think I did end up merging the pom.xml changes that I intended, and then I had closed this in favor of #7930 and any other future PRs that we try to push through. So maybe that did makes sense.

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.

2 participants