error-prone icon indicating copy to clipboard operation
error-prone copied to clipboard

How to get bug patterns supported by a given Error Prone version?

Open rdesgroppes opened this issue 2 years ago • 3 comments

I'm looking for a way to get the exact list of bug pattern names supported by a given Error Prone version, whether experimental or not. Practically, each time we upgrade our Bazel version, there's a chance that the shipped Error Prone plugin comes with changes we'd like to leverage. Ideally, I'd like to run a Bazel command that would print such a list I could then post-process to alter our configuration accordingly. But any other semi-automatable method would do the job. Thanks in advance!

rdesgroppes avatar May 25 '23 16:05 rdesgroppes

Not sure if that's what you're looking for (or maybe you found a way already) but the com.google.errorprone.scanner.BuiltInCheckerSuppliers class has ENABLED_WARNINGS and ENABLED_ERRORS sets, you can use them to programmatically get the patterns

gtoison avatar Nov 07 '23 11:11 gtoison

Not sure if that's what you're looking for (or maybe you found a way already) but the com.google.errorprone.scanner.BuiltInCheckerSuppliers class has ENABLED_WARNINGS and ENABLED_ERRORS sets, you can use them to programmatically get the patterns

Excuse me, If we customizsed some checkers, do we have to insert ours checkers into ENABLED_WARNINGS and ENABLED_ERRORS sets,?

SolomonSun2010 avatar Apr 03 '24 06:04 SolomonSun2010

My comment was for the built-in checkers, I don't think you would need to add your custom checkers in there.

From memory the checkers are loaded using the Java service api. See for instance https://github.com/KengoTODA/errorprone-slf4j/blob/master/src/main/java/jp/skypencil/errorprone/slf4j/Slf4jIllegalPassedClass.java uses @AutoService(BugChecker.class) to generate the service file.

gtoison avatar Apr 03 '24 07:04 gtoison