Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't fire PreferJavaTimeOverload on custom AssertJ assertThat() overloads. #1436

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@

import static com.google.errorprone.BugPattern.ProvidesFix.REQUIRES_HUMAN_ATTENTION;
import static com.google.errorprone.BugPattern.SeverityLevel.WARNING;
import static com.google.errorprone.matchers.Matchers.allOf;
import static com.google.errorprone.matchers.Matchers.anyOf;
import static com.google.errorprone.matchers.Matchers.constructor;
import static com.google.errorprone.matchers.Matchers.toType;
import static com.google.errorprone.matchers.method.MethodMatchers.instanceMethod;
import static com.google.errorprone.matchers.method.MethodMatchers.staticMethod;
import static com.google.errorprone.util.ASTHelpers.getSymbol;
Expand Down Expand Up @@ -111,7 +113,13 @@ public final class PreferJavaTimeOverload extends BugChecker

private static final Matcher<ExpressionTree> IGNORED_APIS =
anyOf(
staticMethod().onClass("org.assertj.core.api.Assertions").named("assertThat"));
allOf(
staticMethod().anyClass().named("assertThat"),
toType(MethodInvocationTree.class, (Matcher<MethodInvocationTree>) (methodInvocationTree, state) ->
isSubtype(
ASTHelpers.getReturnType(methodInvocationTree),
state.getTypeFromString("org.assertj.core.api.Assert"),
state))));

private static final Matcher<ExpressionTree> JAVA_DURATION_DECOMPOSITION_MATCHER =
anyOf(
Expand Down