feature request: Check errorprone annotations by class name to avoid dependency on errorprone
- Dominant language
- Java
- Stars
- 7.2k
- Forks
- 820
- Avg merge
- 5h 9m
- Merged PRs (30d)
- 50
Description
What version of Error Prone are you using? v2.2.0
For some of the errorprone annotations, the errorprone plug-in checks it by class not by class name, so it will not work if we add a custom annotation with the same name and use the custom annotation. This is strong limitation if we want to avoid dependency on errorprone library and we do want the benefit of errorprone plug-in at the static code analysis phase.
Propose Error Prone plug-in to check annotation by name and existence of an annotation argument for custom annotations.
For example
https://github.com/grpc/grpc-java/blob/master/context/src/main/java/io/grpc/Context.java
```java
package io.grpc;
// we can not import com.google.errorprone.annotations.* and not even Guava
// because it adds dependency
import io.grpc.Context.CheckReturnValue;
import io.grpc.Context.DoNotMock;
// this custom annotation works because errorprone plug-in checks it by class name
@CheckReturnValue
// but this is not working because it is not com.google.errorprone.annotations.DoNotMock
@DoNotMock
public class Context {
...
// custom annotation
@interface CheckReturnValue {}
// custom annotation
@interface DoNotMock() {
String value() default "Create a real instance instead";
/** Errorprone please do check me. */
// propose Error Prone plug-in check annotation name and existence of this argument
String errorProne() default "Error Prone";
}
}
Contributor guide
Assessment
This issue has not been assessed yet.