Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add notes to UnusedMethod and UnusedVariable to discourage adding more annotations to the lists of exempting annotations. #4539

Merged
merged 1 commit into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
* <p>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<String> EXEMPTING_METHOD_ANNOTATIONS =
ImmutableSet.of(
"com.fasterxml.jackson.annotation.JsonCreator",
Expand Down Expand Up @@ -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.
*
* <p>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<String> 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.
*
* <p>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<String> EXEMPTING_SUPER_TYPES = ImmutableSet.of();

private final ImmutableSet<String> exemptingMethodAnnotations;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
* <p>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<String> EXEMPTING_VARIABLE_ANNOTATIONS =
ImmutableSet.of(
Expand Down
Loading