ErrorProne flags Subscribe annotated methods as UnusedMethod
bright-tools opened this issue · comments
We've found that ErrorProne flags all @Subscribe
annotated methods with an UnusedMethod warning
ErrorProne has a Keep annotation which could be applied to the Subscribe annotation in order to avoid this.
The alternatives seem to be suppressing the warning for each method or adding the subscribe annotation to a growing exemption list.
Would you be open to a PR to annotate Subscribe with @keep?
Thanks. It looks like UnusedMethod
has a special case for @Subscribe
already, but it's accidentally set up only for our internal builds.
That special case predates the creation of @Keep
, so @Keep
wasn't an option back then. We'll either add @Keep
now or make the special case public.
(I should always take EventBus bugs as an opportunity to point people to our docs that recommend against using it if you can help it. But we should fix this regardless.)
This will be fixed in the next Error Prone release.
It's probably true that @Keep
would be better. Hopefully that, like the special case in Error Prone, would work even if users omit error_prone_annotations
from their own builds (though we recommend against that). I went with the fix on the Error Prone side just because it was slightly easier, especially to handle more annotations than just Guava's.