Compare commits

...

4 Commits

15 changed files with 102 additions and 13 deletions

View File

@@ -5,7 +5,7 @@
<parent>
<groupId>tech.picnic.error-prone-support</groupId>
<artifactId>error-prone-support</artifactId>
<version>0.21.0</version>
<version>0.21.1-SNAPSHOT</version>
</parent>
<artifactId>documentation-support</artifactId>

View File

@@ -5,7 +5,7 @@
<parent>
<groupId>tech.picnic.error-prone-support</groupId>
<artifactId>error-prone-support</artifactId>
<version>0.21.0</version>
<version>0.21.1-SNAPSHOT</version>
</parent>
<artifactId>error-prone-contrib</artifactId>

View File

@@ -0,0 +1,47 @@
package tech.picnic.errorprone.refasterrules;
import com.google.errorprone.refaster.Refaster;
import com.google.errorprone.refaster.annotation.AfterTemplate;
import com.google.errorprone.refaster.annotation.BeforeTemplate;
import org.springframework.test.json.JsonCompareMode;
import org.springframework.test.web.reactive.server.WebTestClient.BodyContentSpec;
import tech.picnic.errorprone.refaster.annotation.OnlineDocumentation;
/** Refaster rules related to Spring Test expressions and statements. */
@OnlineDocumentation
final class SpringTestRules {
private SpringTestRules() {}
/**
* Prefer {@link BodyContentSpec#json(String, JsonCompareMode)} over alternatives that implicitly
* perform a {@link JsonCompareMode#LENIENT lenient} comparison or are deprecated.
*/
static final class BodyContentSpecJsonLenient {
@BeforeTemplate
@SuppressWarnings("deprecation" /* This deprecated method invocation will be rewritten. */)
BodyContentSpec before(BodyContentSpec spec, String expectedJson) {
return Refaster.anyOf(spec.json(expectedJson), spec.json(expectedJson, /* strict= */ false));
}
@AfterTemplate
BodyContentSpec after(BodyContentSpec spec, String expectedJson) {
return spec.json(expectedJson, JsonCompareMode.LENIENT);
}
}
/**
* Prefer {@link BodyContentSpec#json(String, JsonCompareMode)} over the deprecated alternative.
*/
static final class BodyContentSpecJsonStrict {
@BeforeTemplate
@SuppressWarnings("deprecation" /* This deprecated method invocation will be rewritten. */)
BodyContentSpec before(BodyContentSpec spec, String expectedJson) {
return spec.json(expectedJson, /* strict= */ true);
}
@AfterTemplate
BodyContentSpec after(BodyContentSpec spec, String expectedJson) {
return spec.json(expectedJson, JsonCompareMode.STRICT);
}
}
}

View File

