Skip to content

Commit c532950

Browse files
graememorganError Prone Team
authored andcommitted
Delete deprecated isSuppressed methods.
I fear I may have to split this. PiperOrigin-RevId: 827964348
1 parent 1ba080b commit c532950

File tree

3 files changed

+2
-101
lines changed

3 files changed

+2
-101
lines changed

check_api/src/main/java/com/google/errorprone/bugpatterns/BugChecker.java

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
import com.google.errorprone.matchers.Description;
3636
import com.google.errorprone.matchers.Suppressible;
3737
import com.google.errorprone.suppliers.Supplier;
38-
import com.google.errorprone.util.ASTHelpers;
3938
import com.sun.source.tree.AnnotatedTypeTree;
4039
import com.sun.source.tree.AnnotationTree;
4140
import com.sun.source.tree.ArrayAccessTree;
@@ -107,9 +106,7 @@
107106
import com.sun.tools.javac.util.Name;
108107
import java.io.Serializable;
109108
import java.lang.annotation.Annotation;
110-
import java.util.Arrays;
111109
import java.util.Collections;
112-
import java.util.List;
113110
import java.util.Objects;
114111
import java.util.Set;
115112
import java.util.function.BiPredicate;
@@ -260,31 +257,6 @@ public boolean suppressedByAnyOf(Set<Name> annotations, VisitorState s) {
260257
return checkSuppression.test(annotations, s);
261258
}
262259

263-
/**
264-
* @deprecated use {@link #isSuppressed(Tree, VisitorState)} instead
265-
*/
266-
@Deprecated
267-
public boolean isSuppressed(Tree tree) {
268-
return isSuppressed(ASTHelpers.getAnnotation(tree, SuppressWarnings.class));
269-
}
270-
271-
/**
272-
* @deprecated use {@link #isSuppressed(Symbol, VisitorState)} instead
273-
*/
274-
@Deprecated
275-
public boolean isSuppressed(Symbol symbol) {
276-
return isSuppressed(ASTHelpers.getAnnotation(symbol, SuppressWarnings.class));
277-
}
278-
279-
private boolean isSuppressed(SuppressWarnings suppression) {
280-
if (suppression == null || !supportsSuppressWarnings()) {
281-
return false;
282-
}
283-
284-
List<String> suppressions = Arrays.asList(suppression.value());
285-
return suppressions.contains("all") || !Collections.disjoint(suppressions, allNames());
286-
}
287-
288260
/**
289261
* Returns true if the given tree is annotated with a {@code @SuppressWarnings} that disables this
290262
* bug checker.

core/src/main/java/com/google/errorprone/bugpatterns/threadsafety/ThreadSafeAnalysis.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,10 +235,9 @@ private Violation isFieldThreadSafe(
235235
ClassSymbol classSym,
236236
ClassType classType,
237237
VarSymbol var) {
238-
if (bugChecker.isSuppressed(var)
238+
if (bugChecker.isSuppressed(var, state)
239239
|| bugChecker.customSuppressionAnnotations().stream()
240-
.map(a -> hasAnnotation(var, a.getName(), state))
241-
.anyMatch(v -> v)) {
240+
.anyMatch(a -> hasAnnotation(var, a.getName(), state))) {
242241
return Violation.absent();
243242
}
244243
if (var.getModifiers().contains(Modifier.STATIC)) {

core/src/test/java/com/google/errorprone/bugpatterns/BugCheckerTest.java

Lines changed: 0 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,9 @@
1616

1717
package com.google.errorprone.bugpatterns;
1818

19-
import static com.google.common.collect.ImmutableList.toImmutableList;
2019
import static com.google.errorprone.BugPattern.SeverityLevel.ERROR;
2120
import static com.google.errorprone.matchers.Description.NO_MATCH;
2221

23-
import com.google.common.collect.ImmutableList;
2422
import com.google.errorprone.BugPattern;
2523
import com.google.errorprone.CompilationTestHelper;
2624
import com.google.errorprone.VisitorState;
@@ -38,45 +36,6 @@
3836

3937
@RunWith(JUnit4.class)
4038
public class BugCheckerTest {
41-
@Test
42-
public void isSuppressed_withoutVisitorState() {
43-
CompilationTestHelper.newInstance(LegacySuppressionCheck.class, getClass())
44-
.addSourceLines(
45-
"A.java",
46-
"""
47-
class A {
48-
void m() {
49-
// BUG: Diagnostic contains: []
50-
int unsuppressed;
51-
@SuppressWarnings("foo")
52-
// BUG: Diagnostic contains: []
53-
int unrelatedSuppression;
54-
@SuppressWarnings("Suppressible")
55-
// BUG: Diagnostic contains: [Suppressible, SuppressibleTps, ManualIsSuppressed]
56-
int suppressed;
57-
@SuppressWarnings("Alternative")
58-
// BUG: Diagnostic contains: [Suppressible, SuppressibleTps, ManualIsSuppressed]
59-
int suppressedWithAlternativeName;
60-
@SuppressWarnings("all")
61-
// BUG: Diagnostic contains: [Suppressible, SuppressibleTps, ManualIsSuppressed]
62-
int allSuppressed;
63-
@SuppressWarnings({"foo", "Suppressible"})
64-
// BUG: Diagnostic contains: [Suppressible, SuppressibleTps, ManualIsSuppressed]
65-
int alsoSuppressed;
66-
@SuppressWarnings({"all", "foo"})
67-
// BUG: Diagnostic contains: [Suppressible, SuppressibleTps, ManualIsSuppressed]
68-
int redundantlySuppressed;
69-
@SuppressWarnings({"all", "OnlySuppressedInsideDeprecatedCode"})
70-
// BUG: Diagnostic contains: [Suppressible, SuppressibleTps, ManualIsSuppressed]
71-
int ineffectiveSuppression;
72-
// BUG: Diagnostic contains: []
73-
@Deprecated int unuspportedSuppression;
74-
}
75-
}
76-
""")
77-
.doTest();
78-
}
79-
8039
@Test
8140
public void isSuppressed() {
8241
CompilationTestHelper.newInstance(SuppressibleCheck.class, getClass())
@@ -255,35 +214,6 @@ void m() {
255214
.doTest();
256215
}
257216

258-
@BugPattern(
259-
name = "SuppressionReporter",
260-
summary =
261-
"Tells whether some other checks are suppressed according to the deprecated method "
262-
+ "`BugChecker#isSuppressed(Tree)`",
263-
severity = ERROR,
264-
suppressionAnnotations = {})
265-
public static final class LegacySuppressionCheck extends BugChecker
266-
implements VariableTreeMatcher {
267-
private final ImmutableList<BugChecker> checks =
268-
ImmutableList.of(
269-
new SuppressibleCheck(),
270-
new CustomSuppressibilityCheck(),
271-
new SuppressibleTreePathScannerCheck(),
272-
new ManuallySuppressibleCheck());
273-
274-
@Override
275-
@SuppressWarnings("deprecation") // testing deprecated method
276-
public Description matchVariable(VariableTree tree, VisitorState state) {
277-
ImmutableList<String> suppressions =
278-
checks.stream()
279-
.filter(check -> check.isSuppressed(tree))
280-
.map(BugChecker::canonicalName)
281-
.collect(toImmutableList());
282-
283-
return buildDescription(tree).setMessage("Suppressions: " + suppressions).build();
284-
}
285-
}
286-
287217
@BugPattern(
288218
name = "Suppressible",
289219
altNames = "Alternative",

0 commit comments

Comments
 (0)