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

Flag unused Refaster template parameters #4060

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ public final class UnnecessarilyVisible extends BugChecker implements MethodTree
VisitorState.memoize(
s ->
Stream.of(
"com.google.errorprone.refaster.annotation.AfterTemplate",
"com.google.errorprone.refaster.annotation.BeforeTemplate",
"com.google.inject.Inject",
"com.google.inject.Provides",
"com.google.inject.multibindings.ProvidesIntoMap",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ public final class UnusedVariable extends BugChecker implements CompilationUnitT
// TODO(ghm): Find a sensible place to dedupe this with UnnecessarilyVisible.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If acceptable I don't mind also updating this list. Alternatively we can upstream our RefasterRuleModifiers check, which normalizes modifier usage by Refaster rule definitions more generally.

Copy link
Collaborator

Choose a reason for hiding this comment

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

If acceptable I don't mind also updating this list.

Thanks, updating the list until we get around to deduping them SGTM

Alternatively we can upstream our RefasterRuleModifiers check, which normalizes modifier usage by Refaster rule definitions more generally.

That also sounds good if you have time/interest, but it also doesn't need to block this PR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, updating the list until we get around to deduping them SGTM

Top; will do.

That also sounds good if you have time/interest, but it also doesn't need to block this PR

I'll make a note to consider this later then ✔️. (When we contributed #3813 and #2232 that caused some issues for downstream users due to a name collision (PicnicSupermarket/error-prone-support#622 and PicnicSupermarket/error-prone-support#686), so maybe this time I'll try to find an alternative name; hehe.)

private static final ImmutableSet<String> ANNOTATIONS_INDICATING_PARAMETERS_SHOULD_BE_CHECKED =
ImmutableSet.of(
"com.google.errorprone.refaster.annotation.AfterTemplate",
"com.google.errorprone.refaster.annotation.BeforeTemplate",
Comment on lines +152 to +153
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Of this list, currently there's only a test for javax.inject.Inject, so I didn't add any test cases for these new annotations, either. Let me know if I should. (I did test these changes against a collection of real Refaster templates.)

"com.google.inject.Inject",
"com.google.inject.Provides",
"com.google.inject.multibindings.ProvidesIntoMap",
Expand Down
Loading