Error-prone: Disable checks for an entire package.

Created on 4 Feb 2017  路  7Comments  路  Source: google/error-prone

I'm adding error-prone to a legacy project and have the need to disable/ignore an entire package.

This package is a transplant from a third-party dependency that isn't published as a consumable artifact but also requires a very small tweak to work in my usage. Since I want to reduce the changes to this package so future updates are easy, I'm hesitant to go in and annotation every type with a suppression for every violation therein.

Unfortunately the @SuppressWarnings annotation can't be targeted at packages so I can't use it in a package-info.java either (not sure this would have worked anyway).

Is there any other way of suppressing checks for an entire package? And if not, what do you think about introducing a mechanism for this (e.g., an exclude flag which was a list of globs)?

Most helpful comment

I think it very useful to have a glob/pattern matching solution where error prone can skip all analysis on generated code for example. Then it is not purely controlled by an annotation

All 7 comments

If it would be done by using globs, #511 would also get supported automatically.

We generally use build flags to disable checks for third party packages where it isn't worth fixing minor issues, but that may not be a good option depend on the build system and project structure you're using.

What do you think about adding another annotation that works the same as @SuppressWarnings but can be applied to packages? JDK-6299893 failed to convince me that package-level suppressions are a bad idea.

Yeah it sounds like I should isolate this package into its own mobile so that the checks (or even the whole compiler) can be disabled on only it. I'm certainly not convinced either that whole-package suppression should _not_ be supported, but i'm also not sure if i'm convinced that it needs added at this time.

I have a similar need regarding generated code (gRPC-generated code specifically).

I think it very useful to have a glob/pattern matching solution where error prone can skip all analysis on generated code for example. Then it is not purely controlled by an annotation

I think this issue can be closed because Error Prone now supports a -XepExcludedPaths command-line flag.

Thanks for the heads up, @mernst!

Was this page helpful?
0 / 5 - 0 ratings