Skip to content

Commit 137618a

Browse files
authored
Simplify AbstractMatcherTestChecker subtype definitions (#2140)
This was likely made possible by google/error-prone@1c3c09f. While there, make other test `BugChecker`s `private` too.
1 parent ad7b45f commit 137618a

19 files changed

+44
-75
lines changed

error-prone-utils/src/test/java/tech/picnic/errorprone/utils/ConflictDetectionTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ void matcher() {
8585
* String, VisitorState)} to flag methods of which the name cannot be suffixed with a {@code t}.
8686
*/
8787
@BugPattern(summary = "Interacts with `ConflictDetection` for testing purposes", severity = ERROR)
88-
public static final class RenameBlockerFlagger extends BugChecker implements MethodTreeMatcher {
88+
private static final class RenameBlockerFlagger extends BugChecker implements MethodTreeMatcher {
8989
private static final long serialVersionUID = 1L;
9090

9191
@Override

error-prone-utils/src/test/java/tech/picnic/errorprone/utils/MethodMatcherFactoryTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ void matcher() {
203203

204204
/** A {@link BugChecker} that flags method invocations matched by {@link #TEST_MATCHER}. */
205205
@BugPattern(severity = SUGGESTION, summary = "Flags methods matched by the test matcher.")
206-
public static final class MatchedMethodsFlagger extends BugChecker
206+
private static final class MatchedMethodsFlagger extends BugChecker
207207
implements MethodInvocationTreeMatcher {
208208
private static final long serialVersionUID = 1L;
209209

error-prone-utils/src/test/java/tech/picnic/errorprone/utils/MoreASTHelpersTest.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,8 @@ private static String createMethodSearchDiagnosticsMessage(
170170
* VisitorState)}.
171171
*/
172172
@BugPattern(summary = "Interacts with `MoreASTHelpers` for testing purposes", severity = ERROR)
173-
public static final class FindMethodsTestChecker extends BugChecker implements MethodTreeMatcher {
173+
private static final class FindMethodsTestChecker extends BugChecker
174+
implements MethodTreeMatcher {
174175
private static final long serialVersionUID = 1L;
175176

176177
@Override
@@ -188,7 +189,7 @@ public Description matchMethod(MethodTree tree, VisitorState state) {
188189
* MoreASTHelpers#methodExistsInEnclosingClass(CharSequence, VisitorState)}.
189190
*/
190191
@BugPattern(summary = "Interacts with `MoreASTHelpers` for testing purposes", severity = ERROR)
191-
public static final class MethodExistsTestChecker extends BugChecker
192+
private static final class MethodExistsTestChecker extends BugChecker
192193
implements MethodTreeMatcher {
193194
private static final long serialVersionUID = 1L;
194195

@@ -207,7 +208,7 @@ public Description matchMethod(MethodTree tree, VisitorState state) {
207208
* MoreASTHelpers#findMethodExitedOnReturn(VisitorState)}.
208209
*/
209210
@BugPattern(summary = "Interacts with `MoreASTHelpers` for testing purposes", severity = ERROR)
210-
public static final class FindMethodReturnTestChecker extends BugChecker
211+
private static final class FindMethodReturnTestChecker extends BugChecker
211212
implements ExpressionStatementTreeMatcher, ReturnTreeMatcher {
212213
private static final long serialVersionUID = 1L;
213214

@@ -233,7 +234,8 @@ private Description flagMethodReturnLocation(Tree tree, VisitorState state) {
233234
* VisitorState)}.
234235
*/
235236
@BugPattern(summary = "Interacts with `MoreASTHelpers` for testing purposes", severity = ERROR)
236-
public static final class AreSameTypeTestChecker extends BugChecker implements MethodTreeMatcher {
237+
private static final class AreSameTypeTestChecker extends BugChecker
238+
implements MethodTreeMatcher {
237239
private static final long serialVersionUID = 1L;
238240

239241
@Override
@@ -252,7 +254,7 @@ public Description matchMethod(MethodTree tree, VisitorState state) {
252254
* VisitorState)}.
253255
*/
254256
@BugPattern(summary = "Interacts with `MoreASTHelpers` for testing purposes", severity = ERROR)
255-
public static final class IsStringTypedTestChecker extends BugChecker
257+
private static final class IsStringTypedTestChecker extends BugChecker
256258
implements MethodInvocationTreeMatcher, VariableTreeMatcher {
257259
private static final long serialVersionUID = 1L;
258260

error-prone-utils/src/test/java/tech/picnic/errorprone/utils/MoreJUnitMatchersTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ void getMethodSourceFactoryDescriptors() {
170170
* exposed by {@link MoreJUnitMatchers}.
171171
*/
172172
@BugPattern(summary = "Interacts with `MoreJUnitMatchers` for testing purposes", severity = ERROR)
173-
public static final class MethodMatchersTestChecker extends BugChecker
173+
private static final class MethodMatchersTestChecker extends BugChecker
174174
implements MethodTreeMatcher {
175175
private static final long serialVersionUID = 1L;
176176
private static final ImmutableMap<String, Matcher<MethodTree>> METHOD_MATCHERS =
@@ -198,7 +198,7 @@ public Description matchMethod(MethodTree tree, VisitorState state) {
198198
* enumerating the associated value factory method names.
199199
*/
200200
@BugPattern(summary = "Interacts with `MoreJUnitMatchers` for testing purposes", severity = ERROR)
201-
public static final class MethodSourceFactoryNamesTestChecker extends BugChecker
201+
private static final class MethodSourceFactoryNamesTestChecker extends BugChecker
202202
implements MethodTreeMatcher {
203203
private static final long serialVersionUID = 1L;
204204

@@ -218,7 +218,7 @@ public Description matchMethod(MethodTree tree, VisitorState state) {
218218
* enumerating the associated value factory method descriptors.
219219
*/
220220
@BugPattern(summary = "Interacts with `MoreJUnitMatchers` for testing purposes", severity = ERROR)
221-
public static final class MethodSourceFactoryDescriptorsTestChecker extends BugChecker
221+
private static final class MethodSourceFactoryDescriptorsTestChecker extends BugChecker
222222
implements MethodTreeMatcher {
223223
private static final long serialVersionUID = 1L;
224224

error-prone-utils/src/test/java/tech/picnic/errorprone/utils/MoreMatchersTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ void isSubTypeOfBoundTypeUnknown() {
106106

107107
/** A {@link BugChecker} that delegates to {@link MoreMatchers#hasMetaAnnotation(String)}. */
108108
@BugPattern(summary = "Interacts with `MoreMatchers` for testing purposes", severity = ERROR)
109-
public static final class HasMetaAnnotationTestChecker extends BugChecker
109+
private static final class HasMetaAnnotationTestChecker extends BugChecker
110110
implements AnnotationTreeMatcher {
111111
private static final long serialVersionUID = 1L;
112112
private static final Matcher<AnnotationTree> DELEGATE =
@@ -120,7 +120,7 @@ public Description matchAnnotation(AnnotationTree tree, VisitorState state) {
120120

121121
/** A {@link BugChecker} that delegates to {@link MoreMatchers#isSubTypeOf(Supplier)}. */
122122
@BugPattern(summary = "Interacts with `MoreMatchers` for testing purposes", severity = ERROR)
123-
public static final class IsSubTypeOfTestChecker extends BugChecker
123+
private static final class IsSubTypeOfTestChecker extends BugChecker
124124
implements MethodInvocationTreeMatcher {
125125
private static final long serialVersionUID = 1L;
126126
private static final Matcher<Tree> DELEGATE =

error-prone-utils/src/test/java/tech/picnic/errorprone/utils/MoreTypesTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ void matcher() {
126126
* {@link #getTestTypes()}.
127127
*/
128128
@BugPattern(summary = "Flags invocations of methods with select return types", severity = ERROR)
129-
public static final class SubtypeFlagger extends BugChecker
129+
private static final class SubtypeFlagger extends BugChecker
130130
implements MethodInvocationTreeMatcher {
131131
private static final long serialVersionUID = 1L;
132132

error-prone-utils/src/test/java/tech/picnic/errorprone/utils/SourceCodeTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ void sortTrees() {
334334
* VisitorState)} to string literals.
335335
*/
336336
@BugPattern(severity = ERROR, summary = "Interacts with `SourceCode` for testing purposes")
337-
public static final class ToStringConstantExpressionTestChecker extends BugChecker
337+
private static final class ToStringConstantExpressionTestChecker extends BugChecker
338338
implements LiteralTreeMatcher, VariableTreeMatcher {
339339
private static final long serialVersionUID = 1L;
340340

@@ -363,7 +363,7 @@ private static SuggestedFix addComment(Tree tree, Object value, VisitorState sta
363363
* {@value DELETION_MARKER}.
364364
*/
365365
@BugPattern(severity = ERROR, summary = "Interacts with `SourceCode` for testing purposes")
366-
public static final class DeleteWithTrailingWhitespaceTestChecker extends BugChecker
366+
private static final class DeleteWithTrailingWhitespaceTestChecker extends BugChecker
367367
implements AnnotationTreeMatcher, MethodTreeMatcher {
368368
private static final long serialVersionUID = 1L;
369369
private static final String DELETION_MARKER = "ToBeDeleted";
@@ -394,7 +394,7 @@ private Description match(Tree tree, Name name, VisitorState state) {
394394
* invocations.
395395
*/
396396
@BugPattern(severity = ERROR, summary = "Interacts with `SourceCode` for testing purposes")
397-
public static final class UnwrapMethodInvocationTestChecker extends BugChecker
397+
private static final class UnwrapMethodInvocationTestChecker extends BugChecker
398398
implements MethodInvocationTreeMatcher {
399399
private static final long serialVersionUID = 1L;
400400

@@ -410,7 +410,7 @@ public Description matchMethodInvocation(MethodInvocationTree tree, VisitorState
410410
* VisitorState)} to all method invocations.
411411
*/
412412
@BugPattern(severity = ERROR, summary = "Interacts with `SourceCode` for testing purposes")
413-
public static final class UnwrapMethodInvocationDroppingWhitespaceAndCommentsTestChecker
413+
private static final class UnwrapMethodInvocationDroppingWhitespaceAndCommentsTestChecker
414414
extends BugChecker implements MethodInvocationTreeMatcher {
415415
private static final long serialVersionUID = 1L;
416416

@@ -427,7 +427,7 @@ public Description matchMethodInvocation(MethodInvocationTree tree, VisitorState
427427
* lexicographically.
428428
*/
429429
@BugPattern(severity = ERROR, summary = "Interacts with `SourceCode` for testing purposes")
430-
public static final class SortTreesTestChecker extends BugChecker
430+
private static final class SortTreesTestChecker extends BugChecker
431431
implements MethodInvocationTreeMatcher {
432432
private static final long serialVersionUID = 1L;
433433

error-prone-utils/src/test/java/tech/picnic/errorprone/utils/ThirdPartyLibraryTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ void canIntroduceUsage() {
102102
* element, whether they can be used.
103103
*/
104104
@BugPattern(severity = ERROR, summary = "Interacts with `ThirdPartyLibrary` for testing purposes")
105-
public static final class IsIntroductionAllowedTestChecker extends BugChecker
105+
private static final class IsIntroductionAllowedTestChecker extends BugChecker
106106
implements ClassTreeMatcher {
107107
private static final long serialVersionUID = 1L;
108108

@@ -122,7 +122,7 @@ public Description matchClass(ClassTree tree, VisitorState state) {
122122
* {@link ThirdPartyLibrary#canIntroduceUsage(String, VisitorState)}.
123123
*/
124124
@BugPattern(severity = ERROR, summary = "Interacts with `ThirdPartyLibrary` for testing purposes")
125-
public static final class CanIntroduceUsageTestChecker extends BugChecker
125+
private static final class CanIntroduceUsageTestChecker extends BugChecker
126126
implements ClassTreeMatcher {
127127
private static final long serialVersionUID = 1L;
128128
private static final ImmutableMap<String, String> TYPES =

refaster-support/src/test/java/tech/picnic/errorprone/refaster/matchers/IsArrayTest.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,10 @@ void matches() {
4141

4242
/** A {@link BugChecker} that simply delegates to {@link IsArray}. */
4343
@BugPattern(summary = "Flags expressions matched by `IsArray`", severity = ERROR)
44-
public static final class MatcherTestChecker extends AbstractMatcherTestChecker {
44+
private static final class MatcherTestChecker extends AbstractMatcherTestChecker {
4545
private static final long serialVersionUID = 1L;
4646

47-
// XXX: This is a false positive reported by Checkstyle. See
48-
// https://github.com/checkstyle/checkstyle/issues/10161#issuecomment-1242732120.
49-
@SuppressWarnings("RedundantModifier")
50-
public MatcherTestChecker() {
47+
private MatcherTestChecker() {
5148
super(new IsArray());
5249
}
5350
}

refaster-support/src/test/java/tech/picnic/errorprone/refaster/matchers/IsCharacterTest.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,10 @@ void matches() {
5050

5151
/** A {@link BugChecker} that simply delegates to {@link IsCharacter}. */
5252
@BugPattern(summary = "Flags expressions matched by `IsCharacter`", severity = ERROR)
53-
public static final class MatcherTestChecker extends AbstractMatcherTestChecker {
53+
private static final class MatcherTestChecker extends AbstractMatcherTestChecker {
5454
private static final long serialVersionUID = 1L;
5555

56-
// XXX: This is a false positive reported by Checkstyle. See
57-
// https://github.com/checkstyle/checkstyle/issues/10161#issuecomment-1242732120.
58-
@SuppressWarnings("RedundantModifier")
59-
public MatcherTestChecker() {
56+
private MatcherTestChecker() {
6057
super(new IsCharacter());
6158
}
6259
}

0 commit comments

Comments
 (0)