@@ -73,6 +73,7 @@ final class RefasterRulesTest {
PrimitiveRules.class,
ReactorRules.class,
RxJava2AdapterRules.class,
SpringTestRules.class,
StreamRules.class,
StringRules.class,
SuggestedFixRules.class,

View File

@@ -0,0 +1,18 @@
package tech.picnic.errorprone.refasterrules;
import com.google.common.collect.ImmutableSet;
import org.springframework.test.web.reactive.server.WebTestClient.BodyContentSpec;
import tech.picnic.errorprone.refaster.test.RefasterRuleCollectionTestCase;
final class SpringTestRulesTest implements RefasterRuleCollectionTestCase {
@SuppressWarnings("deprecation" /* Rule rewrites deprecated method invocation. */)
ImmutableSet<BodyContentSpec> testBodyContentSpecJsonLenient() {
return ImmutableSet.of(
((BodyContentSpec) null).json("foo"), ((BodyContentSpec) null).json("bar", false));
}
@SuppressWarnings("deprecation" /* Rule rewrites deprecated method invocation. */)
BodyContentSpec testBodyContentSpecJsonStrict() {
return ((BodyContentSpec) null).json("foo", true);
}
}

View File

@@ -0,0 +1,20 @@
package tech.picnic.errorprone.refasterrules;
import com.google.common.collect.ImmutableSet;
import org.springframework.test.json.JsonCompareMode;
import org.springframework.test.web.reactive.server.WebTestClient.BodyContentSpec;
import tech.picnic.errorprone.refaster.test.RefasterRuleCollectionTestCase;
final class SpringTestRulesTest implements RefasterRuleCollectionTestCase {
@SuppressWarnings("deprecation" /* Rule rewrites deprecated method invocation. */)
ImmutableSet<BodyContentSpec> testBodyContentSpecJsonLenient() {
return ImmutableSet.of(
((BodyContentSpec) null).json("foo", JsonCompareMode.LENIENT),
((BodyContentSpec) null).json("bar", JsonCompareMode.LENIENT));
}
@SuppressWarnings("deprecation" /* Rule rewrites deprecated method invocation. */)
BodyContentSpec testBodyContentSpecJsonStrict() {
return ((BodyContentSpec) null).json("foo", JsonCompareMode.STRICT);
}
}

View File

@@ -5,7 +5,7 @@
<parent>
<groupId>tech.picnic.error-prone-support</groupId>
<artifactId>error-prone-support</artifactId>
<version>0.21.0</version>
<version>0.21.1-SNAPSHOT</version>
</parent>
<artifactId>error-prone-experimental</artifactId>

View File

@@ -5,7 +5,7 @@
<parent>
<groupId>tech.picnic.error-prone-support</groupId>
<artifactId>error-prone-support</artifactId>
<version>0.21.0</version>
<version>0.21.1-SNAPSHOT</version>
</parent>
<artifactId>error-prone-guidelines</artifactId>

View File

@@ -5,7 +5,7 @@
<parent>
<groupId>tech.picnic.error-prone-support</groupId>
<artifactId>error-prone-support</artifactId>
<version>0.21.0</version>
<version>0.21.1-SNAPSHOT</version>
</parent>
<artifactId>error-prone-utils</artifactId>

View File

@@ -4,7 +4,7 @@
<groupId>tech.picnic.error-prone-support</groupId>
<artifactId>error-prone-support</artifactId>
<version>0.21.0</version>
<version>0.21.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Picnic :: Error Prone Support</name>
@@ -52,7 +52,7 @@
<scm child.scm.developerConnection.inherit.append.path="false" child.scm.url.inherit.append.path="false">
<developerConnection>scm:git:git@github.com:PicnicSupermarket/error-prone-support.git</developerConnection>
<tag>v0.21.0</tag>
<tag>HEAD</tag>
<url>https://github.com/PicnicSupermarket/error-prone-support</url>
</scm>
<issueManagement>
@@ -146,7 +146,7 @@
<error-prone.self-check-args />
<!-- The build timestamp is derived from the most recent commit
timestamp in support of reproducible builds. -->
<project.build.outputTimestamp>2025-03-24T10:36:40Z</project.build.outputTimestamp>
<project.build.outputTimestamp>2025-03-24T10:41:07Z</project.build.outputTimestamp>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- Glob pattern identifying Refaster rule definition files. These
Java classes don't contain "regular" code, and thus require special
@@ -213,7 +213,7 @@
<version.maven>3.9.9</version.maven>
<version.mockito>5.16.1</version.mockito>
<version.nopen-checker>1.0.1</version.nopen-checker>
<version.nullaway>0.12.4</version.nullaway>
<version.nullaway>0.12.5</version.nullaway>
<version.pitest-git>2.2.0</version.pitest-git>
<version.rewrite-templating>1.24.1</version.rewrite-templating>
<version.surefire>3.2.3</version.surefire>

View File

@@ -5,7 +5,7 @@
<parent>
<groupId>tech.picnic.error-prone-support</groupId>
<artifactId>error-prone-support</artifactId>
<version>0.21.0</version>
<version>0.21.1-SNAPSHOT</version>
</parent>
<artifactId>refaster-compiler</artifactId>

View File

@@ -5,7 +5,7 @@
<parent>
<groupId>tech.picnic.error-prone-support</groupId>
<artifactId>error-prone-support</artifactId>
<version>0.21.0</version>
<version>0.21.1-SNAPSHOT</version>
</parent>
<artifactId>refaster-runner</artifactId>

View File

@@ -5,7 +5,7 @@
<parent>
<groupId>tech.picnic.error-prone-support</groupId>
<artifactId>error-prone-support</artifactId>
<version>0.21.0</version>
<version>0.21.1-SNAPSHOT</version>
</parent>
<artifactId>refaster-support</artifactId>

View File

@@ -5,7 +5,7 @@
<parent>
<groupId>tech.picnic.error-prone-support</groupId>
<artifactId>error-prone-support</artifactId>
<version>0.21.0</version>
<version>0.21.1-SNAPSHOT</version>
</parent>
<artifactId>refaster-test-support</artifactId>

View File

@@ -1,6 +1,9 @@
# An overview of Error Prone Support releases, along with compatible Error
# Prone releases. This data was generated by `generate-version-compatibility-overview.sh`.
releases:
- version: 0.21.0
compatible:
- "2.37.0"
- version: 0.20.0
compatible:
- "2.36.0"