Skip to content

Commit

Permalink
Remove ProtoFieldPreconditionsCheckNotNull, as it is subsumed into
Browse files Browse the repository at this point in the history
ProtoFieldNullComparison.

MOE_MIGRATED_REVID=211590847
  • Loading branch information
graememorgan authored and cushon committed Sep 13, 2018
1 parent 722be59 commit 03200e9
Show file tree
Hide file tree
Showing 7 changed files with 2 additions and 372 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ private static boolean isNull(ExpressionTree tree) {
private final Matcher<ExpressionTree> protoReceiver;
private final boolean trackAssignments;
private final boolean matchListGetters;
private final boolean matchCheckNotNull;
private final boolean matchTestAssertions;

public ProtoFieldNullComparison(ErrorProneFlags flags) {
Expand All @@ -147,8 +146,6 @@ public ProtoFieldNullComparison(ErrorProneFlags flags) {
: instanceMethod().onDescendantOf(PROTO_SUPER_CLASS);
trackAssignments = flags.getBoolean("ProtoFieldNullComparison:TrackAssignments").orElse(false);
matchListGetters = flags.getBoolean("ProtoFieldNullComparison:MatchListGetters").orElse(false);
matchCheckNotNull =
flags.getBoolean("ProtoFieldNullComparison:MatchCheckNotNull").orElse(false);
matchTestAssertions =
flags.getBoolean("ProtoFieldNullComparison:MatchTestAssertions").orElse(false);
}
Expand Down Expand Up @@ -213,7 +210,7 @@ public Void visitMethodInvocation(MethodInvocationTree node, Void unused) {
VisitorState subState = state.withPath(getCurrentPath());
ExpressionTree argument;
ProblemUsage problemType;
if (matchCheckNotNull && CHECK_NOT_NULL.matches(node, subState)) {
if (CHECK_NOT_NULL.matches(node, subState)) {
argument = node.getArguments().get(0);
problemType = ProblemUsage.CHECK_NOT_NULL;
} else if (matchTestAssertions && ASSERT_NOT_NULL.matches(node, subState)) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@
import com.google.errorprone.bugpatterns.PrivateConstructorForUtilityClass;
import com.google.errorprone.bugpatterns.PrivateSecurityContractProtoAccess;
import com.google.errorprone.bugpatterns.ProtoFieldNullComparison;
import com.google.errorprone.bugpatterns.ProtoFieldPreconditionsCheckNotNull;
import com.google.errorprone.bugpatterns.ProtoRedundantSet;
import com.google.errorprone.bugpatterns.ProtoStringFieldReferenceEquality;
import com.google.errorprone.bugpatterns.ProtocolBufferOrdinal;
Expand Down Expand Up @@ -593,7 +592,6 @@ public static ScannerSupplier errorChecks() {
OverrideThrowableToString.class,
ParameterName.class,
PreconditionsInvalidPlaceholder.class,
ProtoFieldPreconditionsCheckNotNull.class,
ProtoRedundantSet.class,
QualifierOrScopeOnInjectMethod.class,
ReachabilityFenceUsage.class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,10 +320,7 @@ public void preconditions() {
" TestFieldProtoMessage fieldCopy = requireNonNull(field);",
" }",
"}")
.setArgs(
ImmutableList.of(
"-XepOpt:ProtoFieldNullComparison:TrackAssignments",
"-XepOpt:ProtoFieldNullComparison:MatchCheckNotNull"))
.setArgs(ImmutableList.of("-XepOpt:ProtoFieldNullComparison:TrackAssignments"))
.doTest();
}

Expand Down Expand Up @@ -351,27 +348,6 @@ public void assertions() {
.doTest();
}

@Test
public void preconditions_negative() {
compilationHelper
.addSourceLines(
"Test.java",
"import com.google.errorprone.bugpatterns.proto.ProtoTest.TestProtoMessage;",
"import com.google.errorprone.bugpatterns.proto.ProtoTest.TestFieldProtoMessage;",
"import java.util.List;",
"class Test {",
" void test() {",
" TestProtoMessage message = TestProtoMessage.newBuilder().build();",
" TestFieldProtoMessage field = message.getMessage();",
" Preconditions.checkNotNull(field);",
" }",
"}",
"class Preconditions {",
" static void checkNotNull(Object o) {}",
"}")
.doTest();
}

@Test
public void assertions_negative() {
compilationHelper
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit 03200e9

Please sign in to comment.