Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for jakarta annotations to some checks #4782

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

gavlyukovskiy
Copy link

This MR adds jakarta annotations to the exempt lists.
We're currently migrating to Jakarta EE and we have to temporarily disable the rule or add exceptions in the code.

I didn't add new tests since it's just additional exempt annotations, but let me know if you want explicit tests.

@@ -168,6 +173,7 @@ public final class UnusedVariable extends BugChecker implements CompilationUnitT
"com.google.inject.multibindings.ProvidesIntoMap",
"com.google.inject.multibindings.ProvidesIntoSet",
"dagger.Provides",
"jakarta.inject.Inject",
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe also add this to UnnecessarilyVisible? (as hinted in the TODO comment above the constant)

Copy link
Author

@gavlyukovskiy gavlyukovskiy Jan 20, 2025

Choose a reason for hiding this comment

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

Added it there as well as to few other places I found. Thanks!
I've seen it also in InjectMatchers and other places that seem to relate to dependency injection / Guice. I didn't change that, because the logic is a bit more complicated, and since we're not using Guice, I'm not that confident in changing those. I'm not sure whether it even supports Jakarta EE already.

Copy link
Contributor

Choose a reason for hiding this comment

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

since we're not using Guice, I'm not that confident in changing those. I'm not sure whether it even supports Jakarta EE already.

FYI, it does!
https://github.com/google/guice/wiki/Guice600
https://github.com/google/guice/wiki/Guice700

Copy link
Author

@gavlyukovskiy gavlyukovskiy Jan 20, 2025

Choose a reason for hiding this comment

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

@tbroyer good to know :) But do you think we can have these checks merged separately from Guice or are they somehow intertwined?
I also noticed that sometimes there are suggested fixes to add javax.inject.Inject annotation, but it doesn't make sense if the project is already using jakarta / Guice 7 🤷 I think there could be some heuristic, but I'm not the best person to define that as we're using spring instead 😅

@gavlyukovskiy gavlyukovskiy changed the title Add jakarta annotations to UnusedVariable Add support for jakarta annotations to some checks Jan 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants