Skip to content

Commit

Permalink
Fix possible ClassCastException and cleanup warnings in NoRequestMapp…
Browse files Browse the repository at this point in the history
…ingAnnotation
  • Loading branch information
sambsnyd committed Mar 14, 2024
1 parent 0bb7731 commit 866f021
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@
import static org.openrewrite.Tree.randomId;

/**
* This visitor can remove the specified method calls if it can be deleted without compile error,
* It can be used to remove deprecated or unnecessary method calls, but be sure to carefully
* review your code before deleting any methods to avoid errors or unexpected behavior.
* This visitor removes method calls matching some criteria.
* Tries to intelligently remove within chains without breaking other methods in the chain.
*/
public class RemoveMethodInvocationsVisitor extends JavaVisitor<ExecutionContext> {
private final Map<MethodMatcher, Predicate<List<Expression>>> matchers;
Expand Down Expand Up @@ -64,7 +63,8 @@ public J visitMethodInvocation(J.MethodInvocation method, ExecutionContext ctx)
j = j.withPrefix(method.getPrefix());
}

if (method.getArguments().stream().allMatch(ToBeRemoved::hasMarker)) {
// There should always be
if (!method.getArguments().isEmpty() && method.getArguments().stream().allMatch(ToBeRemoved::hasMarker)) {
return ToBeRemoved.withMarker(j);
}
return j;
Expand Down

0 comments on commit 866f021

Please sign in to comment.