Google errorprone java compiler - Default bugpatterns? Mark ignore?

627 views Asked by At

I am getting some warnings regarding the accessing static method from a variable over class.

Is there a way to tell errorprone to ignore these warnings? Is error-prone loaded with a set of "bugpatterns"? Is it all of these:

https://github.com/google/error-prone/tree/master/core/src/main/java/com/google/errorprone/bugpatterns

How can I override for instance this to stop complaining:

Warning:(111, 21) java: [StaticAccessedFromInstance] Static method info should not be accessed from an object instance; instead use Log.info (see errorprone.info/bugpattern/StaticAccessedFromInstance) Did you mean 'Log.info( EntityError.class, Gson.asString(this) );'?

I am using Intellij.

2

There are 2 answers

1
Andy Turner On BEST ANSWER

According to the errorprone flags documentation, you can switch the check off with:

-Xep:StaticAccessedFromInstance:OFF

However, I agree with Kayaman: you are better off fixing the problem than working to ignore it.

3
GhostCat On

Maybe I am mistaken; but I think that "eclipse code cleanup" is able to fix this kind of code problem automatically.

My suggestion would be to rather spend time to understand how such bugs can be easily fixed; versus spending time to suppress the corresponding warning.