Skip to content

Commit

Permalink
Rip out the YetMore flag.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 573209595
  • Loading branch information
graememorgan authored and Error Prone Team committed Oct 13, 2023
1 parent 8d62eb6 commit 1c62a56
Showing 1 changed file with 13 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@

import com.google.common.collect.Streams;
import com.google.errorprone.BugPattern;
import com.google.errorprone.ErrorProneFlags;
import com.google.errorprone.VisitorState;
import com.google.errorprone.bugpatterns.BugChecker;
import com.google.errorprone.bugpatterns.BugChecker.MethodInvocationTreeMatcher;
Expand Down Expand Up @@ -89,7 +88,17 @@ public class TruthIncompatibleType extends BugChecker implements MethodInvocatio
.onDescendantOf("com.google.common.truth.extensions.proto.ProtoFluentAssertion"),
instanceMethod().onDescendantOf("com.google.common.truth.extensions.proto.ProtoSubject"));

private final Matcher<ExpressionTree> scalarContains;
private static final Matcher<ExpressionTree> SCALAR_CONTAINS =
instanceMethod()
.onDescendantOfAny(
"com.google.common.truth.IterableSubject", "com.google.common.truth.StreamSubject")
.namedAnyOf(
"contains",
"containsExactly",
"doesNotContain",
"containsAnyOf",
"containsNoneOf",
"containsAtLeast");

private static final Matcher<ExpressionTree> IS_ANY_OF =
instanceMethod()
Expand Down Expand Up @@ -152,31 +161,8 @@ public class TruthIncompatibleType extends BugChecker implements MethodInvocatio
private final TypeCompatibility typeCompatibility;

@Inject
TruthIncompatibleType(TypeCompatibility typeCompatibility, ErrorProneFlags flags) {
TruthIncompatibleType(TypeCompatibility typeCompatibility) {
this.typeCompatibility = typeCompatibility;
this.scalarContains =
flags.getBoolean("TruthIncompatibleType:YetMore").orElse(true)
? instanceMethod()
.onDescendantOfAny(
"com.google.common.truth.IterableSubject",
"com.google.common.truth.StreamSubject")
.namedAnyOf(
"contains",
"containsExactly",
"doesNotContain",
"containsAnyOf",
"containsNoneOf",
"containsAtLeast")
: instanceMethod()
.onDescendantOfAny(
"com.google.common.truth.IterableSubject",
"com.google.common.truth.StreamSubject")
.namedAnyOf(
"contains",
"containsExactly",
"doesNotContain",
"containsAnyOf",
"containsNoneOf");
}

@Override
Expand Down Expand Up @@ -297,7 +283,7 @@ private Stream<Description> matchArrayContains(MethodInvocationTree tree, Visito
}

private Stream<Description> matchScalarContains(MethodInvocationTree tree, VisitorState state) {
if (!scalarContains.matches(tree, state)) {
if (!SCALAR_CONTAINS.matches(tree, state)) {
return Stream.empty();
}
ExpressionTree receiver = getReceiver(tree);
Expand Down

0 comments on commit 1c62a56

Please sign in to comment.