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 ability to suppress warning for the entire AutoValue class #4522

Merged
merged 1 commit into from
Aug 6, 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 @@ -62,7 +62,7 @@ public class AutoValueBoxedValues extends BugChecker implements ClassTreeMatcher

@Override
public Description matchClass(ClassTree tree, VisitorState state) {
if (!hasAnnotation(tree, AutoValue.class.getName(), state)) {
if (!hasAnnotation(tree, AutoValue.class.getName(), state) || isSuppressed(tree, state)) {
return NO_MATCH;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,34 @@ public void mixedTypes_refactoring() {
.doTest();
}

@Test
public void unnecessaryBoxedTypes_suppressWarningsForClass() {
compilationHelper
.addSourceLines(
"in/Test.java",
mergeLines(
lines(
"import com.google.auto.value.AutoValue;",
"@AutoValue",
"@SuppressWarnings(\"AutoValueBoxedValues\")",
"abstract class Test {",
" public abstract Long longId();",
" public abstract Integer intId();"),
linesWithoutBuilder(
" static Test create(Long longId, Integer intId) {",
" return new AutoValue_Test(longId, intId);",
" }"),
linesWithBuilder(
" @AutoValue.Builder",
" abstract static class Builder {",
" abstract Builder setLongId(Long value);",
" abstract Builder setIntId(Integer value);",
" abstract Test build();",
" }"),
lines("}")))
.doTest();
}

@Test
public void unnecessaryBoxedTypes_suppressWarnings() {
refactoringHelper
Expand Down
Loading