diff --git a/core/src/main/java/com/google/errorprone/bugpatterns/UnusedMethod.java b/core/src/main/java/com/google/errorprone/bugpatterns/UnusedMethod.java index ebab420c169..a3547881c61 100644 --- a/core/src/main/java/com/google/errorprone/bugpatterns/UnusedMethod.java +++ b/core/src/main/java/com/google/errorprone/bugpatterns/UnusedMethod.java @@ -98,6 +98,13 @@ public final class UnusedMethod extends BugChecker implements CompilationUnitTre private static final String JUNIT_PARAMS_VALUE = "value"; private static final String JUNIT_PARAMS_ANNOTATION_TYPE = "junitparams.Parameters"; + /** + * Annotations that exempt methods from being considered unused. + * + *

Try to avoid adding more annotations here. Annotating these annotations with {@code @Keep} + * has the same effect; this list is chiefly for third-party annotations which cannot be + * annotated. + */ private static final ImmutableSet EXEMPTING_METHOD_ANNOTATIONS = ImmutableSet.of( "com.fasterxml.jackson.annotation.JsonCreator", @@ -159,10 +166,22 @@ public final class UnusedMethod extends BugChecker implements CompilationUnitTre "org.junit.jupiter.api.Test", "org.junit.jupiter.params.ParameterizedTest"); - /** Class annotations which exempt methods within the annotated class from findings. */ + /** + * Class annotations which exempt methods within the annotated class from findings. + * + *

Try to avoid adding more annotations here. Annotating these annotations with {@code @Keep} + * has the same effect; this list is chiefly for third-party annotations which cannot be + * annotated. + */ private static final ImmutableSet EXEMPTING_CLASS_ANNOTATIONS = ImmutableSet.of(); - /** The set of types exempting a type that is extending or implementing them. */ + /** + * The set of types exempting a type that is extending or implementing them. + * + *

Try to avoid adding more annotations here. Annotating these annotations with {@code @Keep} + * has the same effect; this list is chiefly for third-party annotations which cannot be + * annotated. + */ private static final ImmutableSet EXEMPTING_SUPER_TYPES = ImmutableSet.of(); private final ImmutableSet exemptingMethodAnnotations; diff --git a/core/src/main/java/com/google/errorprone/bugpatterns/UnusedVariable.java b/core/src/main/java/com/google/errorprone/bugpatterns/UnusedVariable.java index d01f7386a85..cfb211d3d70 100644 --- a/core/src/main/java/com/google/errorprone/bugpatterns/UnusedVariable.java +++ b/core/src/main/java/com/google/errorprone/bugpatterns/UnusedVariable.java @@ -137,6 +137,10 @@ public final class UnusedVariable extends BugChecker implements CompilationUnitT /** * The set of annotation full names which exempt annotated element from being reported as unused. + * + *

Try to avoid adding more annotations here. Annotating these annotations with {@code @Keep} + * has the same effect; this list is chiefly for third-party annotations which cannot be + * annotated. */ private static final ImmutableSet EXEMPTING_VARIABLE_ANNOTATIONS = ImmutableSet.of(