mirror of
https://github.com/jlengrand/error-prone-support.git
synced 2026-03-10 08:11:25 +00:00
Compare commits
2 Commits
v0.17.0
...
werli/mong
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c7c1a3d0ed | ||
|
|
c7606e893e |
@@ -174,10 +174,15 @@
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mongodb</groupId>
|
||||
<artifactId>bson</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mongodb</groupId>
|
||||
<artifactId>mongodb-driver-core</artifactId>
|
||||
<scope>test</scope>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openrewrite</groupId>
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package tech.picnic.errorprone.refasterrules;
|
||||
|
||||
import static com.google.errorprone.refaster.ImportPolicy.STATIC_IMPORT_ALWAYS;
|
||||
import static com.mongodb.client.model.Filters.eq;
|
||||
|
||||
import com.google.errorprone.refaster.annotation.AfterTemplate;
|
||||
import com.google.errorprone.refaster.annotation.BeforeTemplate;
|
||||
import com.google.errorprone.refaster.annotation.UseImportPolicy;
|
||||
import com.mongodb.client.model.Filters;
|
||||
import org.bson.conversions.Bson;
|
||||
import tech.picnic.errorprone.refaster.annotation.OnlineDocumentation;
|
||||
|
||||
/** Refaster rules related to MongoDB client expressions and statements. */
|
||||
@OnlineDocumentation
|
||||
final class MongoDBRules {
|
||||
private MongoDBRules() {}
|
||||
|
||||
/** Avoid {@link Enum#toString()} invocations when invoking {@link Filters#eq(String, Object)}. */
|
||||
static final class Eq {
|
||||
@BeforeTemplate
|
||||
Bson before(String field, Enum<?> value) {
|
||||
return eq(field, value.toString());
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
@UseImportPolicy(STATIC_IMPORT_ALWAYS)
|
||||
Bson after(String field, Enum<?> value) {
|
||||
return eq(field, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -59,6 +59,7 @@ final class RefasterRulesTest {
|
||||
MapEntryRules.class,
|
||||
MapRules.class,
|
||||
MockitoRules.class,
|
||||
MongoDBRules.class,
|
||||
MultimapRules.class,
|
||||
NullRules.class,
|
||||
OptionalRules.class,
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package tech.picnic.errorprone.refasterrules;
|
||||
|
||||
import static com.mongodb.client.model.Filters.eq;
|
||||
|
||||
import org.bson.conversions.Bson;
|
||||
import tech.picnic.errorprone.refaster.test.RefasterRuleCollectionTestCase;
|
||||
import tech.picnic.errorprone.utils.ThirdPartyLibrary;
|
||||
|
||||
final class MongoDBRulesTest implements RefasterRuleCollectionTestCase {
|
||||
Bson testEq() {
|
||||
return eq("foo", ThirdPartyLibrary.GUAVA.toString());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package tech.picnic.errorprone.refasterrules;
|
||||
|
||||
import static com.mongodb.client.model.Filters.eq;
|
||||
|
||||
import org.bson.conversions.Bson;
|
||||
import tech.picnic.errorprone.refaster.test.RefasterRuleCollectionTestCase;
|
||||
import tech.picnic.errorprone.utils.ThirdPartyLibrary;
|
||||
|
||||
final class MongoDBRulesTest implements RefasterRuleCollectionTestCase {
|
||||
Bson testEq() {
|
||||
return eq("foo", ThirdPartyLibrary.GUAVA);
|
||||
}
|
||||
}
|
||||
8
pom.xml
8
pom.xml
@@ -214,6 +214,7 @@
|
||||
<version.jdk>17</version.jdk>
|
||||
<version.maven>3.9.5</version.maven>
|
||||
<version.mockito>5.12.0</version.mockito>
|
||||
<version.mongodb>5.1.0</version.mongodb>
|
||||
<version.nopen-checker>1.0.1</version.nopen-checker>
|
||||
<version.nullaway>0.11.0</version.nullaway>
|
||||
<version.pitest-git>1.1.4</version.pitest-git>
|
||||
@@ -463,10 +464,15 @@
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mongodb</groupId>
|
||||
<artifactId>bson</artifactId>
|
||||
<version>${version.mongodb}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mongodb</groupId>
|
||||
<artifactId>mongodb-driver-core</artifactId>
|
||||
<version>5.1.0</version>
|
||||
<version>${version.mongodb}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openrewrite</groupId>
|
||||
|
||||
Reference in New Issue
Block a user