Skip to content

Commit

Permalink
Don't fire PreferJavaTimeOverload on custom AssertJ assertThat() over…
Browse files Browse the repository at this point in the history
…loads.

Fixes #1435
Related to #1377 and f1df86d
  • Loading branch information
carterkozak committed Dec 5, 2019
1 parent df4cdef commit 66fcaa3
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
34 changes: 34 additions & 0 deletions core/AutoValue_Test.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@


import javax.annotation.processing.Generated;

@Generated("com.google.auto.value.processor.AutoValueProcessor")
final class AutoValue_Test extends Test {

private final String valueOne;
private final String valueTwo;

AutoValue_Test(
String valueOne,
String valueTwo) {
if (valueOne == null) {
throw new NullPointerException("Null valueOne");
}
this.valueOne = valueOne;
if (valueTwo == null) {
throw new NullPointerException("Null valueTwo");
}
this.valueTwo = valueTwo;
}

@Override
String valueOne() {
return valueOne;
}

@Override
String valueTwo() {
return valueTwo;
}

}
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.getResultType(methodInvocationTree),
state.getTypeFromString("org.assertj.core.api.Assert"),
state))));

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

0 comments on commit 66fcaa3

Please sign in to comment.