From 91fad126f40fa9b6f072c56a0aa87fb5a6491d40 Mon Sep 17 00:00:00 2001 From: Philip Leonard Date: Fri, 26 May 2023 14:47:56 +0200 Subject: [PATCH] Drop enumeration of Mongo core in `ThirdPartyLibrary` --- .../bugpatterns/MongoFullTextSearchQueryUsage.java | 4 +--- .../bugpatterns/util/ThirdPartyLibrary.java | 10 ---------- .../bugpatterns/util/ThirdPartyLibraryTest.java | 14 ++++++-------- 3 files changed, 7 insertions(+), 21 deletions(-) diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/MongoFullTextSearchQueryUsage.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/MongoFullTextSearchQueryUsage.java index 4b7db6bbbbc..703ef11c6fd 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/MongoFullTextSearchQueryUsage.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/MongoFullTextSearchQueryUsage.java @@ -15,7 +15,6 @@ import com.google.errorprone.matchers.Matcher; import com.sun.source.tree.ExpressionTree; import com.sun.source.tree.MethodInvocationTree; -import tech.picnic.errorprone.bugpatterns.util.ThirdPartyLibrary; /** * A {@link BugChecker} that flags usages of Mongo $text filters used for full text searches. @@ -41,8 +40,7 @@ public MongoFullTextSearchQueryUsage() {} @Override public Description matchMethodInvocation(MethodInvocationTree tree, VisitorState state) { - if (!ThirdPartyLibrary.MONGO.isIntroductionAllowed(state) - || !TEXT_FILTER_INVOCATION.matches(tree, state)) { + if (!TEXT_FILTER_INVOCATION.matches(tree, state)) { return Description.NO_MATCH; } return describeMatch(tree); diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/util/ThirdPartyLibrary.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/util/ThirdPartyLibrary.java index 29384aa6445..9138797020a 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/util/ThirdPartyLibrary.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/util/ThirdPartyLibrary.java @@ -33,16 +33,6 @@ public enum ThirdPartyLibrary { */ GUAVA("com.google.common.collect.ImmutableList"), - /** - * Mongo's Java driver Filters API. - * - * @see MongoDB - * Filters API - * @see MongoDB Java drvier - */ - MONGO("com.mongodb.client.model.Filters"), - /** * New Relic's Java agent API. * diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/util/ThirdPartyLibraryTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/util/ThirdPartyLibraryTest.java index 417a443b36f..053dc76f17d 100644 --- a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/util/ThirdPartyLibraryTest.java +++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/util/ThirdPartyLibraryTest.java @@ -23,7 +23,7 @@ void isIntroductionAllowed() { CompilationTestHelper.newInstance(TestChecker.class, getClass()) .addSourceLines( "A.java", - "// BUG: Diagnostic contains: ASSERTJ: true, GUAVA: true, MONGO: true, NEW_RELIC_AGENT_API: true,", + "// BUG: Diagnostic contains: ASSERTJ: true, GUAVA: true, NEW_RELIC_AGENT_API: true,", "// REACTOR: true", "class A {}") .doTest(); @@ -35,18 +35,16 @@ void isIntroductionAllowedWitnessClassesInSymtab() { .addSourceLines( "A.java", "import com.google.common.collect.ImmutableList;", - "import com.mongodb.client.model.Filters;", "import com.newrelic.api.agent.Agent;", "import org.assertj.core.api.Assertions;", "import reactor.core.publisher.Flux;", "", - "// BUG: Diagnostic contains: ASSERTJ: true, GUAVA: true, MONGO: true, NEW_RELIC_AGENT_API: true,", + "// BUG: Diagnostic contains: ASSERTJ: true, GUAVA: true, NEW_RELIC_AGENT_API: true,", "// REACTOR: true", "class A {", " void m(Class clazz) {", " m(Assertions.class);", " m(ImmutableList.class);", - " m(Filters.class);", " m(Agent.class);", " m(Flux.class);", " }", @@ -60,7 +58,7 @@ void isIntroductionAllowedWitnessClassesPartiallyOnClassPath() { .withClasspath(ImmutableList.class, Flux.class) .addSourceLines( "A.java", - "// BUG: Diagnostic contains: ASSERTJ: false, GUAVA: true, MONGO: false, NEW_RELIC_AGENT_API: false,", + "// BUG: Diagnostic contains: ASSERTJ: false, GUAVA: true, NEW_RELIC_AGENT_API: false,", "// REACTOR: true", "class A {}") .doTest(); @@ -72,7 +70,7 @@ void isIntroductionAllowedWitnessClassesNotOnClassPath() { .withClasspath() .addSourceLines( "A.java", - "// BUG: Diagnostic contains: ASSERTJ: false, GUAVA: false, MONGO: false, NEW_RELIC_AGENT_API: false,", + "// BUG: Diagnostic contains: ASSERTJ: false, GUAVA: false, NEW_RELIC_AGENT_API: false,", "// REACTOR:", "// false", "class A {}") @@ -88,8 +86,8 @@ void isIntroductionAllowedIgnoreClasspathCompat(boolean ignoreClassPath) { .addSourceLines( "A.java", String.format( - "// BUG: Diagnostic contains: ASSERTJ: %s, GUAVA: true, MONGO: %s, NEW_RELIC_AGENT_API: %s, REACTOR: true", - ignoreClassPath, ignoreClassPath, ignoreClassPath), + "// BUG: Diagnostic contains: ASSERTJ: %s, GUAVA: true, NEW_RELIC_AGENT_API: %s, REACTOR: true", + ignoreClassPath, ignoreClassPath), "class A {}") .doTest(); }