File tree Expand file tree Collapse file tree 3 files changed +12
-7
lines changed
check_api/src/main/java/com/google/errorprone/matchers
core/src/main/java/com/google/errorprone/bugpatterns Expand file tree Collapse file tree 3 files changed +12
-7
lines changed Original file line number Diff line number Diff line change 2929import static com .google .errorprone .matchers .Matchers .hasMethod ;
3030import static com .google .errorprone .matchers .Matchers .hasModifier ;
3131import static com .google .errorprone .matchers .Matchers .isSubtypeOf ;
32- import static com .google .errorprone .matchers .Matchers .methodHasParameters ;
32+ import static com .google .errorprone .matchers .Matchers .methodHasNoParameters ;
3333import static com .google .errorprone .matchers .Matchers .methodHasVisibility ;
3434import static com .google .errorprone .matchers .Matchers .methodIsNamed ;
3535import static com .google .errorprone .matchers .Matchers .methodNameStartsWith ;
@@ -144,14 +144,14 @@ private static boolean hasJUnitAttr(MethodSymbol methodSym) {
144144 public static final Matcher <MethodTree > isJunit3TestCase =
145145 allOf (
146146 methodNameStartsWith ("test" ),
147- methodHasParameters (),
147+ methodHasNoParameters (),
148148 Matchers .<MethodTree >hasModifier (Modifier .PUBLIC ),
149149 methodReturns (VOID_TYPE ));
150150
151151 /** Common matcher for possible JUnit setUp/tearDown methods. */
152152 private static final Matcher <MethodTree > looksLikeJUnitSetUpOrTearDown =
153153 allOf (
154- methodHasParameters (),
154+ methodHasNoParameters (),
155155 anyOf (
156156 methodHasVisibility (MethodVisibility .Visibility .PUBLIC ),
157157 methodHasVisibility (MethodVisibility .Visibility .PROTECTED )),
Original file line number Diff line number Diff line change @@ -887,6 +887,11 @@ public static Matcher<MethodTree> methodHasParameters(Matcher<VariableTree>... v
887887 return methodHasParameters (ImmutableList .copyOf (variableMatcher ));
888888 }
889889
890+ /** Matches an AST node that represents a method declaration with no parameters. */
891+ public static Matcher <MethodTree > methodHasNoParameters () {
892+ return methodHasParameters (ImmutableList .of ());
893+ }
894+
890895 /**
891896 * Matches an AST node that represents a method declaration, based on the list of
892897 * variableMatchers. Applies the variableMatcher at index n to the parameter at index n and
@@ -1482,7 +1487,7 @@ public static Matcher<MethodTree> equalsMethodDeclaration() {
14821487 allOf (
14831488 methodIsNamed ("toString" ),
14841489 methodHasVisibility (Visibility .PUBLIC ),
1485- methodHasParameters (),
1490+ methodHasNoParameters (),
14861491 methodReturns (STRING_TYPE ));
14871492
14881493 /** Matches {@link Object#toString} method declaration. */
@@ -1494,7 +1499,7 @@ public static Matcher<MethodTree> toStringMethodDeclaration() {
14941499 allOf (
14951500 methodIsNamed ("hashCode" ),
14961501 methodHasVisibility (Visibility .PUBLIC ),
1497- methodHasParameters (),
1502+ methodHasNoParameters (),
14981503 methodReturns (INT_TYPE ));
14991504
15001505 /** Matches {@code hashCode} method declaration. */
Original file line number Diff line number Diff line change 2727import static com .google .errorprone .matchers .JUnitMatchers .wouldRunInJUnit4 ;
2828import static com .google .errorprone .matchers .Matchers .allOf ;
2929import static com .google .errorprone .matchers .Matchers .enclosingClass ;
30- import static com .google .errorprone .matchers .Matchers .methodHasParameters ;
30+ import static com .google .errorprone .matchers .Matchers .methodHasNoParameters ;
3131import static com .google .errorprone .matchers .Matchers .methodReturns ;
3232import static com .google .errorprone .matchers .Matchers .not ;
3333import static com .google .errorprone .suppliers .Suppliers .VOID_TYPE ;
@@ -77,7 +77,7 @@ public final class JUnit3TestNotRun extends BugChecker implements MethodTreeMatc
7777 enclosingClass (isJUnit3TestClass ),
7878 not (isJunit3TestCase ),
7979 methodReturns (VOID_TYPE ),
80- methodHasParameters ());
80+ methodHasNoParameters ());
8181
8282 /**
8383 * Matches iff:
You can’t perform that action at this time.
0 commit comments