diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/MonoZipOfMonoVoidUsage.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/MonoZipOfMonoVoidUsage.java index 278920247ca..7754ca540ca 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/MonoZipOfMonoVoidUsage.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/MonoZipOfMonoVoidUsage.java @@ -19,7 +19,6 @@ import com.google.errorprone.BugPattern; import com.google.errorprone.VisitorState; import com.google.errorprone.bugpatterns.BugChecker; -import com.google.errorprone.bugpatterns.BugChecker.MemberReferenceTreeMatcher; import com.google.errorprone.bugpatterns.BugChecker.MethodInvocationTreeMatcher; import com.google.errorprone.fixes.SuggestedFixes; import com.google.errorprone.matchers.Description; @@ -27,10 +26,8 @@ import com.google.errorprone.suppliers.Supplier; import com.google.errorprone.util.ASTHelpers; import com.sun.source.tree.ExpressionTree; -import com.sun.source.tree.MemberReferenceTree; import com.sun.source.tree.MethodInvocationTree; import com.sun.tools.javac.code.Type; -import com.sun.tools.javac.util.List; import reactor.core.publisher.Mono; /** @@ -41,9 +38,10 @@ * of the empty publisher and prematurely terminates the reactive chain from the execution. In most * cases this is not the desired behaviour. * - *

NB: Mono<?>#zipWith(Mono<Void>) is allowed be the Reactor API, but it is an incorrect - * usage of the API. It will be flagged by ErrorProne but the fix won't be supplied. The problem - * with the original code should be revisited and fixed in a structural manner by the developer. + *

NB: Mono<?>#zipWith(Mono<Void>) is allowed be the Reactor API, but it is an + * incorrect usage of the API. It will be flagged by ErrorProne but the fix won't be supplied. The + * problem with the original code should be revisited and fixed in a structural manner by the + * developer. */ @AutoService(BugChecker.class) @BugPattern( @@ -55,7 +53,7 @@ severity = ERROR, tags = LIKELY_ERROR) public final class MonoZipOfMonoVoidUsage extends BugChecker - implements MethodInvocationTreeMatcher, MemberReferenceTreeMatcher { + implements MethodInvocationTreeMatcher { private static final long serialVersionUID = 1L; private static final Supplier MONO = type(Mono.class.getName()); // Mono.empty() yields `Mono` under the hood @@ -111,17 +109,6 @@ public Description matchMethodInvocation(MethodInvocationTree tree, VisitorState .build(); } - @Override - public Description matchMemberReference(MemberReferenceTree tree, VisitorState state) { - boolean dynamicMono = MONO_ZIP_AND_WITH.matches(tree, state); - boolean staticMono = STATIC_MONO_ZIP.matches(tree, state); - - if (!dynamicMono && !staticMono) { - return Description.NO_MATCH; - } - return describeMatch(tree); - } - private static Matcher hasArgumentOfType(Supplier type) { return hasArgumentOfTypes(ImmutableList.of(type)); } @@ -149,12 +136,7 @@ private static Matcher hasArgumentOfTypes( tree.getArguments().stream() .anyMatch( arg -> { - List allParams = ASTHelpers.getType(arg).allparams(); - if (allParams.isEmpty()) { - return false; - } - - Type argumentType = allParams.get(0); + Type argumentType = ASTHelpers.getType(arg).allparams().get(0); return types.stream() .map(type -> type.get(state).allparams().get(0)) .anyMatch(