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

Fix #1159: StrictUnusedVariable respects UnusedVariable suppression #1160

Merged
merged 2 commits into from
Jan 10, 2020
Merged
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
@@ -106,7 +106,7 @@
@AutoService(BugChecker.class)
@BugPattern(
name = "StrictUnusedVariable",
altNames = {"unused", "StrictUnusedVariable"},
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's unnecessary to duplicate the name.

altNames = {"unused", "UnusedVariable"},
link = "https://github.com/palantir/gradle-baseline#baseline-error-prone-checks",
linkType = BugPattern.LinkType.CUSTOM,
summary = "Unused.",
Original file line number Diff line number Diff line change
@@ -215,4 +215,19 @@ public void fixes_previously_suppressed_variables() {
"}"
).doTest(TestMode.TEXT_MATCH);
}

@Test
public void testSuppression() {
refactoringTestHelper
.addInputLines(
"Test.java",
"class Test {",
" public static void a(@SuppressWarnings(\"StrictUnusedVariable\") int val) {}",
" public static void b(@SuppressWarnings(\"UnusedVariable\") int val) {}",
" public static void c(@SuppressWarnings(\"unused\") int val) {}",
" public static void d(int _val) {}",
"}")
.expectUnchanged()
.doTest(TestMode.TEXT_MATCH);
}
}
5 changes: 5 additions & 0 deletions changelog/@unreleased/pr-1160.v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type: fix
fix:
description: StrictUnusedVariable respects UnusedVariable suppression
links:
- https://github.com/palantir/gradle-baseline/pull/1160