Skip to content

Commit

Permalink
Drop enumeration of Mongo core in ThirdPartyLibrary
Browse files Browse the repository at this point in the history
  • Loading branch information
philleonard committed May 26, 2023
1 parent a9c90bb commit 8242ea9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,6 @@ public enum ThirdPartyLibrary {
*/
GUAVA("com.google.common.collect.ImmutableList"),

/**
* Mongo's Java driver Filters API.
*
* @see <a
* href="https://github.com/mongodb/mongo-java-driver/blob/master/driver-core/src/main/com/mongodb/client/model/Filters.java">MongoDB
* Filters API</a>
* @see <a href="https://mongodb.github.io/mongo-java-driver/">MongoDB Java drvier</a>
*/
MONGO("com.mongodb.client.model.Filters"),

/**
* New Relic's Java agent API.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);",
" }",
Expand All @@ -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();
Expand All @@ -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 {}")
Expand All @@ -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();
}
Expand Down

0 comments on commit 8242ea9

Please sign in to comment.