From c5fb53d725eeac68970f84204936027a1bfe406d Mon Sep 17 00:00:00 2001 From: Picnic-Bot Date: Wed, 20 Mar 2024 10:59:23 +0100 Subject: [PATCH 001/312] Upgrade Guava 33.0.0-jre -> 33.1.0-jre (#1086) See: - https://guava.dev/releases/33.1.0-jre/api/diffs/ - https://github.com/google/guava/releases/tag/v33.1.0 - https://github.com/google/guava/compare/v33.0.0...v33.1.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 9194b9f7..1c35d657 100644 --- a/pom.xml +++ b/pom.xml @@ -338,7 +338,7 @@ com.google.guava guava-bom - 33.0.0-jre + 33.1.0-jre pom import From 6914dae822f17ff5effcd6758bcca137e8828050 Mon Sep 17 00:00:00 2001 From: Picnic-Bot Date: Wed, 20 Mar 2024 17:46:13 +0100 Subject: [PATCH 002/312] Upgrade swagger-annotations 1.6.13 -> 1.6.14 (#1100) See: - https://github.com/swagger-api/swagger-core/releases/tag/v1.6.13 - https://github.com/swagger-api/swagger-core/compare/v1.6.12...v1.6.13 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 1c35d657..256770dd 100644 --- a/pom.xml +++ b/pom.xml @@ -372,7 +372,7 @@ io.swagger swagger-annotations - 1.6.13 + 1.6.14 io.swagger.core.v3 From b166d0daea1ff307929b707219c3b0fc4e0a0058 Mon Sep 17 00:00:00 2001 From: Stephan Schroevers Date: Thu, 21 Mar 2024 07:31:07 +0100 Subject: [PATCH 003/312] Update Error Prone compatibility matrix (#1092) While there, improve the generation script. --- website/_data/compatibility.yml | 28 ++++++++++++++ ...generate-version-compatibility-overview.sh | 37 +++++++++++++++---- 2 files changed, 58 insertions(+), 7 deletions(-) diff --git a/website/_data/compatibility.yml b/website/_data/compatibility.yml index 3e2d10d4..29ddbe66 100644 --- a/website/_data/compatibility.yml +++ b/website/_data/compatibility.yml @@ -1,8 +1,36 @@ # 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.16.1 + compatible: + - "2.26.1" + - "2.26.0" + - "2.25.0" + - "2.24.1" + - "2.24.0" + - "2.23.0" + - version: 0.16.0 + compatible: + - "2.26.1" + - "2.26.0" + - "2.25.0" + - "2.24.1" + - "2.24.0" + - "2.23.0" + - version: 0.15.0 + compatible: + - "2.26.1" + - "2.26.0" + - "2.25.0" + - "2.24.1" + - "2.24.0" + - "2.23.0" - version: 0.14.0 compatible: + - "2.26.1" + - "2.26.0" + - "2.25.0" + - "2.24.1" - "2.24.0" - "2.23.0" - "2.22.0" diff --git a/website/generate-version-compatibility-overview.sh b/website/generate-version-compatibility-overview.sh index b4db15c5..ad29e4db 100755 --- a/website/generate-version-compatibility-overview.sh +++ b/website/generate-version-compatibility-overview.sh @@ -10,15 +10,21 @@ source "${HOME}/.sdkman/bin/sdkman-init.sh" set -e -u -o pipefail +# Currently all released Error Prone Support versions are compatible with Java +# 17. +java_version=17.0.10-tem +(set +u && echo n | sdk install java "${java_version}") +sdk use java "${java_version}" + output_file="$(dirname "${0}")/_data/compatibility.yml" -ep_versions=$( +ep_versions="$( git ls-remote \ --exit-code --refs --sort='-v:refname' \ https://github.com/google/error-prone.git \ 'v*.*' \ | grep -oP '(?<=/v)[^/]+$' -) +)" work_dir="$(mktemp -d)" trap 'rm -rf -- "${work_dir=}"' INT TERM HUP EXIT @@ -39,26 +45,43 @@ for eps_version in ${eps_versions}; do (set +u && echo n | sdk install maven "${mvn_version}") sdk use maven "${mvn_version}" + # Collect the list of checks supported by this version of Error Prone + # Support. + # XXX: Conditionally omit the `MethodReferenceUsage` exclusion once that + # check is production-ready. + mvn clean compile -Dverification.skip -DskipTests + checks="$( + find \ + -path "*/META-INF/services/com.google.errorprone.bugpatterns.BugChecker" \ + -not -path "*/error-prone-experimental/*" \ + -not -path "*/error-prone-guidelines/*" \ + -print0 \ + | xargs -0 grep -hoP '[^.]+$' \ + | grep -v '^MethodReferenceUsage$' \ + | paste -s -d ',' - + )" + # Remove any Error Prone flags used by this build that may not be compatible # with the targeted version of Error Prone. Removal of these build flags does # not influence the compatibility assessment. sed -i -r 's,-XepAllSuggestionsAsWarnings|-Xep:\w+:\w+,,g' pom.xml # Using each Error Prone release, attempt to build and test the source, while - # also applying the Maven Central-hosted Refaster rules. This determines - # source and behavioral (in)compatibility with Error Prone APIs, while also - # assessing whether the Refaster rules are deserialization-compatible. + # also applying the Maven Central-hosted Error Prone Support-defined checks + # and Refaster rules. This determines source and behavioral (in)compatibility + # with Error Prone APIs, while also assessing whether the Refaster rules are + # deserialization-compatible. for ep_version in ${ep_versions}; do echo "Testing Error Prone Support ${eps_version} with Error Prone ${ep_version}..." mvn clean test \ -Perror-prone \ - -Derror-prone.patch-checks=Refaster \ + -Derror-prone.patch-checks="${checks}" \ -Ppatch \ -Pself-check \ -Dverification.skip \ -Dversion.error-prone-orig="${ep_version}" \ && echo "SUCCESS: { \"eps_version\": \"${eps_version}\", \"ep_version\": \"${ep_version}\" }" || true - # Undo any changes applied by Refaster. + # Undo any changes applied by the checks. git checkout -- '*.java' done done | tee "${build_log}" From 63bc903f8371c84fe67a2137dade8dda2a0d6872 Mon Sep 17 00:00:00 2001 From: Picnic-Bot Date: Thu, 21 Mar 2024 08:17:04 +0100 Subject: [PATCH 004/312] Upgrade Spring Security 6.2.2 -> 6.2.3 (#1093) See: - https://github.com/spring-projects/spring-security/releases/tag/6.2.3 - https://github.com/spring-projects/spring-security/compare/6.2.2...6.2.3 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 256770dd..41dbbbb2 100644 --- a/pom.xml +++ b/pom.xml @@ -502,7 +502,7 @@ org.springframework.security spring-security-bom - 6.2.2 + 6.2.3 pom import From 0b696b95b645e7e2499c41dbdce5d9e4e78572d2 Mon Sep 17 00:00:00 2001 From: Picnic-Bot Date: Thu, 21 Mar 2024 10:39:37 +0100 Subject: [PATCH 005/312] Upgrade maven-compiler-plugin 3.12.1 -> 3.13.0 (#1101) See: - https://github.com/apache/maven-compiler-plugin/releases/tag/maven-compiler-plugin-3.13.0 - https://github.com/apache/maven-compiler-plugin/compare/maven-compiler-plugin-3.12.1...maven-compiler-plugin-3.13.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 41dbbbb2..7ef3d2d4 100644 --- a/pom.xml +++ b/pom.xml @@ -916,7 +916,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.12.1 + 3.13.0 From 4708fec20126648f6a7caec8b03504949275ab67 Mon Sep 17 00:00:00 2001 From: Picnic-Bot Date: Wed, 10 Apr 2024 15:10:21 +0200 Subject: [PATCH 033/312] Upgrade TestNG 7.10.0 -> 7.10.1 (#1131) See: - https://github.com/testng-team/testng/releases/tag/7.10.1 - https://github.com/testng-team/testng/compare/7.10.0...7.10.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 92ea44f9..40d80d7d 100644 --- a/pom.xml +++ b/pom.xml @@ -509,7 +509,7 @@ org.testng testng - 7.10.0 + 7.10.1 From 9e230302e931669f42f97cb2a70da4ce9aadf6a6 Mon Sep 17 00:00:00 2001 From: Picnic-Bot Date: Thu, 11 Apr 2024 09:46:18 +0200 Subject: [PATCH 034/312] Upgrade Project Reactor 2023.0.4 -> 2023.0.5 (#1130) See: - https://github.com/reactor/reactor/releases/tag/2023.0.5 - https://github.com/reactor/reactor/compare/2023.0.4...2023.0.5 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 40d80d7d..3f250397 100644 --- a/pom.xml +++ b/pom.xml @@ -360,7 +360,7 @@ io.projectreactor reactor-bom - 2023.0.4 + 2023.0.5 pom import From 032109756dfad0efd2e60d7b77ac26df687e9287 Mon Sep 17 00:00:00 2001 From: Picnic-Bot Date: Mon, 15 Apr 2024 07:36:02 +0200 Subject: [PATCH 035/312] Upgrade SLF4J 2.0.12 -> 2.0.13 (#1136) See: - https://www.slf4j.org/news.html - https://github.com/qos-ch/slf4j/compare/v_2.0.12...v_2.0.13 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 3f250397..4943ebd7 100644 --- a/pom.xml +++ b/pom.xml @@ -483,7 +483,7 @@ org.slf4j slf4j-bom - 2.0.12 + 2.0.13 pom import From eb84ddf5007369cf1f417ab54ef52e52e7c7e29d Mon Sep 17 00:00:00 2001 From: Picnic-Bot Date: Mon, 15 Apr 2024 07:44:29 +0200 Subject: [PATCH 036/312] Upgrade maven-gpg-plugin 3.2.2 -> 3.2.3 (#1134) See: - https://github.com/apache/maven-gpg-plugin/releases/tag/maven-gpg-plugin-3.2.3 - https://github.com/apache/maven-gpg-plugin/compare/maven-gpg-plugin-3.2.2...maven-gpg-plugin-3.2.3 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4943ebd7..52f05a12 100644 --- a/pom.xml +++ b/pom.xml @@ -1068,7 +1068,7 @@ org.apache.maven.plugins maven-gpg-plugin - 3.2.2 + 3.2.3 sign-artifacts From 7118d6bf03ecdffdb2432491fb3f5ba16bb70ec9 Mon Sep 17 00:00:00 2001 From: Picnic-Bot Date: Mon, 15 Apr 2024 08:32:41 +0200 Subject: [PATCH 037/312] Upgrade Spring 6.1.5 -> 6.1.6 (#1133) See: - https://github.com/spring-projects/spring-framework/releases/tag/v6.1.6 - https://github.com/spring-projects/spring-framework/compare/v6.1.5...v6.1.6 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 52f05a12..f60372dc 100644 --- a/pom.xml +++ b/pom.xml @@ -490,7 +490,7 @@ org.springframework spring-framework-bom - 6.1.5 + 6.1.6 pom import From 7be27614da2d73633dad98aed6f4f73c4943c9f8 Mon Sep 17 00:00:00 2001 From: Picnic-Bot Date: Mon, 15 Apr 2024 08:45:16 +0200 Subject: [PATCH 038/312] Upgrade maven-jar-plugin 3.3.0 -> 3.4.0 (#1137) See: - https://github.com/apache/maven-jar-plugin/releases/tag/maven-jar-plugin-3.4.0 - https://github.com/apache/maven-jar-plugin/compare/maven-jar-plugin-3.3.0...maven-jar-plugin-3.4.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f60372dc..c38754e0 100644 --- a/pom.xml +++ b/pom.xml @@ -1086,7 +1086,7 @@ org.apache.maven.plugins maven-jar-plugin - 3.3.0 + 3.4.0 true From 4558f8affb04ec1180f4a7a6a62de41a3b1066e0 Mon Sep 17 00:00:00 2001 From: Stephan Schroevers Date: Tue, 16 Apr 2024 17:04:48 +0200 Subject: [PATCH 039/312] Update `FluxTake` Refaster rule for Reactor 3.5.0+ (#1128) --- .../refasterrules/ReactorRules.java | 21 ++++++------------- .../refasterrules/ReactorRulesTestInput.java | 2 +- .../refasterrules/ReactorRulesTestOutput.java | 2 +- 3 files changed, 8 insertions(+), 17 deletions(-) diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/ReactorRules.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/ReactorRules.java index 57cb55a6..21ca2d4a 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/ReactorRules.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/ReactorRules.java @@ -3,7 +3,6 @@ package tech.picnic.errorprone.refasterrules; import static com.google.common.collect.ImmutableList.toImmutableList; import static com.google.common.collect.ImmutableSet.toImmutableSet; import static com.google.common.collect.MoreCollectors.toOptional; -import static com.google.errorprone.BugPattern.SeverityLevel.WARNING; import static com.google.errorprone.refaster.ImportPolicy.STATIC_IMPORT_ALWAYS; import static java.util.Comparator.naturalOrder; import static java.util.Comparator.reverseOrder; @@ -52,7 +51,6 @@ import reactor.util.context.Context; import reactor.util.function.Tuple2; import tech.picnic.errorprone.refaster.annotation.Description; import tech.picnic.errorprone.refaster.annotation.OnlineDocumentation; -import tech.picnic.errorprone.refaster.annotation.Severity; import tech.picnic.errorprone.refaster.matchers.IsEmpty; import tech.picnic.errorprone.refaster.matchers.IsIdentityOperation; import tech.picnic.errorprone.refaster.matchers.ThrowsCheckedException; @@ -380,30 +378,23 @@ final class ReactorRules { } /** - * Prefer {@link Flux#take(long, boolean)} over {@link Flux#take(long)}. + * Prefer {@link Flux#take(long)} over {@link Flux#take(long, boolean)} where relevant. * *

In Reactor versions prior to 3.5.0, {@code Flux#take(long)} makes an unbounded request - * upstream, and is equivalent to {@code Flux#take(long, false)}. In 3.5.0, the behavior of {@code - * Flux#take(long)} will change to that of {@code Flux#take(long, true)}. - * - *

The intent with this Refaster rule is to get the new behavior before upgrading to Reactor - * 3.5.0. + * upstream, and is equivalent to {@code Flux#take(long, false)}. From version 3.5.0 onwards, the + * behavior of {@code Flux#take(long)} instead matches {@code Flux#take(long, true)}. */ - // XXX: Drop this rule some time after upgrading to Reactor 3.6.0, or introduce a way to apply - // this rule only when an older version of Reactor is on the classpath. - // XXX: Once Reactor 3.6.0 is out, introduce a rule that rewrites code in the opposite direction. @Description( - "Prior to Reactor 3.5.0, `take(n)` requests and unbounded number of elements upstream.") - @Severity(WARNING) + "From Reactor 3.5.0 onwards, `take(n)` no longer requests an unbounded number of elements upstream.") static final class FluxTake { @BeforeTemplate Flux before(Flux flux, long n) { - return flux.take(n); + return flux.take(n, /* limitRequest= */ true); } @AfterTemplate Flux after(Flux flux, long n) { - return flux.take(n, /* limitRequest= */ true); + return flux.take(n); } } diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ReactorRulesTestInput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ReactorRulesTestInput.java index f2f04dc3..300c70e8 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ReactorRulesTestInput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ReactorRulesTestInput.java @@ -142,7 +142,7 @@ final class ReactorRulesTest implements RefasterRuleCollectionTestCase { } Flux testFluxTake() { - return Flux.just(1, 2, 3).take(1); + return Flux.just(1, 2, 3).take(1, true); } Mono testMonoDefaultIfEmpty() { diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ReactorRulesTestOutput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ReactorRulesTestOutput.java index 6bfd98f9..a8751ff1 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ReactorRulesTestOutput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ReactorRulesTestOutput.java @@ -147,7 +147,7 @@ final class ReactorRulesTest implements RefasterRuleCollectionTestCase { } Flux testFluxTake() { - return Flux.just(1, 2, 3).take(1, true); + return Flux.just(1, 2, 3).take(1); } Mono testMonoDefaultIfEmpty() { From 5fad0ea04fb8f9d1f40afaa2bc05ba710c040f66 Mon Sep 17 00:00:00 2001 From: Picnic-Bot Date: Wed, 17 Apr 2024 08:01:53 +0200 Subject: [PATCH 040/312] Upgrade Spring Security 6.2.3 -> 6.2.4 (#1140) See: - https://github.com/spring-projects/spring-security/releases/tag/6.2.4 - https://github.com/spring-projects/spring-security/compare/6.2.3...6.2.4 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c38754e0..c180d619 100644 --- a/pom.xml +++ b/pom.xml @@ -502,7 +502,7 @@ org.springframework.security spring-security-bom - 6.2.3 + 6.2.4 pom import From 8f5faf0f6a813c0ed9244391ad04a0ab8bf208ed Mon Sep 17 00:00:00 2001 From: Picnic-Bot Date: Fri, 19 Apr 2024 09:55:53 +0200 Subject: [PATCH 041/312] Upgrade OpenRewrite Templating 1.6.3 -> 1.6.4 (#1142) See: - https://github.com/openrewrite/rewrite-templating/releases/tag/v1.6.4 - https://github.com/openrewrite/rewrite-templating/compare/v1.6.3...v1.6.4 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c180d619..e8ad7985 100644 --- a/pom.xml +++ b/pom.xml @@ -217,7 +217,7 @@ 1.0.1 0.10.25 1.1.4 - 1.6.3 + 1.6.4 3.2.3 From eb36c1e4933530e8973e31356f4a84c1dc52d258 Mon Sep 17 00:00:00 2001 From: Picnic-Bot Date: Fri, 19 Apr 2024 10:14:36 +0200 Subject: [PATCH 042/312] Upgrade actions/upload-artifact v4.3.1 -> v4.3.2 (#1143) See: - https://github.com/actions/upload-artifact/releases/tag/v4.3.2 --- .github/workflows/pitest-analyze-pr.yml | 2 +- .github/workflows/run-integration-tests.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pitest-analyze-pr.yml b/.github/workflows/pitest-analyze-pr.yml index d0763aeb..e1ba6132 100644 --- a/.github/workflows/pitest-analyze-pr.yml +++ b/.github/workflows/pitest-analyze-pr.yml @@ -36,7 +36,7 @@ jobs: - name: Aggregate Pitest reports run: mvn pitest-git:aggregate -DkilledEmoji=":tada:" -DmutantEmoji=":zombie:" -DtrailingText="Mutation testing report by [Pitest](https://pitest.org/). Review any surviving mutants by inspecting the line comments under [_Files changed_](${{ github.event.number }}/files)." - name: Upload Pitest reports as artifact - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 + uses: actions/upload-artifact@1746f4ab65b179e0ea60a494b83293b640dd5bba # v4.3.2 with: name: pitest-reports path: ./target/pit-reports-ci diff --git a/.github/workflows/run-integration-tests.yml b/.github/workflows/run-integration-tests.yml index 6776c89b..0d5d73e5 100644 --- a/.github/workflows/run-integration-tests.yml +++ b/.github/workflows/run-integration-tests.yml @@ -43,7 +43,7 @@ jobs: run: xvfb-run ./integration-tests/checkstyle.sh "${{ runner.temp }}/artifacts" - name: Upload artifacts on failure if: ${{ failure() }} - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 + uses: actions/upload-artifact@1746f4ab65b179e0ea60a494b83293b640dd5bba # v4.3.2 with: name: integration-test-checkstyle path: "${{ runner.temp }}/artifacts" From 6669a2e1ecabdc860ac93ab293b78ddecbd1a0fc Mon Sep 17 00:00:00 2001 From: Picnic-Bot Date: Sat, 20 Apr 2024 13:37:38 +0200 Subject: [PATCH 043/312] Upgrade Spring Boot 3.2.4 -> 3.2.5 (#1144) See: - https://github.com/spring-projects/spring-boot/releases/tag/v3.2.5 - https://github.com/spring-projects/spring-boot/compare/v3.2.4...v3.2.5 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e8ad7985..5bb7d281 100644 --- a/pom.xml +++ b/pom.xml @@ -497,7 +497,7 @@ org.springframework.boot spring-boot-test - 3.2.4 + 3.2.5 org.springframework.security From 0367037f0a267e40782d8ec6f7c5b0522cf984c1 Mon Sep 17 00:00:00 2001 From: Picnic-Bot Date: Mon, 22 Apr 2024 07:30:17 +0200 Subject: [PATCH 044/312] Upgrade ruby/setup-ruby v1.173.0 -> v1.174.0 (#1148) See: - https://github.com/ruby/setup-ruby/releases/tag/v1.174.0 --- .github/workflows/deploy-website.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy-website.yml b/.github/workflows/deploy-website.yml index 51bb64b1..1f8d0abe 100644 --- a/.github/workflows/deploy-website.yml +++ b/.github/workflows/deploy-website.yml @@ -42,7 +42,7 @@ jobs: uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 with: persist-credentials: false - - uses: ruby/setup-ruby@5f19ec79cedfadb78ab837f95b87734d0003c899 # v1.173.0 + - uses: ruby/setup-ruby@6bd3d993c602f6b675728ebaecb2b569ff86e99b # v1.174.0 with: working-directory: ./website bundler-cache: true From 85cb7ffdb1816fd6f2988c19c06ead9ec68b4d67 Mon Sep 17 00:00:00 2001 From: Picnic-Bot Date: Mon, 22 Apr 2024 07:44:09 +0200 Subject: [PATCH 045/312] Upgrade CodeQL v3.24.9 -> v3.25.1 (#1147) See: - https://github.com/github/codeql-action/blob/main/CHANGELOG.md - https://github.com/github/codeql-action/compare/v3.25.0...v3.25.1 - https://github.com/github/codeql-action/compare/v3.24.10...v3.25.0 - https://github.com/github/codeql-action/compare/v3.24.9...v3.24.10 --- .github/workflows/codeql.yml | 4 ++-- .github/workflows/openssf-scorecard.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 1f6158d2..c09c9e75 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -39,13 +39,13 @@ jobs: java-distribution: temurin maven-version: 3.9.6 - name: Initialize CodeQL - uses: github/codeql-action/init@1b1aada464948af03b950897e5eb522f92603cc2 # v3.24.9 + uses: github/codeql-action/init@c7f9125735019aa87cfc361530512d50ea439c71 # v3.25.1 with: languages: ${{ matrix.language }} - name: Perform minimal build if: matrix.language == 'java' run: mvn -T1C clean package -DskipTests -Dverification.skip - name: Perform CodeQL analysis - uses: github/codeql-action/analyze@1b1aada464948af03b950897e5eb522f92603cc2 # v3.24.9 + uses: github/codeql-action/analyze@c7f9125735019aa87cfc361530512d50ea439c71 # v3.25.1 with: category: /language:${{ matrix.language }} diff --git a/.github/workflows/openssf-scorecard.yml b/.github/workflows/openssf-scorecard.yml index 0f634f41..1e6e35e4 100644 --- a/.github/workflows/openssf-scorecard.yml +++ b/.github/workflows/openssf-scorecard.yml @@ -46,6 +46,6 @@ jobs: results_format: sarif publish_results: ${{ github.ref == 'refs/heads/master' }} - name: Update GitHub's code scanning dashboard - uses: github/codeql-action/upload-sarif@1b1aada464948af03b950897e5eb522f92603cc2 # v3.24.9 + uses: github/codeql-action/upload-sarif@c7f9125735019aa87cfc361530512d50ea439c71 # v3.25.1 with: sarif_file: results.sarif From 01687c7f3e61c4cfe559ddfe160163509a852746 Mon Sep 17 00:00:00 2001 From: Picnic-Bot Date: Mon, 22 Apr 2024 08:50:57 +0200 Subject: [PATCH 046/312] Upgrade maven-gpg-plugin 3.2.3 -> 3.2.4 (#1145) See: - https://github.com/apache/maven-gpg-plugin/releases/tag/maven-gpg-plugin-3.2.4 - https://github.com/apache/maven-gpg-plugin/compare/maven-gpg-plugin-3.2.3...maven-gpg-plugin-3.2.4 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5bb7d281..5dc34b91 100644 --- a/pom.xml +++ b/pom.xml @@ -1068,7 +1068,7 @@ org.apache.maven.plugins maven-gpg-plugin - 3.2.3 + 3.2.4 sign-artifacts From d47549d68f61f9baa5261745d6d7920515fc51e3 Mon Sep 17 00:00:00 2001 From: Picnic-Bot Date: Mon, 22 Apr 2024 13:05:52 +0200 Subject: [PATCH 047/312] Upgrade maven-jar-plugin 3.4.0 -> 3.4.1 (#1146) See: - https://github.com/apache/maven-jar-plugin/releases/tag/maven-jar-plugin-3.4.1 - https://github.com/apache/maven-jar-plugin/compare/maven-jar-plugin-3.4.0...maven-jar-plugin-3.4.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5dc34b91..03738d56 100644 --- a/pom.xml +++ b/pom.xml @@ -1086,7 +1086,7 @@ org.apache.maven.plugins maven-jar-plugin - 3.4.0 + 3.4.1 true From 271e01a02ccae0b575338bd255b660b8b1f0d8ba Mon Sep 17 00:00:00 2001 From: Picnic-Bot Date: Tue, 23 Apr 2024 10:48:35 +0200 Subject: [PATCH 048/312] Upgrade actions/checkout v4.1.1 -> v4.1.3 (#1149) See: - https://github.com/actions/checkout/releases/tag/v4.1.3 - https://github.com/actions/checkout/blob/HEAD/CHANGELOG.md#v412 --- .github/workflows/deploy-website.yml | 2 +- .github/workflows/openssf-scorecard.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-website.yml b/.github/workflows/deploy-website.yml index 1f8d0abe..4ff0265a 100644 --- a/.github/workflows/deploy-website.yml +++ b/.github/workflows/deploy-website.yml @@ -39,7 +39,7 @@ jobs: www.youtube.com:443 youtrack.jetbrains.com:443 - name: Check out code - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4.1.3 with: persist-credentials: false - uses: ruby/setup-ruby@6bd3d993c602f6b675728ebaecb2b569ff86e99b # v1.174.0 diff --git a/.github/workflows/openssf-scorecard.yml b/.github/workflows/openssf-scorecard.yml index 1e6e35e4..318d6dfc 100644 --- a/.github/workflows/openssf-scorecard.yml +++ b/.github/workflows/openssf-scorecard.yml @@ -36,7 +36,7 @@ jobs: tuf-repo-cdn.sigstore.dev:443 www.bestpractices.dev:443 - name: Check out code - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4.1.3 with: persist-credentials: false - name: Run OpenSSF Scorecard analysis From 72c5a42feb3d75a622ea5222e322fd4cc2e6b43a Mon Sep 17 00:00:00 2001 From: Picnic-Bot Date: Tue, 23 Apr 2024 11:24:02 +0200 Subject: [PATCH 049/312] Upgrade actions/upload-artifact v4.3.2 -> v4.3.3 (#1150) See: - https://github.com/actions/upload-artifact/releases/tag/v4.3.3 --- .github/workflows/pitest-analyze-pr.yml | 2 +- .github/workflows/run-integration-tests.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pitest-analyze-pr.yml b/.github/workflows/pitest-analyze-pr.yml index e1ba6132..cd9dd8a7 100644 --- a/.github/workflows/pitest-analyze-pr.yml +++ b/.github/workflows/pitest-analyze-pr.yml @@ -36,7 +36,7 @@ jobs: - name: Aggregate Pitest reports run: mvn pitest-git:aggregate -DkilledEmoji=":tada:" -DmutantEmoji=":zombie:" -DtrailingText="Mutation testing report by [Pitest](https://pitest.org/). Review any surviving mutants by inspecting the line comments under [_Files changed_](${{ github.event.number }}/files)." - name: Upload Pitest reports as artifact - uses: actions/upload-artifact@1746f4ab65b179e0ea60a494b83293b640dd5bba # v4.3.2 + uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 with: name: pitest-reports path: ./target/pit-reports-ci diff --git a/.github/workflows/run-integration-tests.yml b/.github/workflows/run-integration-tests.yml index 0d5d73e5..b559f539 100644 --- a/.github/workflows/run-integration-tests.yml +++ b/.github/workflows/run-integration-tests.yml @@ -43,7 +43,7 @@ jobs: run: xvfb-run ./integration-tests/checkstyle.sh "${{ runner.temp }}/artifacts" - name: Upload artifacts on failure if: ${{ failure() }} - uses: actions/upload-artifact@1746f4ab65b179e0ea60a494b83293b640dd5bba # v4.3.2 + uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 with: name: integration-test-checkstyle path: "${{ runner.temp }}/artifacts" From ef4e004141dae199add742ed5d84fc59a89a4f0a Mon Sep 17 00:00:00 2001 From: Picnic-Bot Date: Thu, 25 Apr 2024 09:09:49 +0200 Subject: [PATCH 050/312] Upgrade Byte Buddy 1.14.13 -> 1.14.14 (#1151) See: - https://github.com/raphw/byte-buddy/releases/tag/byte-buddy-1.14.14 - https://github.com/raphw/byte-buddy/compare/byte-buddy-1.14.13...byte-buddy-1.14.14 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 03738d56..bbcab3de 100644 --- a/pom.xml +++ b/pom.xml @@ -407,7 +407,7 @@ net.bytebuddy byte-buddy - 1.14.13 + 1.14.14 From f089157443aa121e73b310a0274ae9220c6c07ae Mon Sep 17 00:00:00 2001 From: Picnic-DevPla-Bot <168541957+Picnic-DevPla-Bot@users.noreply.github.com> Date: Sat, 11 May 2024 14:59:23 +0200 Subject: [PATCH 070/312] Upgrade Byte Buddy 1.14.14 -> 1.14.15 (#1169) See: - https://github.com/raphw/byte-buddy/releases/tag/byte-buddy-1.14.15 - https://github.com/raphw/byte-buddy/compare/byte-buddy-1.14.14...byte-buddy-1.14.15 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 8e5d70b7..2c23f0e3 100644 --- a/pom.xml +++ b/pom.xml @@ -407,7 +407,7 @@ net.bytebuddy byte-buddy - 1.14.14 + 1.14.15 1.1.1 - 1.10.4 + 1.11.0 ${version.error-prone-orig} v${version.error-prone-orig}-picnic-1 2.27.1 From 01f139b6a4e66fa49b1c67370152c4047d7137e5 Mon Sep 17 00:00:00 2001 From: Picnic-DevPla-Bot <168541957+Picnic-DevPla-Bot@users.noreply.github.com> Date: Tue, 4 Jun 2024 13:37:52 +0200 Subject: [PATCH 097/312] Upgrade NullAway 0.10.26 -> 0.11.0 (#1204) See: - https://github.com/uber/NullAway/blob/master/CHANGELOG.md - https://github.com/uber/NullAway/releases/tag/v0.11.0 - https://github.com/uber/NullAway/compare/v0.10.26...v0.11.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 7b902762..6cb306f0 100644 --- a/pom.xml +++ b/pom.xml @@ -215,7 +215,7 @@ 3.9.5 5.12.0 1.0.1 - 0.10.26 + 0.11.0 1.1.4 1.9.2 3.2.3 From 29f1a3d2a65424edbc2cb89c63ddf6571890a982 Mon Sep 17 00:00:00 2001 From: Picnic-DevPla-Bot <168541957+Picnic-DevPla-Bot@users.noreply.github.com> Date: Tue, 4 Jun 2024 13:56:07 +0200 Subject: [PATCH 098/312] Upgrade maven-enforcer-plugin 3.4.1 -> 3.5.0 (#1201) See: - https://github.com/apache/maven-enforcer/releases/tag/enforcer-3.5.0 - https://github.com/apache/maven-enforcer/compare/enforcer-3.4.1...enforcer-3.5.0 --- pom.xml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 6cb306f0..da39e6ee 100644 --- a/pom.xml +++ b/pom.xml @@ -987,7 +987,7 @@ org.apache.maven.plugins maven-enforcer-plugin - 3.4.1 + 3.5.0 false @@ -1042,6 +1042,9 @@ ${version.jdk} + + true + ${version.maven} From 539fcae745c271ecbe2a4814fd67f0af59be71fd Mon Sep 17 00:00:00 2001 From: Picnic-DevPla-Bot <168541957+Picnic-DevPla-Bot@users.noreply.github.com> Date: Tue, 4 Jun 2024 14:47:57 +0200 Subject: [PATCH 099/312] Upgrade maven-javadoc-plugin 3.6.3 -> 3.7.0 (#1205) See: - https://issues.apache.org/jira/issues/?jql=project%20%3D%20MJAVADOC%20AND%20fixVersion%20%3E%203.6.3%20AND%20fixVersion%20%3C%3D%203.7.0 - https://github.com/apache/maven-javadoc-plugin/releases/tag/maven-javadoc-plugin-3.7.0 - https://github.com/apache/maven-javadoc-plugin/compare/maven-javadoc-plugin-3.6.3...maven-javadoc-plugin-3.7.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index da39e6ee..bf102c62 100644 --- a/pom.xml +++ b/pom.xml @@ -1118,7 +1118,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.6.3 + 3.7.0 --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED From f6a392e118ed210a99306d6695fd6b46ea5fe5c8 Mon Sep 17 00:00:00 2001 From: Picnic-DevPla-Bot <168541957+Picnic-DevPla-Bot@users.noreply.github.com> Date: Tue, 4 Jun 2024 16:39:05 +0200 Subject: [PATCH 100/312] Upgrade Guava 33.2.0-jre -> 33.2.1-jre (#1202) See: - https://guava.dev/releases/33.2.1-jre/api/diffs/ - https://github.com/google/guava/releases/tag/v33.2.1 - https://github.com/google/guava/compare/v33.2.0...v33.2.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index bf102c62..16c3704f 100644 --- a/pom.xml +++ b/pom.xml @@ -338,7 +338,7 @@ com.google.guava guava-bom - 33.2.0-jre + 33.2.1-jre pom import From 85976e199f8040edc5ba09aabb45ab6542370476 Mon Sep 17 00:00:00 2001 From: Picnic-DevPla-Bot <168541957+Picnic-DevPla-Bot@users.noreply.github.com> Date: Wed, 5 Jun 2024 09:20:12 +0200 Subject: [PATCH 101/312] Upgrade Checker Framework Annotations 3.43.0 -> 3.44.0 (#1207) See: - https://github.com/typetools/checker-framework/releases/tag/checker-framework-3.44.0 - https://github.com/typetools/checker-framework/compare/checker-framework-3.43.0...checker-framework-3.44.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 16c3704f..fe7b618a 100644 --- a/pom.xml +++ b/pom.xml @@ -432,7 +432,7 @@ org.checkerframework checker-qual - 3.43.0 + 3.44.0 org.hamcrest From b658c19c03c05ef022b0ca48da66e56eae38801a Mon Sep 17 00:00:00 2001 From: Picnic-Bot Date: Wed, 5 Jun 2024 09:42:42 +0200 Subject: [PATCH 102/312] Upgrade Spring Boot 3.2.5 -> 3.3.0 (#1196) See: - https://github.com/spring-projects/spring-boot/releases/tag/v3.2.6 - https://github.com/spring-projects/spring-boot/releases/tag/v3.3.0-M1 - https://github.com/spring-projects/spring-boot/releases/tag/v3.3.0-M2 - https://github.com/spring-projects/spring-boot/releases/tag/v3.3.0-M3 - https://github.com/spring-projects/spring-boot/releases/tag/v3.3.0-RC1 - https://github.com/spring-projects/spring-boot/releases/tag/v3.3.0 - https://github.com/spring-projects/spring-boot/compare/v3.2.5...v3.3.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index fe7b618a..1777856c 100644 --- a/pom.xml +++ b/pom.xml @@ -497,7 +497,7 @@ org.springframework.boot spring-boot-test - 3.2.5 + 3.3.0 org.springframework.security From 8c8055d381a55a885b454526b02e56d4b3890f13 Mon Sep 17 00:00:00 2001 From: Picnic-DevPla-Bot <168541957+Picnic-DevPla-Bot@users.noreply.github.com> Date: Fri, 7 Jun 2024 11:08:31 +0200 Subject: [PATCH 103/312] Upgrade maven-checkstyle-plugin 3.3.1 -> 3.4.0 (#1208) See https://github.com/apache/maven-checkstyle-plugin/compare/maven-checkstyle-plugin-3.3.1...maven-checkstyle-plugin-3.4.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 1777856c..09f3efe4 100644 --- a/pom.xml +++ b/pom.xml @@ -643,7 +643,7 @@ org.apache.maven.plugins maven-checkstyle-plugin - 3.3.1 + 3.4.0 GPL-2.0-with-classpath-exception | CDDL/GPLv2+CE + | CDDL + GPLv2 with classpath exception | GNU General Public License, version 2 (GPL2), with the classpath exception | GNU General Public License, version 2, with the Classpath Exception | GPL2 w/ CPE diff --git a/refaster-runner/pom.xml b/refaster-runner/pom.xml index ddacd89c..d7c40e1d 100644 --- a/refaster-runner/pom.xml +++ b/refaster-runner/pom.xml @@ -58,6 +58,11 @@ guava provided + + javax.annotation + javax.annotation-api + test + javax.inject javax.inject diff --git a/refaster-test-support/pom.xml b/refaster-test-support/pom.xml index 0bbfb907..e1b2d699 100644 --- a/refaster-test-support/pom.xml +++ b/refaster-test-support/pom.xml @@ -50,6 +50,11 @@ com.google.guava guava + + javax.annotation + javax.annotation-api + test + javax.inject javax.inject From 4eb0aae4527dad6335938a79b9e7f21c404530e1 Mon Sep 17 00:00:00 2001 From: Picnic-DevPla-Bot <168541957+Picnic-DevPla-Bot@users.noreply.github.com> Date: Sat, 20 Jul 2024 14:09:49 +0200 Subject: [PATCH 152/312] Upgrade versions-maven-plugin 2.17.0 -> 2.17.1 (#1250) See: - https://github.com/mojohaus/versions/releases/tag/2.17.1 - https://github.com/mojohaus/versions-maven-plugin/compare/2.17.0...2.17.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index cc224266..9f0253c4 100644 --- a/pom.xml +++ b/pom.xml @@ -1353,7 +1353,7 @@ org.codehaus.mojo versions-maven-plugin - 2.17.0 + 2.17.1 never From 5a163ce2e9856b14d507fe7791d49163c5d13ce6 Mon Sep 17 00:00:00 2001 From: Stephan Schroevers Date: Sat, 20 Jul 2024 14:15:43 +0200 Subject: [PATCH 153/312] [maven-release-plugin] prepare release v0.17.0 --- documentation-support/pom.xml | 2 +- error-prone-contrib/pom.xml | 2 +- error-prone-experimental/pom.xml | 2 +- error-prone-guidelines/pom.xml | 2 +- error-prone-utils/pom.xml | 2 +- pom.xml | 6 +++--- refaster-compiler/pom.xml | 2 +- refaster-runner/pom.xml | 2 +- refaster-support/pom.xml | 2 +- refaster-test-support/pom.xml | 2 +- 10 files changed, 12 insertions(+), 12 deletions(-) diff --git a/documentation-support/pom.xml b/documentation-support/pom.xml index 373b2ce9..1da6ef30 100644 --- a/documentation-support/pom.xml +++ b/documentation-support/pom.xml @@ -5,7 +5,7 @@ tech.picnic.error-prone-support error-prone-support - 0.16.2-SNAPSHOT + 0.17.0 documentation-support diff --git a/error-prone-contrib/pom.xml b/error-prone-contrib/pom.xml index f8bb856d..be51c654 100644 --- a/error-prone-contrib/pom.xml +++ b/error-prone-contrib/pom.xml @@ -5,7 +5,7 @@ tech.picnic.error-prone-support error-prone-support - 0.16.2-SNAPSHOT + 0.17.0 error-prone-contrib diff --git a/error-prone-experimental/pom.xml b/error-prone-experimental/pom.xml index 965e0875..9eaf5376 100644 --- a/error-prone-experimental/pom.xml +++ b/error-prone-experimental/pom.xml @@ -5,7 +5,7 @@ tech.picnic.error-prone-support error-prone-support - 0.16.2-SNAPSHOT + 0.17.0 error-prone-experimental diff --git a/error-prone-guidelines/pom.xml b/error-prone-guidelines/pom.xml index a283915f..883d51cf 100644 --- a/error-prone-guidelines/pom.xml +++ b/error-prone-guidelines/pom.xml @@ -5,7 +5,7 @@ tech.picnic.error-prone-support error-prone-support - 0.16.2-SNAPSHOT + 0.17.0 error-prone-guidelines diff --git a/error-prone-utils/pom.xml b/error-prone-utils/pom.xml index 5b7fedb1..6c621f1a 100644 --- a/error-prone-utils/pom.xml +++ b/error-prone-utils/pom.xml @@ -5,7 +5,7 @@ tech.picnic.error-prone-support error-prone-support - 0.16.2-SNAPSHOT + 0.17.0 error-prone-utils diff --git a/pom.xml b/pom.xml index 9f0253c4..17cdb46f 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ tech.picnic.error-prone-support error-prone-support - 0.16.2-SNAPSHOT + 0.17.0 pom Picnic :: Error Prone Support @@ -52,7 +52,7 @@ scm:git:git@github.com:PicnicSupermarket/error-prone-support.git - HEAD + v0.17.0 https://github.com/PicnicSupermarket/error-prone-support @@ -148,7 +148,7 @@ com.google.errorprone - 2024-03-15T12:04:44Z + 2024-07-20T12:12:19Z UTF-8 - 2024-07-20T12:12:19Z + 2024-07-20T12:15:43Z UTF-8 false + + + + compile-recipes + + compile + + + + + -Xlint:-options + + 8 + 8 + + **/*Recipes.java + + ${project.build.directory}/openrewrite-recipes + + + org.apache.maven.plugins @@ -1112,6 +1144,39 @@ + + default-jar + + jar + + + + + **/*Recipe$*.class + **/*Recipe.class + **/*Recipes.class + + + + + + create-openrewrite-recipes-jar + + jar + + + ${project.build.directory}/openrewrite-recipes + recipes + + **/*Recipe$*.class + **/*Recipe.class + **/*Recipes.class + + + create-test-jar From 635fe280f8cf1c9feb1607ddc3dcda08acf97077 Mon Sep 17 00:00:00 2001 From: Picnic-DevPla-Bot <168541957+Picnic-DevPla-Bot@users.noreply.github.com> Date: Fri, 9 Aug 2024 09:49:34 +0200 Subject: [PATCH 168/312] Upgrade OpenRewrite Templating 1.12.1 -> 1.12.3 (#1273) See: - https://github.com/openrewrite/rewrite-templating/releases/tag/v1.12.2 - https://github.com/openrewrite/rewrite-templating/releases/tag/v1.12.3 - https://github.com/openrewrite/rewrite-templating/compare/v1.12.1...v1.12.3 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 857a9eff..3a1cdab9 100644 --- a/pom.xml +++ b/pom.xml @@ -217,7 +217,7 @@ 1.0.1 0.11.1 1.1.4 - 1.12.1 + 1.12.3 3.2.3 From 32ec35a354c33514b54ba460c1af50841c9033d2 Mon Sep 17 00:00:00 2001 From: Picnic-DevPla-Bot <168541957+Picnic-DevPla-Bot@users.noreply.github.com> Date: Fri, 9 Aug 2024 14:37:40 +0200 Subject: [PATCH 169/312] Upgrade SLF4J 2.0.13 -> 2.0.15 (#1272) See: - https://www.slf4j.org/news.html - https://github.com/qos-ch/slf4j/compare/v_2.0.13...v_2.0.15 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 3a1cdab9..b13e4074 100644 --- a/pom.xml +++ b/pom.xml @@ -488,7 +488,7 @@ org.slf4j slf4j-bom - 2.0.13 + 2.0.15 pom import From 363b0c22c7a1c2a7d6f30bf7837bfe36cfbe1870 Mon Sep 17 00:00:00 2001 From: Mohamed Sameh <110535847+mohamedsamehsalah@users.noreply.github.com> Date: Sat, 10 Aug 2024 16:49:44 +0200 Subject: [PATCH 170/312] Introduce `ArraysAsList` Refaster rule (#1275) --- .../refasterrules/CollectionRules.java | 20 +++++++++++++++++++ .../CollectionRulesTestInput.java | 6 ++++++ .../CollectionRulesTestOutput.java | 6 ++++++ 3 files changed, 32 insertions(+) diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/CollectionRules.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/CollectionRules.java index ecbc7e51..4ee37189 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/CollectionRules.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/CollectionRules.java @@ -8,7 +8,9 @@ import com.google.errorprone.refaster.Refaster; import com.google.errorprone.refaster.annotation.AfterTemplate; import com.google.errorprone.refaster.annotation.AlsoNegation; import com.google.errorprone.refaster.annotation.BeforeTemplate; +import com.google.errorprone.refaster.annotation.NotMatches; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; import java.util.Iterator; import java.util.List; @@ -21,6 +23,7 @@ import java.util.function.Consumer; import java.util.function.IntFunction; import java.util.stream.Stream; import tech.picnic.errorprone.refaster.annotation.OnlineDocumentation; +import tech.picnic.errorprone.refaster.matchers.IsRefasterAsVarargs; /** Refaster rules related to expressions dealing with (arbitrary) collections. */ // XXX: There are other Guava `Iterables` methods that should not be called if the input is known to @@ -294,6 +297,23 @@ final class CollectionRules { } } + /** Prefer {@link Arrays#asList(Object[])} over more contrived alternatives. */ + // XXX: Consider moving this rule to `ImmutableListRules` and having it suggest + // `ImmutableList#copyOf`. That would retain immutability, at the cost of no longer handling + // `null`s. + static final class ArraysAsList { + // XXX: This expression produces an unmodifiable list, while the alternative doesn't. + @BeforeTemplate + List before(@NotMatches(IsRefasterAsVarargs.class) T[] array) { + return Arrays.stream(array).toList(); + } + + @AfterTemplate + List after(T[] array) { + return Arrays.asList(array); + } + } + /** Prefer calling {@link Collection#toArray()} over more contrived alternatives. */ static final class CollectionToArray { @BeforeTemplate diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/CollectionRulesTestInput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/CollectionRulesTestInput.java index 2968c3a0..c667a808 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/CollectionRulesTestInput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/CollectionRulesTestInput.java @@ -6,9 +6,11 @@ import com.google.common.collect.ImmutableSortedSet; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedList; +import java.util.List; import java.util.Optional; import java.util.TreeSet; import java.util.stream.Stream; @@ -98,6 +100,10 @@ final class CollectionRulesTest implements RefasterRuleCollectionTestCase { return ImmutableSet.of(1).asList().toString(); } + List testArraysAsList() { + return Arrays.stream(new String[0]).toList(); + } + ImmutableSet testCollectionToArray() { return ImmutableSet.of( ImmutableSet.of(1).toArray(new Object[1]), diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/CollectionRulesTestOutput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/CollectionRulesTestOutput.java index 1eb0abc0..756135c8 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/CollectionRulesTestOutput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/CollectionRulesTestOutput.java @@ -6,9 +6,11 @@ import com.google.common.collect.ImmutableSortedSet; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedList; +import java.util.List; import java.util.Optional; import java.util.TreeSet; import java.util.stream.Stream; @@ -90,6 +92,10 @@ final class CollectionRulesTest implements RefasterRuleCollectionTestCase { return ImmutableSet.of(1).toString(); } + List testArraysAsList() { + return Arrays.asList(new String[0]); + } + ImmutableSet testCollectionToArray() { return ImmutableSet.of( ImmutableSet.of(1).toArray(), ImmutableSet.of(2).toArray(), ImmutableSet.of(3).toArray()); From fdf9bb5d2586e4afb25d6a3e11da95cb0e8a8e08 Mon Sep 17 00:00:00 2001 From: Stephan Schroevers Date: Sat, 10 Aug 2024 23:13:23 +0200 Subject: [PATCH 171/312] Make the build JDK 22-compatible (#1277) And verify the build with JDK 22.0.2. --- .github/workflows/build.yml | 2 +- .../refaster/plugin/RefasterRuleCompilerTaskListener.java | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 888d6cfc..0a11222c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,7 +10,7 @@ jobs: strategy: matrix: os: [ ubuntu-22.04 ] - jdk: [ 17.0.10, 21.0.2 ] + jdk: [ 17.0.10, 21.0.2, 22.0.2 ] distribution: [ temurin ] experimental: [ false ] include: diff --git a/refaster-compiler/src/main/java/tech/picnic/errorprone/refaster/plugin/RefasterRuleCompilerTaskListener.java b/refaster-compiler/src/main/java/tech/picnic/errorprone/refaster/plugin/RefasterRuleCompilerTaskListener.java index dbef9d0e..e9cd1a44 100644 --- a/refaster-compiler/src/main/java/tech/picnic/errorprone/refaster/plugin/RefasterRuleCompilerTaskListener.java +++ b/refaster-compiler/src/main/java/tech/picnic/errorprone/refaster/plugin/RefasterRuleCompilerTaskListener.java @@ -21,7 +21,6 @@ import com.sun.tools.javac.code.Symbol.ClassSymbol; import com.sun.tools.javac.code.Symbol.PackageSymbol; import com.sun.tools.javac.main.JavaCompiler; import com.sun.tools.javac.util.Context; -import com.sun.tools.javac.util.Name; import java.io.IOException; import java.io.ObjectOutput; import java.io.ObjectOutputStream; @@ -137,10 +136,10 @@ final class RefasterRuleCompilerTaskListener implements TaskListener { return enclosingPackage == null ? "" : enclosingPackage.toString(); } - private static CharSequence toSimpleFlatName(ClassSymbol symbol) { - Name flatName = symbol.flatName(); + private static String toSimpleFlatName(ClassSymbol symbol) { + String flatName = symbol.flatName().toString(); int lastDot = flatName.lastIndexOf((byte) '.'); - return lastDot < 0 ? flatName : flatName.subSequence(lastDot + 1, flatName.length()); + return lastDot < 0 ? flatName : flatName.substring(lastDot + 1); } private static void outputCodeTransformer(CodeTransformer codeTransformer, FileObject target) From a868b03130ba4522a42549d008adff73b22415ea Mon Sep 17 00:00:00 2001 From: Picnic-DevPla-Bot <168541957+Picnic-DevPla-Bot@users.noreply.github.com> Date: Sun, 11 Aug 2024 12:11:31 +0200 Subject: [PATCH 172/312] Upgrade SLF4J 2.0.15 -> 2.0.16 (#1279) See: - https://www.slf4j.org/news.html - https://github.com/qos-ch/slf4j/compare/v_2.0.15...v_2.0.16 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b13e4074..0e3eeab4 100644 --- a/pom.xml +++ b/pom.xml @@ -488,7 +488,7 @@ org.slf4j slf4j-bom - 2.0.15 + 2.0.16 pom import From 5b6dd147ef4b970b7b1d04fa2d99ad11b0100e1a Mon Sep 17 00:00:00 2001 From: Picnic-DevPla-Bot <168541957+Picnic-DevPla-Bot@users.noreply.github.com> Date: Sun, 11 Aug 2024 12:23:58 +0200 Subject: [PATCH 173/312] Upgrade MongoDB driver 5.1.2 -> 5.1.3 (#1274) See: - https://jira.mongodb.org/issues/?jql=project%20%3D%20JAVA%20AND%20fixVersion%20%3E%204.11.2%20AND%20fixVersion%20%3C%3D%204.11.3 - https://github.com/mongodb/mongo-java-driver/releases/tag/r4.11.3 - https://github.com/mongodb/mongo-java-driver/compare/r4.11.2...r4.11.3 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0e3eeab4..965ba140 100644 --- a/pom.xml +++ b/pom.xml @@ -471,7 +471,7 @@ org.mongodb mongodb-driver-core - 5.1.2 + 5.1.3 org.openrewrite From 366cdda3d8ad84b9b1870621d845a14bcb9eac87 Mon Sep 17 00:00:00 2001 From: Picnic-DevPla-Bot <168541957+Picnic-DevPla-Bot@users.noreply.github.com> Date: Sun, 11 Aug 2024 12:48:15 +0200 Subject: [PATCH 174/312] Upgrade Error Prone 2.29.2 -> 2.30.0 (#1280) See: - https://github.com/google/error-prone/releases/tag/v2.30.0 - https://github.com/google/error-prone/compare/v2.29.2...v2.30.0 - https://github.com/PicnicSupermarket/error-prone/compare/v2.29.2-picnic-1...v2.30.0-picnic-1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 965ba140..358c339c 100644 --- a/pom.xml +++ b/pom.xml @@ -208,7 +208,7 @@ 1.11.0 ${version.error-prone-orig} v${version.error-prone-orig}-picnic-1 - 2.29.2 + 2.30.0 0.1.25 1.0 17 From 3d9aab7c5b9776929da49b32d41cdd9400dd1df1 Mon Sep 17 00:00:00 2001 From: Mohamed Sameh <110535847+mohamedsamehsalah@users.noreply.github.com> Date: Sun, 11 Aug 2024 15:01:53 +0200 Subject: [PATCH 175/312] Introduce `Class{Literal,Reference}Cast` Refaster rules (#1269) --- .../errorprone/refasterrules/ClassRules.java | 49 ++++++++++++++++++- .../refasterrules/ClassRulesTestInput.java | 18 +++++-- .../refasterrules/ClassRulesTestOutput.java | 18 +++++-- 3 files changed, 73 insertions(+), 12 deletions(-) diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/ClassRules.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/ClassRules.java index 2890dd1b..496b1f1f 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/ClassRules.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/ClassRules.java @@ -3,6 +3,7 @@ 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 java.util.function.Function; import java.util.function.Predicate; import tech.picnic.errorprone.refaster.annotation.OnlineDocumentation; @@ -37,7 +38,12 @@ final class ClassRules { } } - /** Prefer {@link Class#isInstance(Object)} method references over more verbose alternatives. */ + /** + * Prefer {@link Class#isInstance(Object)} method references over lambda expressions that require + * naming a variable. + */ + // XXX: Once the `ClassReferenceIsInstancePredicate` rule is dropped, rename this rule to just + // `ClassIsInstancePredicate`. static final class ClassLiteralIsInstancePredicate { @BeforeTemplate Predicate before() { @@ -50,7 +56,11 @@ final class ClassRules { } } - /** Prefer {@link Class#isInstance(Object)} method references over more verbose alternatives. */ + /** + * Prefer {@link Class#isInstance(Object)} method references over lambda expressions that require + * naming a variable. + */ + // XXX: Drop this rule once the `MethodReferenceUsage` rule is enabled by default. static final class ClassReferenceIsInstancePredicate { @BeforeTemplate Predicate before(Class clazz) { @@ -62,4 +72,39 @@ final class ClassRules { return clazz::isInstance; } } + + /** + * Prefer {@link Class#cast(Object)} method references over lambda expressions that require naming + * a variable. + */ + // XXX: Once the `ClassReferenceCast` rule is dropped, rename this rule to just `ClassCast`. + static final class ClassLiteralCast { + @BeforeTemplate + @SuppressWarnings("unchecked") + Function before() { + return t -> (S) t; + } + + @AfterTemplate + Function after() { + return Refaster.clazz()::cast; + } + } + + /** + * Prefer {@link Class#cast(Object)} method references over lambda expressions that require naming + * a variable. + */ + // XXX: Drop this rule once the `MethodReferenceUsage` rule is enabled by default. + static final class ClassReferenceCast { + @BeforeTemplate + Function before(Class clazz) { + return o -> clazz.cast(o); + } + + @AfterTemplate + Function after(Class clazz) { + return clazz::cast; + } + } } diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ClassRulesTestInput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ClassRulesTestInput.java index 2e94c242..94f6db36 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ClassRulesTestInput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ClassRulesTestInput.java @@ -1,26 +1,34 @@ package tech.picnic.errorprone.refasterrules; import com.google.common.collect.ImmutableSet; -import java.io.IOException; +import java.util.function.Function; import java.util.function.Predicate; import tech.picnic.errorprone.refaster.test.RefasterRuleCollectionTestCase; final class ClassRulesTest implements RefasterRuleCollectionTestCase { - boolean testClassIsInstance() throws IOException { + boolean testClassIsInstance() { return CharSequence.class.isAssignableFrom("foo".getClass()); } - ImmutableSet testInstanceof() throws IOException { + ImmutableSet testInstanceof() { Class clazz = CharSequence.class; return ImmutableSet.of(CharSequence.class.isInstance("foo"), clazz.isInstance("bar")); } - Predicate testClassLiteralIsInstancePredicate() throws IOException { + Predicate testClassLiteralIsInstancePredicate() { return s -> s instanceof CharSequence; } - Predicate testClassReferenceIsInstancePredicate() throws IOException { + Predicate testClassReferenceIsInstancePredicate() { Class clazz = CharSequence.class; return s -> clazz.isInstance(s); } + + Function testClassLiteralCast() { + return i -> (Integer) i; + } + + Function testClassReferenceCast() { + return i -> Integer.class.cast(i); + } } diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ClassRulesTestOutput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ClassRulesTestOutput.java index 39c08a50..2c431415 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ClassRulesTestOutput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ClassRulesTestOutput.java @@ -1,26 +1,34 @@ package tech.picnic.errorprone.refasterrules; import com.google.common.collect.ImmutableSet; -import java.io.IOException; +import java.util.function.Function; import java.util.function.Predicate; import tech.picnic.errorprone.refaster.test.RefasterRuleCollectionTestCase; final class ClassRulesTest implements RefasterRuleCollectionTestCase { - boolean testClassIsInstance() throws IOException { + boolean testClassIsInstance() { return CharSequence.class.isInstance("foo"); } - ImmutableSet testInstanceof() throws IOException { + ImmutableSet testInstanceof() { Class clazz = CharSequence.class; return ImmutableSet.of("foo" instanceof CharSequence, clazz.isInstance("bar")); } - Predicate testClassLiteralIsInstancePredicate() throws IOException { + Predicate testClassLiteralIsInstancePredicate() { return CharSequence.class::isInstance; } - Predicate testClassReferenceIsInstancePredicate() throws IOException { + Predicate testClassReferenceIsInstancePredicate() { Class clazz = CharSequence.class; return clazz::isInstance; } + + Function testClassLiteralCast() { + return Integer.class::cast; + } + + Function testClassReferenceCast() { + return Integer.class::cast; + } } From b733179cd07edfe770c7380e8b49c4099f83ccf8 Mon Sep 17 00:00:00 2001 From: Stephan Schroevers Date: Sun, 11 Aug 2024 15:05:54 +0200 Subject: [PATCH 176/312] [maven-release-plugin] prepare release v0.18.0 --- documentation-support/pom.xml | 2 +- error-prone-contrib/pom.xml | 2 +- error-prone-experimental/pom.xml | 2 +- error-prone-guidelines/pom.xml | 2 +- error-prone-utils/pom.xml | 2 +- pom.xml | 6 +++--- refaster-compiler/pom.xml | 2 +- refaster-runner/pom.xml | 2 +- refaster-support/pom.xml | 2 +- refaster-test-support/pom.xml | 2 +- 10 files changed, 12 insertions(+), 12 deletions(-) diff --git a/documentation-support/pom.xml b/documentation-support/pom.xml index 9fd518e5..ad0ecfae 100644 --- a/documentation-support/pom.xml +++ b/documentation-support/pom.xml @@ -5,7 +5,7 @@ tech.picnic.error-prone-support error-prone-support - 0.17.1-SNAPSHOT + 0.18.0 documentation-support diff --git a/error-prone-contrib/pom.xml b/error-prone-contrib/pom.xml index 225f1218..58e972d3 100644 --- a/error-prone-contrib/pom.xml +++ b/error-prone-contrib/pom.xml @@ -5,7 +5,7 @@ tech.picnic.error-prone-support error-prone-support - 0.17.1-SNAPSHOT + 0.18.0 error-prone-contrib diff --git a/error-prone-experimental/pom.xml b/error-prone-experimental/pom.xml index 231857cf..e5aafe29 100644 --- a/error-prone-experimental/pom.xml +++ b/error-prone-experimental/pom.xml @@ -5,7 +5,7 @@ tech.picnic.error-prone-support error-prone-support - 0.17.1-SNAPSHOT + 0.18.0 error-prone-experimental diff --git a/error-prone-guidelines/pom.xml b/error-prone-guidelines/pom.xml index 03573f9f..e63b947f 100644 --- a/error-prone-guidelines/pom.xml +++ b/error-prone-guidelines/pom.xml @@ -5,7 +5,7 @@ tech.picnic.error-prone-support error-prone-support - 0.17.1-SNAPSHOT + 0.18.0 error-prone-guidelines diff --git a/error-prone-utils/pom.xml b/error-prone-utils/pom.xml index 2cbdd8d1..c35748ee 100644 --- a/error-prone-utils/pom.xml +++ b/error-prone-utils/pom.xml @@ -5,7 +5,7 @@ tech.picnic.error-prone-support error-prone-support - 0.17.1-SNAPSHOT + 0.18.0 error-prone-utils diff --git a/pom.xml b/pom.xml index 358c339c..8f560f4e 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ tech.picnic.error-prone-support error-prone-support - 0.17.1-SNAPSHOT + 0.18.0 pom Picnic :: Error Prone Support @@ -52,7 +52,7 @@ scm:git:git@github.com:PicnicSupermarket/error-prone-support.git - HEAD + v0.18.0 https://github.com/PicnicSupermarket/error-prone-support @@ -148,7 +148,7 @@ com.google.errorprone - 2024-07-20T12:15:43Z + 2024-08-11T13:04:41Z UTF-8 - 2024-08-11T13:04:41Z + 2024-08-11T13:05:54Z UTF-8 + + + compile-refaster-test-input + + testCompile + + process-test-resources + + + ${project.basedir}/src/test/resources + + + **/*Input.java + + ${project.build.directory}/refaster-test-input + + + + compile-refaster-test-output + + testCompile + + process-test-resources + + + ${project.basedir}/src/test/resources + + + **/*Output.java + + ${project.build.directory}/refaster-test-output + + + diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ImmutableMultisetRulesTestInput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ImmutableMultisetRulesTestInput.java index 96231993..dc462c7e 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ImmutableMultisetRulesTestInput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ImmutableMultisetRulesTestInput.java @@ -26,6 +26,7 @@ final class ImmutableMultisetRulesTest implements RefasterRuleCollectionTestCase Stream.empty().collect(toImmutableMultiset())); } + @SuppressWarnings("unchecked") ImmutableMultiset> testIterableToImmutableMultiset() { return ImmutableMultiset.of( ImmutableList.of(1).stream().collect(toImmutableMultiset()), diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ImmutableMultisetRulesTestOutput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ImmutableMultisetRulesTestOutput.java index 76af043a..3e4c01d0 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ImmutableMultisetRulesTestOutput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ImmutableMultisetRulesTestOutput.java @@ -24,6 +24,7 @@ final class ImmutableMultisetRulesTest implements RefasterRuleCollectionTestCase return ImmutableMultiset.of(ImmutableMultiset.of(), ImmutableMultiset.of()); } + @SuppressWarnings("unchecked") ImmutableMultiset> testIterableToImmutableMultiset() { return ImmutableMultiset.of( ImmutableMultiset.copyOf(ImmutableList.of(1)), diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ImmutableSortedMultisetRulesTestInput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ImmutableSortedMultisetRulesTestInput.java index 36c0b35f..7424a9b6 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ImmutableSortedMultisetRulesTestInput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ImmutableSortedMultisetRulesTestInput.java @@ -37,6 +37,7 @@ final class ImmutableSortedMultisetRulesTest implements RefasterRuleCollectionTe Stream.empty().collect(toImmutableSortedMultiset(naturalOrder()))); } + @SuppressWarnings("unchecked") ImmutableMultiset> testIterableToImmutableSortedMultiset() { return ImmutableMultiset.of( ImmutableSortedMultiset.copyOf(naturalOrder(), ImmutableList.of(1)), diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ImmutableSortedMultisetRulesTestOutput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ImmutableSortedMultisetRulesTestOutput.java index 36fca66a..e430c8da 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ImmutableSortedMultisetRulesTestOutput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ImmutableSortedMultisetRulesTestOutput.java @@ -35,6 +35,7 @@ final class ImmutableSortedMultisetRulesTest implements RefasterRuleCollectionTe return ImmutableMultiset.of(ImmutableSortedMultiset.of(), ImmutableSortedMultiset.of()); } + @SuppressWarnings("unchecked") ImmutableMultiset> testIterableToImmutableSortedMultiset() { return ImmutableMultiset.of( ImmutableSortedMultiset.copyOf(ImmutableList.of(1)), diff --git a/refaster-test-support/src/main/java/tech/picnic/errorprone/refaster/test/RefasterRuleCollection.java b/refaster-test-support/src/main/java/tech/picnic/errorprone/refaster/test/RefasterRuleCollection.java index 77991f09..99673e20 100644 --- a/refaster-test-support/src/main/java/tech/picnic/errorprone/refaster/test/RefasterRuleCollection.java +++ b/refaster-test-support/src/main/java/tech/picnic/errorprone/refaster/test/RefasterRuleCollection.java @@ -61,6 +61,9 @@ import tech.picnic.errorprone.refaster.runner.Refaster; // XXX: This check currently only validates that one `Refaster.anyOf` branch in one // `@BeforeTemplate` method is covered by a test. Review how we can make sure that _all_ // `@BeforeTemplate` methods and `Refaster.anyOf` branches are covered. +// XXX: Look into replacing this setup with another that allows test cases to be co-located +// with/nested within the rules. This way any rule change only requires modifications in a single +// place, rather than in three. @BugPattern(summary = "Exercises a Refaster rule collection", linkType = NONE, severity = ERROR) @SuppressWarnings("java:S2160" /* Super class equality definition suffices. */) public final class RefasterRuleCollection extends BugChecker implements CompilationUnitTreeMatcher { From 26da67d1f53de6585e308551d7ff6cdf59e588fa Mon Sep 17 00:00:00 2001 From: Stephan Schroevers Date: Mon, 16 Sep 2024 08:02:56 +0200 Subject: [PATCH 222/312] Use `rewrite-java-17` rather than `rewrite-java-11` (#1330) --- error-prone-contrib/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/error-prone-contrib/pom.xml b/error-prone-contrib/pom.xml index cc442db2..385f0867 100644 --- a/error-prone-contrib/pom.xml +++ b/error-prone-contrib/pom.xml @@ -201,7 +201,7 @@ org.openrewrite - rewrite-java-11 + rewrite-java-17 test From 3d5ee10d934df7c2de69a20ff39513a6000abc1f Mon Sep 17 00:00:00 2001 From: Stephan Schroevers Date: Mon, 16 Sep 2024 09:15:12 +0200 Subject: [PATCH 223/312] Introduce Refaster rules for Sonar's java:S4635 rule (#1320) As well as two related expressions that can be optimized. See: - https://sonarcloud.io/organizations/picnic-technologies/rules?open=java%3AS4635&rule_key=java%3AS4635 - https://github.com/SonarSource/sonar-java/blob/26157927314eed0105449e8c7bc7e86c34148a83/java-checks/src/main/java/org/sonar/java/checks/StringOffsetMethodsCheck.java --- .../errorprone/refasterrules/StringRules.java | 101 ++++++++++++++++++ .../refasterrules/StringRulesTestInput.java | 28 +++++ .../refasterrules/StringRulesTestOutput.java | 28 +++++ 3 files changed, 157 insertions(+) diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/StringRules.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/StringRules.java index f3610a86..2ae04b74 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/StringRules.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/StringRules.java @@ -244,4 +244,105 @@ final class StringRules { return Utf8.encodedLength(str); } } + + /** Prefer {@link String#indexOf(int, int)} over less efficient alternatives. */ + static final class StringIndexOfChar { + @BeforeTemplate + @SuppressWarnings("java:S4635" /* This violation will be rewritten. */) + int before(String string, int ch, int fromIndex) { + return string.substring(fromIndex).indexOf(ch); + } + + @AfterTemplate + int after(String string, int ch, int fromIndex) { + return Math.max(-1, string.indexOf(ch, fromIndex) - fromIndex); + } + } + + /** Prefer {@link String#indexOf(String, int)} over less efficient alternatives. */ + static final class StringIndexOfString { + @BeforeTemplate + @SuppressWarnings("java:S4635" /* This violation will be rewritten. */) + int before(String string, String substring, int fromIndex) { + return string.substring(fromIndex).indexOf(substring); + } + + @AfterTemplate + int after(String string, String substring, int fromIndex) { + return Math.max(-1, string.indexOf(substring, fromIndex) - fromIndex); + } + } + + // XXX: Once we compile Refaster templates with JDK 21 also suggest `String#indexOf(int, int, + // int)` and `String#indexOf(String, int, int)`. + + /** Prefer {@link String#lastIndexOf(int, int)} over less efficient alternatives. */ + static final class StringLastIndexOfChar { + @BeforeTemplate + @SuppressWarnings("java:S4635" /* This violation will be rewritten. */) + int before(String string, int ch, int fromIndex) { + return string.substring(fromIndex).lastIndexOf(ch); + } + + @AfterTemplate + int after(String string, int ch, int fromIndex) { + return Math.max(-1, string.lastIndexOf(ch) - fromIndex); + } + } + + /** Prefer {@link String#lastIndexOf(String, int)} over less efficient alternatives. */ + static final class StringLastIndexOfString { + @BeforeTemplate + @SuppressWarnings("java:S4635" /* This violation will be rewritten. */) + int before(String string, String substring, int fromIndex) { + return string.substring(fromIndex).lastIndexOf(substring); + } + + @AfterTemplate + int after(String string, String substring, int fromIndex) { + return Math.max(-1, string.lastIndexOf(substring) - fromIndex); + } + } + + /** Prefer {@link String#lastIndexOf(int, int)} over less efficient alternatives. */ + static final class StringLastIndexOfCharWithIndex { + @BeforeTemplate + int before(String string, int ch, int fromIndex) { + return string.substring(0, fromIndex).lastIndexOf(ch); + } + + @AfterTemplate + int after(String string, int ch, int fromIndex) { + return string.lastIndexOf(ch, fromIndex - 1); + } + } + + /** Prefer {@link String#lastIndexOf(String, int)} over less efficient alternatives. */ + // XXX: The replacement expression isn't fully equivalent: in case `substring` is empty, then + // the replacement yields `fromIndex - 1` rather than `fromIndex`. + static final class StringLastIndexOfStringWithIndex { + @BeforeTemplate + int before(String string, String substring, int fromIndex) { + return string.substring(0, fromIndex).lastIndexOf(substring); + } + + @AfterTemplate + int after(String string, String substring, int fromIndex) { + return string.lastIndexOf(substring, fromIndex - 1); + } + } + + /** Prefer {@link String#startsWith(String, int)} over less efficient alternatives. */ + static final class StringStartsWith { + @BeforeTemplate + @SuppressWarnings("java:S4635" /* This violation will be rewritten. */) + boolean before(String string, String prefix, int fromIndex) { + return string.substring(fromIndex).startsWith(prefix); + } + + @AfterTemplate + boolean after(String string, String prefix, int fromIndex) { + return string.startsWith(prefix, fromIndex); + } + } } diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/StringRulesTestInput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/StringRulesTestInput.java index a6b2f1cb..39476e36 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/StringRulesTestInput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/StringRulesTestInput.java @@ -96,4 +96,32 @@ final class StringRulesTest implements RefasterRuleCollectionTestCase { int testUtf8EncodedLength() { return "foo".getBytes(UTF_8).length; } + + int testStringIndexOfChar() { + return "foo".substring(1).indexOf('a'); + } + + int testStringIndexOfString() { + return "foo".substring(1).indexOf("bar"); + } + + int testStringLastIndexOfChar() { + return "foo".substring(1).lastIndexOf('a'); + } + + int testStringLastIndexOfString() { + return "foo".substring(1).lastIndexOf("bar"); + } + + int testStringLastIndexOfCharWithIndex() { + return "foo".substring(0, 2).lastIndexOf('a'); + } + + int testStringLastIndexOfStringWithIndex() { + return "foo".substring(0, 2).lastIndexOf("bar"); + } + + boolean testStringStartsWith() { + return "foo".substring(1).startsWith("bar"); + } } diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/StringRulesTestOutput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/StringRulesTestOutput.java index d5e1241a..7973d10d 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/StringRulesTestOutput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/StringRulesTestOutput.java @@ -96,4 +96,32 @@ final class StringRulesTest implements RefasterRuleCollectionTestCase { int testUtf8EncodedLength() { return Utf8.encodedLength("foo"); } + + int testStringIndexOfChar() { + return Math.max(-1, "foo".indexOf('a', 1) - 1); + } + + int testStringIndexOfString() { + return Math.max(-1, "foo".indexOf("bar", 1) - 1); + } + + int testStringLastIndexOfChar() { + return Math.max(-1, "foo".lastIndexOf('a') - 1); + } + + int testStringLastIndexOfString() { + return Math.max(-1, "foo".lastIndexOf("bar") - 1); + } + + int testStringLastIndexOfCharWithIndex() { + return "foo".lastIndexOf('a', 2 - 1); + } + + int testStringLastIndexOfStringWithIndex() { + return "foo".lastIndexOf("bar", 2 - 1); + } + + boolean testStringStartsWith() { + return "foo".startsWith("bar", 1); + } } From f821d3775b887c57efc86c44c4f6685cc49f0c15 Mon Sep 17 00:00:00 2001 From: Picnic-DevPla-Bot <168541957+Picnic-DevPla-Bot@users.noreply.github.com> Date: Tue, 17 Sep 2024 10:48:58 +0200 Subject: [PATCH 224/312] Upgrade NullAway 0.11.2 -> 0.11.3 (#1332) See: - https://github.com/uber/NullAway/blob/master/CHANGELOG.md - https://github.com/uber/NullAway/releases/tag/v0.11.3 - https://github.com/uber/NullAway/compare/v0.11.2...v0.11.3 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 1bae20f6..71f89647 100644 --- a/pom.xml +++ b/pom.xml @@ -215,7 +215,7 @@ 3.9.9 5.13.0 1.0.1 - 0.11.2 + 0.11.3 1.1.4 1.14.1 3.2.3 From e74874b04c02bc0d2c5af7981ace4a678be5356e Mon Sep 17 00:00:00 2001 From: Picnic-DevPla-Bot <168541957+Picnic-DevPla-Bot@users.noreply.github.com> Date: Tue, 17 Sep 2024 11:17:35 +0200 Subject: [PATCH 225/312] Upgrade OpenRewrite 2.18.0 -> 2.19.0 (#1326) See: - https://github.com/openrewrite/rewrite-recipe-bom/releases/tag/v2.19.0 - https://github.com/openrewrite/rewrite-recipe-bom/compare/v2.18.0...v2.19.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 71f89647..e6fcbb77 100644 --- a/pom.xml +++ b/pom.xml @@ -486,7 +486,7 @@ org.openrewrite.recipe rewrite-recipe-bom - 2.18.0 + 2.19.0 pom import From c63d9350d2909e7afc5680439423976a7fa87f4e Mon Sep 17 00:00:00 2001 From: Picnic-DevPla-Bot <168541957+Picnic-DevPla-Bot@users.noreply.github.com> Date: Tue, 17 Sep 2024 11:37:37 +0200 Subject: [PATCH 226/312] Upgrade OpenRewrite Templating 1.14.1 -> 1.15.0 (#1327) See: - https://github.com/openrewrite/rewrite-templating/releases/tag/v1.15.0 - https://github.com/openrewrite/rewrite-templating/compare/v1.14.1...v1.15.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e6fcbb77..374380bb 100644 --- a/pom.xml +++ b/pom.xml @@ -217,7 +217,7 @@ 1.0.1 0.11.3 1.1.4 - 1.14.1 + 1.15.0 3.2.3 From 966fb36ac91d445d4a627369f9441eb5bad2bb22 Mon Sep 17 00:00:00 2001 From: Picnic-DevPla-Bot <168541957+Picnic-DevPla-Bot@users.noreply.github.com> Date: Tue, 17 Sep 2024 11:55:54 +0200 Subject: [PATCH 227/312] Upgrade Spring 6.1.12 -> 6.1.13 (#1328) See: - https://github.com/spring-projects/spring-framework/releases/tag/v6.1.13 - https://github.com/spring-projects/spring-framework/compare/v6.1.12...v6.1.13 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 374380bb..bb89078a 100644 --- a/pom.xml +++ b/pom.xml @@ -500,7 +500,7 @@ org.springframework spring-framework-bom - 6.1.12 + 6.1.13 pom import From 432cf4560d84fde3b86243b725ccff21c3bd42f5 Mon Sep 17 00:00:00 2001 From: Picnic-DevPla-Bot <168541957+Picnic-DevPla-Bot@users.noreply.github.com> Date: Thu, 19 Sep 2024 13:03:04 +0200 Subject: [PATCH 228/312] Upgrade pitest-maven-plugin 1.16.1 -> 1.17.0 (#1313) See: - https://github.com/hcoles/pitest/releases/tag/1.16.2 - https://github.com/hcoles/pitest/releases/tag/1.16.3 - https://github.com/hcoles/pitest/releases/tag/1.17.0 - https://github.com/hcoles/pitest/compare/1.16.1...1.17.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index bb89078a..f3a917ef 100644 --- a/pom.xml +++ b/pom.xml @@ -1492,7 +1492,7 @@ org.pitest pitest-maven - 1.16.1 + 1.17.0 From 6a13efded8f5c64e3b0f09d89e36ece02de36e6d Mon Sep 17 00:00:00 2001 From: Picnic-DevPla-Bot <168541957+Picnic-DevPla-Bot@users.noreply.github.com> Date: Fri, 20 Sep 2024 22:27:00 +0200 Subject: [PATCH 229/312] Upgrade Spring Boot 3.3.3 -> 3.3.4 (#1333) See: - https://github.com/spring-projects/spring-boot/releases/tag/v3.3.4 - https://github.com/spring-projects/spring-boot/compare/v3.3.3...v3.3.4 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f3a917ef..e1821b85 100644 --- a/pom.xml +++ b/pom.xml @@ -507,7 +507,7 @@ org.springframework.boot spring-boot-test - 3.3.3 + 3.3.4 org.springframework.security From c57debdc25c3aad777b2afbdd82a6dd6f2f91635 Mon Sep 17 00:00:00 2001 From: Picnic-DevPla-Bot <168541957+Picnic-DevPla-Bot@users.noreply.github.com> Date: Mon, 23 Sep 2024 09:46:35 +0200 Subject: [PATCH 230/312] Upgrade maven-site-plugin 3.12.1 -> 3.20.0 (#1296) See: - https://issues.apache.org/jira/issues/?jql=project%20%3D%20MSITE%20AND%20fixVersion%20%3E%203.12.1%20AND%20fixVersion%20%3C%3D%203.20.0 - https://github.com/apache/maven-site-plugin/releases/tag/maven-site-plugin-3.20.0 - https://github.com/apache/maven-site-plugin/compare/maven-site-plugin-3.12.1...maven-site-plugin-3.20.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e1821b85..15297a22 100644 --- a/pom.xml +++ b/pom.xml @@ -1244,7 +1244,7 @@ org.apache.maven.plugins maven-site-plugin - 3.12.1 + 3.20.0 org.apache.maven.plugins From 3956a82cd5bd4f2e56ad2e35552a776c04534d5c Mon Sep 17 00:00:00 2001 From: Picnic-DevPla-Bot <168541957+Picnic-DevPla-Bot@users.noreply.github.com> Date: Mon, 23 Sep 2024 10:26:57 +0200 Subject: [PATCH 231/312] Upgrade extra-enforcer-rules 1.8.0 -> 1.9.0 (#1335) See: - https://github.com/mojohaus/extra-enforcer-rules/releases/tag/1.9.0 - https://github.com/mojohaus/extra-enforcer-rules/compare/1.8.0...1.9.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 15297a22..620f6cb6 100644 --- a/pom.xml +++ b/pom.xml @@ -1099,7 +1099,7 @@ org.codehaus.mojo extra-enforcer-rules - 1.8.0 + 1.9.0 From 91e841ce123d1b977768a5c39a0028f233ad6df0 Mon Sep 17 00:00:00 2001 From: Picnic-DevPla-Bot <168541957+Picnic-DevPla-Bot@users.noreply.github.com> Date: Tue, 24 Sep 2024 11:40:34 +0200 Subject: [PATCH 232/312] Upgrade maven-gpg-plugin 3.2.5 -> 3.2.6 (#1331) See: - https://github.com/apache/maven-gpg-plugin/releases/tag/maven-gpg-plugin-3.2.6 - https://github.com/apache/maven-gpg-plugin/compare/maven-gpg-plugin-3.2.5...maven-gpg-plugin-3.2.6 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 620f6cb6..814ea721 100644 --- a/pom.xml +++ b/pom.xml @@ -1114,7 +1114,7 @@ org.apache.maven.plugins maven-gpg-plugin - 3.2.5 + 3.2.6 sign-artifacts From 5583630fb447329e1d480eeb3510d0f38c83ff97 Mon Sep 17 00:00:00 2001 From: Picnic-DevPla-Bot <168541957+Picnic-DevPla-Bot@users.noreply.github.com> Date: Fri, 27 Sep 2024 14:17:50 +0200 Subject: [PATCH 233/312] Upgrade JUnit 5 5.11.0 -> 5.11.1 (#1342) See: - https://junit.org/junit5/docs/current/release-notes/ - https://github.com/junit-team/junit5/releases/tag/r5.11.1 - https://github.com/junit-team/junit5/compare/r5.11.0...r5.11.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 814ea721..0bd183c4 100644 --- a/pom.xml +++ b/pom.xml @@ -462,7 +462,7 @@ org.junit junit-bom - 5.11.0 + 5.11.1 pom import From 9cbc6f875cde2f271412bba55f67a1e77e7e57b5 Mon Sep 17 00:00:00 2001 From: Stephan Schroevers Date: Mon, 30 Sep 2024 06:38:44 +0200 Subject: [PATCH 234/312] Have `LexicographicalAnnotationAttributeListing` also sort booleans and chars (#1334) --- ...cographicalAnnotationAttributeListing.java | 7 ++- ...aphicalAnnotationAttributeListingTest.java | 54 ++++++++++++++++++- .../utils/ThirdPartyLibraryTest.java | 2 +- 3 files changed, 59 insertions(+), 4 deletions(-) diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/LexicographicalAnnotationAttributeListing.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/LexicographicalAnnotationAttributeListing.java index 62577e94..fca196b4 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/LexicographicalAnnotationAttributeListing.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/LexicographicalAnnotationAttributeListing.java @@ -163,7 +163,12 @@ public final class LexicographicalAnnotationAttributeListing extends BugChecker /* For now we don't force sorting on numeric types. */ return Stream.of( - symtab.annotationType, symtab.classType, symtab.enumSym.type, symtab.stringType) + symtab.annotationType, + symtab.booleanType, + symtab.charType, + symtab.classType, + symtab.enumSym.type, + symtab.stringType) .anyMatch(t -> ASTHelpers.isSubtype(elemType, t, state)); } diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/LexicographicalAnnotationAttributeListingTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/LexicographicalAnnotationAttributeListingTest.java index da842fd9..b73458a5 100644 --- a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/LexicographicalAnnotationAttributeListingTest.java +++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/LexicographicalAnnotationAttributeListingTest.java @@ -29,6 +29,10 @@ final class LexicographicalAnnotationAttributeListingTest { " @interface Foo {", " String[] value() default {};", "", + " boolean[] bools() default {};", + "", + " char[] chars() default {};", + "", " int[] ints() default {};", "", " Class[] cls() default {};", @@ -69,6 +73,32 @@ final class LexicographicalAnnotationAttributeListingTest { " @Foo({\"a\", \"A\"})", " A unsortedStringCaseInsensitiveWithTotalOrderFallback();", "", + " @Foo(bools = {})", + " A noBools();", + "", + " @Foo(bools = {false})", + " A oneBool();", + "", + " @Foo(bools = {false, true})", + " A sortedBools();", + "", + " // BUG: Diagnostic contains:", + " @Foo(bools = {true, false})", + " A unsortedBools();", + "", + " @Foo(chars = {})", + " A noChars();", + "", + " @Foo(chars = {'a'})", + " A oneChar();", + "", + " @Foo(chars = {'a', 'b'})", + " A sortedChars();", + "", + " // BUG: Diagnostic contains:", + " @Foo(chars = {'b', 'a'})", + " A unsortedChars();", + "", " @Foo(ints = {})", " A noInts();", "", @@ -173,6 +203,10 @@ final class LexicographicalAnnotationAttributeListingTest { " @interface Foo {", " String[] value() default {};", "", + " boolean[] bools() default {};", + "", + " char[] chars() default {};", + "", " Class[] cls() default {};", "", " RoundingMode[] enums() default {};", @@ -185,7 +219,13 @@ final class LexicographicalAnnotationAttributeListingTest { " }", "", " @Foo({\" \", \"\", \"b\", \"a\"})", - " A unsortedString();", + " A unsortedStrings();", + "", + " @Foo(bools = {true, false})", + " A unsortedBooleans();", + "", + " @Foo(chars = {'b', 'a'})", + " A unsortedChars();", "", " @Foo(cls = {long.class, int.class})", " A unsortedClasses();", @@ -210,6 +250,10 @@ final class LexicographicalAnnotationAttributeListingTest { " @interface Foo {", " String[] value() default {};", "", + " boolean[] bools() default {};", + "", + " char[] chars() default {};", + "", " Class[] cls() default {};", "", " RoundingMode[] enums() default {};", @@ -222,7 +266,13 @@ final class LexicographicalAnnotationAttributeListingTest { " }", "", " @Foo({\"\", \" \", \"a\", \"b\"})", - " A unsortedString();", + " A unsortedStrings();", + "", + " @Foo(bools = {false, true})", + " A unsortedBooleans();", + "", + " @Foo(chars = {'a', 'b'})", + " A unsortedChars();", "", " @Foo(cls = {int.class, long.class})", " A unsortedClasses();", diff --git a/error-prone-utils/src/test/java/tech/picnic/errorprone/utils/ThirdPartyLibraryTest.java b/error-prone-utils/src/test/java/tech/picnic/errorprone/utils/ThirdPartyLibraryTest.java index ac713c55..06bfd5c5 100644 --- a/error-prone-utils/src/test/java/tech/picnic/errorprone/utils/ThirdPartyLibraryTest.java +++ b/error-prone-utils/src/test/java/tech/picnic/errorprone/utils/ThirdPartyLibraryTest.java @@ -73,7 +73,7 @@ final class ThirdPartyLibraryTest { } @ParameterizedTest - @ValueSource(booleans = {true, false}) + @ValueSource(booleans = {false, true}) void isIntroductionAllowedIgnoreClasspathCompat(boolean ignoreClassPath) { CompilationTestHelper.newInstance(IsIntroductionAllowedTestChecker.class, getClass()) .setArgs("-XepOpt:ErrorProneSupport:IgnoreClasspathCompat=" + ignoreClassPath) From 4d1eeb2be1cb23eb93dda74ef980ed3ad4e22a67 Mon Sep 17 00:00:00 2001 From: Picnic-DevPla-Bot <168541957+Picnic-DevPla-Bot@users.noreply.github.com> Date: Mon, 30 Sep 2024 14:04:53 +0200 Subject: [PATCH 235/312] Upgrade Checkstyle 10.18.1 -> 10.18.2 (#1346) See: - https://checkstyle.sourceforge.io/releasenotes.html - https://github.com/checkstyle/checkstyle/releases/tag/checkstyle-10.18.2 - https://github.com/checkstyle/checkstyle/compare/checkstyle-10.18.1...checkstyle-10.18.2 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0bd183c4..4b4dc5b9 100644 --- a/pom.xml +++ b/pom.xml @@ -902,7 +902,7 @@ com.puppycrawl.tools checkstyle - 10.18.1 + 10.18.2 io.spring.nohttp From beb96f0f4b1474283e13ff8cb32d519644436383 Mon Sep 17 00:00:00 2001 From: Mohamed Sameh <110535847+mohamedsamehsalah@users.noreply.github.com> Date: Tue, 1 Oct 2024 10:05:33 +0200 Subject: [PATCH 236/312] Introduce `CollectionIterator` Refaster rule (#1347) This rule supersedes the more specific `ImmutableCollectionIterator` rule. --- .../errorprone/refasterrules/CollectionRules.java | 14 ++++++++------ .../refasterrules/CollectionRulesTestInput.java | 5 +++-- .../refasterrules/CollectionRulesTestOutput.java | 4 ++-- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/CollectionRules.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/CollectionRules.java index 4ee37189..3a02f6fe 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/CollectionRules.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/CollectionRules.java @@ -365,18 +365,20 @@ final class CollectionRules { } } - /** - * Don't call {@link ImmutableCollection#asList()} if {@link ImmutableCollection#iterator()} is - * called on the result; call it directly. - */ - static final class ImmutableCollectionIterator { + /** Prefer {@link Collection#iterator()} over more contrived or less efficient alternatives. */ + static final class CollectionIterator { + @BeforeTemplate + Iterator before(Collection collection) { + return collection.stream().iterator(); + } + @BeforeTemplate Iterator before(ImmutableCollection collection) { return collection.asList().iterator(); } @AfterTemplate - Iterator after(ImmutableCollection collection) { + Iterator after(Collection collection) { return collection.iterator(); } } diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/CollectionRulesTestInput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/CollectionRulesTestInput.java index c667a808..6936af32 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/CollectionRulesTestInput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/CollectionRulesTestInput.java @@ -119,8 +119,9 @@ final class CollectionRulesTest implements RefasterRuleCollectionTestCase { return ImmutableSet.of(1).asList().toArray(Integer[]::new); } - Iterator testImmutableCollectionIterator() { - return ImmutableSet.of(1).asList().iterator(); + ImmutableSet> testCollectionIterator() { + return ImmutableSet.of( + ImmutableSet.of(1).stream().iterator(), ImmutableSet.of(2).asList().iterator()); } ImmutableSet> testOptionalFirstCollectionElement() { diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/CollectionRulesTestOutput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/CollectionRulesTestOutput.java index 756135c8..59367ba2 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/CollectionRulesTestOutput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/CollectionRulesTestOutput.java @@ -109,8 +109,8 @@ final class CollectionRulesTest implements RefasterRuleCollectionTestCase { return ImmutableSet.of(1).toArray(Integer[]::new); } - Iterator testImmutableCollectionIterator() { - return ImmutableSet.of(1).iterator(); + ImmutableSet> testCollectionIterator() { + return ImmutableSet.of(ImmutableSet.of(1).iterator(), ImmutableSet.of(2).iterator()); } ImmutableSet> testOptionalFirstCollectionElement() { From e4d1818ed04c3cf4450b08f7b06fc5a000867945 Mon Sep 17 00:00:00 2001 From: Picnic-DevPla-Bot <168541957+Picnic-DevPla-Bot@users.noreply.github.com> Date: Sun, 13 Oct 2024 15:27:01 +0200 Subject: [PATCH 237/312] Upgrade Error Prone 2.32.0 -> 2.33.0 (#1348) See: - https://github.com/google/error-prone/releases/tag/v2.33.0 - https://github.com/google/error-prone/compare/v2.32.0...v2.33.0 - https://github.com/PicnicSupermarket/error-prone/compare/v2.32.0-picnic-1...v2.33.0-picnic-2 --- pom.xml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 4b4dc5b9..21219482 100644 --- a/pom.xml +++ b/pom.xml @@ -207,8 +207,8 @@ 1.1.1 1.11.0 ${version.error-prone-orig} - v${version.error-prone-orig}-picnic-1 - 2.32.0 + v${version.error-prone-orig}-picnic-2 + 2.33.0 0.1.28 1.0 17 @@ -1938,6 +1938,10 @@ -Xep:Java7ApiChecker:OFF -Xep:Java8ApiChecker:OFF + + -Xep:MemberName:OFF -Xep:StaticOrDefaultInterfaceMethod:OFF From aa08d954a0b765d87e5b20f0afe02a332713b079 Mon Sep 17 00:00:00 2001 From: Picnic-DevPla-Bot <168541957+Picnic-DevPla-Bot@users.noreply.github.com> Date: Sun, 13 Oct 2024 15:43:21 +0200 Subject: [PATCH 238/312] Upgrade Byte Buddy 1.15.1 -> 1.15.4 (#1340) See: - https://github.com/raphw/byte-buddy/releases/tag/byte-buddy-1.15.2 - https://github.com/raphw/byte-buddy/releases/tag/byte-buddy-1.15.3 - https://github.com/raphw/byte-buddy/releases/tag/byte-buddy-1.15.4 - https://github.com/raphw/byte-buddy/compare/byte-buddy-1.15.1...byte-buddy-1.15.4 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 21219482..59f1744a 100644 --- a/pom.xml +++ b/pom.xml @@ -417,7 +417,7 @@ net.bytebuddy byte-buddy - 1.15.1 + 1.15.4 -Xmx${argLine.xmx} + + -javaagent:${org.mockito:mockito-core:jar} + + org.mockito + mockito-core + test + + @@ -1017,6 +1031,14 @@ false true + + + set-additional-properties + + properties + + + org.apache.maven.plugins @@ -1555,6 +1577,10 @@ io.github.git-commit-id git-commit-id-maven-plugin + + org.apache.maven.plugins + maven-dependency-plugin + org.apache.maven.plugins maven-source-plugin diff --git a/refaster-support/pom.xml b/refaster-support/pom.xml index 019a2dc1..bc2dae67 100644 --- a/refaster-support/pom.xml +++ b/refaster-support/pom.xml @@ -88,10 +88,5 @@ junit-jupiter-params test - - org.mockito - mockito-core - test - From 1b00c87b2fac258f72fd9cd988e47d074f64f30c Mon Sep 17 00:00:00 2001 From: Picnic-DevPla-Bot <168541957+Picnic-DevPla-Bot@users.noreply.github.com> Date: Fri, 18 Oct 2024 13:23:57 +0200 Subject: [PATCH 253/312] Upgrade Mockito 5.14.0 -> 5.14.2 (#1361) See: - https://github.com/mockito/mockito/releases/tag/v5.14.1 - https://github.com/mockito/mockito/releases/tag/v5.14.2 - https://github.com/mockito/mockito/compare/v5.14.0...v5.14.2 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index eaef78d0..d7f5adf6 100644 --- a/pom.xml +++ b/pom.xml @@ -216,7 +216,7 @@ 1.0 17 3.9.9 - 5.14.0 + 5.14.2 1.0.1 0.11.3 1.1.4 From a0689f62b4ff2eba9ef32c7ab25174bffc3d3abc Mon Sep 17 00:00:00 2001 From: Picnic-DevPla-Bot <168541957+Picnic-DevPla-Bot@users.noreply.github.com> Date: Fri, 18 Oct 2024 13:53:23 +0200 Subject: [PATCH 254/312] Upgrade Byte Buddy 1.15.4 -> 1.15.5 (#1360) See: - https://github.com/raphw/byte-buddy/releases/tag/byte-buddy-1.15.5 - https://github.com/raphw/byte-buddy/compare/byte-buddy-1.15.4...byte-buddy-1.15.5 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d7f5adf6..d3f162f6 100644 --- a/pom.xml +++ b/pom.xml @@ -420,7 +420,7 @@ net.bytebuddy byte-buddy - 1.15.4 + 1.15.5 -Xep:BetaApi:OFF + + -Xep:IdentifierName:OFF -Xep:Java7ApiChecker:OFF -Xep:Java8ApiChecker:OFF - - -Xep:MemberName:OFF -Xep:StaticOrDefaultInterfaceMethod:OFF From f782ec2d8fa80d2d1d33ce64307e574051d1cb11 Mon Sep 17 00:00:00 2001 From: Picnic-DevPla-Bot <168541957+Picnic-DevPla-Bot@users.noreply.github.com> Date: Sat, 26 Oct 2024 13:36:32 +0200 Subject: [PATCH 268/312] Upgrade Spring Boot 3.3.4 -> 3.3.5 (#1374) See: - https://github.com/spring-projects/spring-boot/releases/tag/v3.3.5 - https://github.com/spring-projects/spring-boot/compare/v3.3.4...v3.3.5 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 26ea12fb..c0764d50 100644 --- a/pom.xml +++ b/pom.xml @@ -510,7 +510,7 @@ org.springframework.boot spring-boot-test - 3.3.4 + 3.3.5 org.springframework.security From be6b17b7dcda4a6c2305fb07527a65e08c33f813 Mon Sep 17 00:00:00 2001 From: Mohamed Sameh <110535847+mohamedsamehsalah@users.noreply.github.com> Date: Sat, 26 Oct 2024 14:01:25 +0200 Subject: [PATCH 269/312] Introduce `ImmutableEnumSetRules` Refaster rule collection (#1302) --- ...ocumentationGeneratorTaskListenerTest.java | 4 +- .../bugpatterns/JUnitClassModifiers.java | 4 +- .../refasterrules/AssortedRules.java | 24 -- .../refasterrules/ImmutableEnumSetRules.java | 246 ++++++++++++++++++ .../refasterrules/RefasterRulesTest.java | 1 + .../refasterrules/AssortedRulesTestInput.java | 10 +- .../AssortedRulesTestOutput.java | 10 +- .../ImmutableEnumSetRulesTestInput.java | 96 +++++++ .../ImmutableEnumSetRulesTestOutput.java | 96 +++++++ 9 files changed, 445 insertions(+), 46 deletions(-) create mode 100644 error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/ImmutableEnumSetRules.java create mode 100644 error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ImmutableEnumSetRulesTestInput.java create mode 100644 error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ImmutableEnumSetRulesTestOutput.java diff --git a/documentation-support/src/test/java/tech/picnic/errorprone/documentation/DocumentationGeneratorTaskListenerTest.java b/documentation-support/src/test/java/tech/picnic/errorprone/documentation/DocumentationGeneratorTaskListenerTest.java index 685c7cd6..4e9d175a 100644 --- a/documentation-support/src/test/java/tech/picnic/errorprone/documentation/DocumentationGeneratorTaskListenerTest.java +++ b/documentation-support/src/test/java/tech/picnic/errorprone/documentation/DocumentationGeneratorTaskListenerTest.java @@ -10,7 +10,6 @@ import static org.junit.jupiter.api.condition.OS.WINDOWS; import com.google.auto.service.AutoService; import com.google.auto.value.AutoValue; import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; import com.google.common.collect.Streams; import com.google.errorprone.VisitorState; @@ -41,7 +40,8 @@ final class DocumentationGeneratorTaskListenerTest { entry -> AclEntry.newBuilder(entry) .setPermissions( - Sets.difference(entry.permissions(), ImmutableSet.of(ADD_SUBDIRECTORY))) + Sets.difference( + entry.permissions(), Sets.immutableEnumSet(ADD_SUBDIRECTORY))) .build()) .collect(toImmutableList())); diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/JUnitClassModifiers.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/JUnitClassModifiers.java index 8cfd59cd..372adebb 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/JUnitClassModifiers.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/JUnitClassModifiers.java @@ -16,7 +16,7 @@ import static tech.picnic.errorprone.utils.MoreJUnitMatchers.TEST_METHOD; import static tech.picnic.errorprone.utils.MoreMatchers.hasMetaAnnotation; import com.google.auto.service.AutoService; -import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Sets; import com.google.errorprone.BugPattern; import com.google.errorprone.VisitorState; import com.google.errorprone.bugpatterns.BugChecker; @@ -70,7 +70,7 @@ public final class JUnitClassModifiers extends BugChecker implements ClassTreeMa SuggestedFixes.removeModifiers( tree.getModifiers(), state, - ImmutableSet.of(Modifier.PRIVATE, Modifier.PROTECTED, Modifier.PUBLIC)) + Sets.immutableEnumSet(Modifier.PRIVATE, Modifier.PROTECTED, Modifier.PUBLIC)) .ifPresent(fixBuilder::merge); if (!HAS_SPRING_CONFIGURATION_ANNOTATION.matches(tree, state)) { diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/AssortedRules.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/AssortedRules.java index 4841481e..a38a823e 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/AssortedRules.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/AssortedRules.java @@ -1,8 +1,6 @@ package tech.picnic.errorprone.refasterrules; import static com.google.common.base.Preconditions.checkElementIndex; -import static com.google.common.collect.ImmutableSet.toImmutableSet; -import static com.google.common.collect.Sets.toImmutableEnumSet; import static com.google.errorprone.refaster.ImportPolicy.STATIC_IMPORT_ALWAYS; import static java.util.Collections.disjoint; import static java.util.Objects.checkIndex; @@ -70,28 +68,6 @@ final class AssortedRules { } } - /** - * Use {@link Sets#toImmutableEnumSet()} when possible, as it is more efficient than {@link - * ImmutableSet#toImmutableSet()} and produces a more compact object. - * - *

Warning: this rewrite rule is not completely behavior preserving: while the - * original code produces a set that iterates over the elements in encounter order, the - * replacement code iterates over the elements in enum definition order. - */ - // XXX: ^ Consider emitting a comment warning about this fact? - static final class StreamToImmutableEnumSet> { - @BeforeTemplate - ImmutableSet before(Stream stream) { - return stream.collect(toImmutableSet()); - } - - @AfterTemplate - @UseImportPolicy(STATIC_IMPORT_ALWAYS) - ImmutableSet after(Stream stream) { - return stream.collect(toImmutableEnumSet()); - } - } - /** Prefer {@link Iterators#getNext(Iterator, Object)} over more contrived alternatives. */ static final class IteratorGetNextOrDefault { @BeforeTemplate diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/ImmutableEnumSetRules.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/ImmutableEnumSetRules.java new file mode 100644 index 00000000..b7b40af6 --- /dev/null +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/ImmutableEnumSetRules.java @@ -0,0 +1,246 @@ +package tech.picnic.errorprone.refasterrules; + +import static com.google.common.collect.ImmutableSet.toImmutableSet; +import static com.google.common.collect.Sets.toImmutableEnumSet; +import static com.google.errorprone.refaster.ImportPolicy.STATIC_IMPORT_ALWAYS; + +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Sets; +import com.google.errorprone.refaster.Refaster; +import com.google.errorprone.refaster.annotation.AfterTemplate; +import com.google.errorprone.refaster.annotation.BeforeTemplate; +import com.google.errorprone.refaster.annotation.Repeated; +import com.google.errorprone.refaster.annotation.UseImportPolicy; +import java.util.Arrays; +import java.util.Collection; +import java.util.EnumSet; +import java.util.stream.Stream; +import tech.picnic.errorprone.refaster.annotation.OnlineDocumentation; + +/** + * Refaster rules related to expressions dealing with {@code + * com.google.common.collect.ImmutableEnumSet}s. + */ +// XXX: Some of the rules defined here impact iteration order. That's a rather subtle change. Should +// we emit a comment warning about this fact? (This may produce a lot of noise. A bug checker could +// in some cases determine whether iteration order is important.) +// XXX: Consider replacing the `SetsImmutableEnumSet[N]` Refaster rules with a bug checker, such +// that call to `ImmutableSet#of(Object, Object, Object, Object, Object, Object, Object[])` with +// enum-typed values can also be rewritten. +@OnlineDocumentation +final class ImmutableEnumSetRules { + private ImmutableEnumSetRules() {} + + /** + * Prefer {@link Sets#immutableEnumSet(Iterable)} for enum collections to take advantage of the + * internally used {@link EnumSet}. + * + *

Warning: this rule is not completely behavior preserving: while the + * original code produces a set that iterates over its elements in the same order as the input + * {@link Iterable}, the replacement code iterates over the elements in enum definition order. + */ + static final class SetsImmutableEnumSetIterable> { + @BeforeTemplate + ImmutableSet before(Iterable elements) { + return ImmutableSet.copyOf(elements); + } + + @BeforeTemplate + ImmutableSet before(Collection elements) { + return ImmutableSet.copyOf(elements); + } + + @AfterTemplate + ImmutableSet after(Iterable elements) { + return Sets.immutableEnumSet(elements); + } + } + + /** + * Prefer {@link Sets#immutableEnumSet(Iterable)} for enum collections to take advantage of the + * internally used {@link EnumSet}. + * + *

Warning: this rule is not completely behavior preserving: while the + * original code produces a set that iterates over its elements in the same order as defined in + * the array, the replacement code iterates over the elements in enum definition order. + */ + static final class SetsImmutableEnumSetArraysAsList> { + @BeforeTemplate + ImmutableSet before(T[] elements) { + return ImmutableSet.copyOf(elements); + } + + @AfterTemplate + ImmutableSet after(T[] elements) { + return Sets.immutableEnumSet(Arrays.asList(elements)); + } + } + + /** + * Prefer {@link Sets#immutableEnumSet(Enum, Enum[])} for enum collections to take advantage of + * the internally used {@link EnumSet}. + */ + static final class SetsImmutableEnumSet1> { + @BeforeTemplate + @SuppressWarnings("SetsImmutableEnumSetIterable" /* This is a more specific template. */) + ImmutableSet before(T e1) { + return Refaster.anyOf(ImmutableSet.of(e1), ImmutableSet.copyOf(EnumSet.of(e1))); + } + + @AfterTemplate + @SuppressWarnings("unchecked") + ImmutableSet after(T e1) { + return Sets.immutableEnumSet(e1); + } + } + + /** + * Prefer {@link Sets#immutableEnumSet(Enum, Enum[])} for enum collections to take advantage of + * the internally used {@link EnumSet}. + * + *

Warning: this rule is not completely behavior preserving: while the {@link + * ImmutableSet#of} expression produces a set that iterates over its elements in the listed order, + * the replacement code iterates over the elements in enum definition order. + */ + static final class SetsImmutableEnumSet2> { + @BeforeTemplate + @SuppressWarnings("SetsImmutableEnumSetIterable" /* This is a more specific template. */) + ImmutableSet before(T e1, T e2) { + return Refaster.anyOf(ImmutableSet.of(e1, e2), ImmutableSet.copyOf(EnumSet.of(e1, e2))); + } + + @AfterTemplate + @SuppressWarnings("unchecked") + ImmutableSet after(T e1, T e2) { + return Sets.immutableEnumSet(e1, e2); + } + } + + /** + * Prefer {@link Sets#immutableEnumSet(Enum, Enum[])} for enum collections to take advantage of + * the internally used {@link EnumSet}. + * + *

Warning: this rule is not completely behavior preserving: while the {@link + * ImmutableSet#of} expression produces a set that iterates over its elements in the listed order, + * the replacement code iterates over the elements in enum definition order. + */ + static final class SetsImmutableEnumSet3> { + @BeforeTemplate + @SuppressWarnings("SetsImmutableEnumSetIterable" /* This is a more specific template. */) + ImmutableSet before(T e1, T e2, T e3) { + return Refaster.anyOf( + ImmutableSet.of(e1, e2, e3), ImmutableSet.copyOf(EnumSet.of(e1, e2, e3))); + } + + @AfterTemplate + @SuppressWarnings("unchecked") + ImmutableSet after(T e1, T e2, T e3) { + return Sets.immutableEnumSet(e1, e2, e3); + } + } + + /** + * Prefer {@link Sets#immutableEnumSet(Enum, Enum[])} for enum collections to take advantage of + * the internally used {@link EnumSet}. + * + *

Warning: this rule is not completely behavior preserving: while the {@link + * ImmutableSet#of} expression produces a set that iterates over its elements in the listed order, + * the replacement code iterates over the elements in enum definition order. + */ + static final class SetsImmutableEnumSet4> { + @BeforeTemplate + @SuppressWarnings("SetsImmutableEnumSetIterable" /* This is a more specific template. */) + ImmutableSet before(T e1, T e2, T e3, T e4) { + return Refaster.anyOf( + ImmutableSet.of(e1, e2, e3, e4), ImmutableSet.copyOf(EnumSet.of(e1, e2, e3, e4))); + } + + @AfterTemplate + @SuppressWarnings("unchecked") + ImmutableSet after(T e1, T e2, T e3, T e4) { + return Sets.immutableEnumSet(e1, e2, e3, e4); + } + } + + /** + * Prefer {@link Sets#immutableEnumSet(Enum, Enum[])} for enum collections to take advantage of + * the internally used {@link EnumSet}. + * + *

Warning: this rule is not completely behavior preserving: while the {@link + * ImmutableSet#of} expression produces a set that iterates over its elements in the listed order, + * the replacement code iterates over the elements in enum definition order. + */ + static final class SetsImmutableEnumSet5> { + @BeforeTemplate + @SuppressWarnings("SetsImmutableEnumSetIterable" /* This is a more specific template. */) + ImmutableSet before(T e1, T e2, T e3, T e4, T e5) { + return Refaster.anyOf( + ImmutableSet.of(e1, e2, e3, e4, e5), ImmutableSet.copyOf(EnumSet.of(e1, e2, e3, e4, e5))); + } + + @AfterTemplate + @SuppressWarnings("unchecked") + ImmutableSet after(T e1, T e2, T e3, T e4, T e5) { + return Sets.immutableEnumSet(e1, e2, e3, e4, e5); + } + } + + /** + * Prefer {@link Sets#immutableEnumSet(Enum, Enum[])} for enum collections to take advantage of + * the internally used {@link EnumSet}. + * + *

Warning: this rule is not completely behavior preserving: while the + * original code produces a set that iterates over its elements in the listed order, the + * replacement code iterates over the elements in enum definition order. + */ + static final class SetsImmutableEnumSet6> { + @BeforeTemplate + ImmutableSet before(T e1, T e2, T e3, T e4, T e5, T e6) { + return ImmutableSet.of(e1, e2, e3, e4, e5, e6); + } + + @AfterTemplate + @SuppressWarnings("unchecked") + ImmutableSet after(T e1, T e2, T e3, T e4, T e5, T e6) { + return Sets.immutableEnumSet(e1, e2, e3, e4, e5, e6); + } + } + + /** + * Prefer {@link Sets#immutableEnumSet(Enum, Enum[])} for enum collections to take advantage of + * the internally used {@link EnumSet}. + */ + static final class SetsImmutableEnumSetVarArgs> { + @BeforeTemplate + @SuppressWarnings("SetsImmutableEnumSetIterable" /* This is a more specific template. */) + ImmutableSet before(T e1, @Repeated T elements) { + return ImmutableSet.copyOf(EnumSet.of(e1, Refaster.asVarargs(elements))); + } + + @AfterTemplate + ImmutableSet after(T e1, @Repeated T elements) { + return Sets.immutableEnumSet(e1, Refaster.asVarargs(elements)); + } + } + + /** + * Use {@link Sets#toImmutableEnumSet()} when possible, as it is more efficient than {@link + * ImmutableSet#toImmutableSet()} and produces a more compact object. + * + *

Warning: this rule is not completely behavior preserving: while the + * original code produces a set that iterates over its elements in encounter order, the + * replacement code iterates over the elements in enum definition order. + */ + static final class StreamToImmutableEnumSet> { + @BeforeTemplate + ImmutableSet before(Stream stream) { + return stream.collect(toImmutableSet()); + } + + @AfterTemplate + @UseImportPolicy(STATIC_IMPORT_ALWAYS) + ImmutableSet after(Stream stream) { + return stream.collect(toImmutableEnumSet()); + } + } +} diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/refasterrules/RefasterRulesTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/refasterrules/RefasterRulesTest.java index a7c35621..30839af9 100644 --- a/error-prone-contrib/src/test/java/tech/picnic/errorprone/refasterrules/RefasterRulesTest.java +++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/refasterrules/RefasterRulesTest.java @@ -43,6 +43,7 @@ final class RefasterRulesTest { EqualityRules.class, FileRules.class, InputStreamRules.class, + ImmutableEnumSetRules.class, ImmutableListRules.class, ImmutableListMultimapRules.class, ImmutableMapRules.class, diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/AssortedRulesTestInput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/AssortedRulesTestInput.java index 1f785293..98174797 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/AssortedRulesTestInput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/AssortedRulesTestInput.java @@ -1,10 +1,7 @@ package tech.picnic.errorprone.refasterrules; -import static com.google.common.collect.ImmutableSet.toImmutableSet; - import com.google.common.base.Preconditions; import com.google.common.base.Splitter; -import com.google.common.collect.BoundType; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; @@ -24,8 +21,7 @@ final class AssortedRulesTest implements RefasterRuleCollectionTestCase { Preconditions.class, Sets.class, Splitter.class, - Streams.class, - toImmutableSet()); + Streams.class); } int testCheckIndex() { @@ -38,10 +34,6 @@ final class AssortedRulesTest implements RefasterRuleCollectionTestCase { } } - ImmutableSet testStreamToImmutableEnumSet() { - return Stream.of(BoundType.OPEN).collect(toImmutableSet()); - } - ImmutableSet testIteratorGetNextOrDefault() { return ImmutableSet.of( ImmutableList.of("a").iterator().hasNext() diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/AssortedRulesTestOutput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/AssortedRulesTestOutput.java index 2fd9c408..2e6794db 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/AssortedRulesTestOutput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/AssortedRulesTestOutput.java @@ -1,12 +1,9 @@ package tech.picnic.errorprone.refasterrules; -import static com.google.common.collect.ImmutableSet.toImmutableSet; -import static com.google.common.collect.Sets.toImmutableEnumSet; import static java.util.Objects.checkIndex; import com.google.common.base.Preconditions; import com.google.common.base.Splitter; -import com.google.common.collect.BoundType; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; @@ -27,8 +24,7 @@ final class AssortedRulesTest implements RefasterRuleCollectionTestCase { Preconditions.class, Sets.class, Splitter.class, - Streams.class, - toImmutableSet()); + Streams.class); } int testCheckIndex() { @@ -39,10 +35,6 @@ final class AssortedRulesTest implements RefasterRuleCollectionTestCase { checkIndex(1, 2); } - ImmutableSet testStreamToImmutableEnumSet() { - return Stream.of(BoundType.OPEN).collect(toImmutableEnumSet()); - } - ImmutableSet testIteratorGetNextOrDefault() { return ImmutableSet.of( Iterators.getNext(ImmutableList.of("a").iterator(), "foo"), diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ImmutableEnumSetRulesTestInput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ImmutableEnumSetRulesTestInput.java new file mode 100644 index 00000000..10662a9a --- /dev/null +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ImmutableEnumSetRulesTestInput.java @@ -0,0 +1,96 @@ +package tech.picnic.errorprone.refasterrules; + +import static com.google.common.collect.ImmutableSet.toImmutableSet; + +import com.google.common.collect.BoundType; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Iterables; +import java.math.RoundingMode; +import java.util.EnumSet; +import java.util.stream.Stream; +import tech.picnic.errorprone.refaster.test.RefasterRuleCollectionTestCase; + +final class ImmutableEnumSetRulesTest implements RefasterRuleCollectionTestCase { + @Override + public ImmutableSet elidedTypesAndStaticImports() { + return ImmutableSet.of(EnumSet.class, toImmutableSet()); + } + + ImmutableSet> testSetsImmutableEnumSetIterable() { + return ImmutableSet.of( + ImmutableSet.copyOf(Iterables.cycle(RoundingMode.UP)), + ImmutableSet.copyOf(EnumSet.allOf(RoundingMode.class))); + } + + ImmutableSet testSetsImmutableEnumSetArraysAsList() { + return ImmutableSet.copyOf(RoundingMode.values()); + } + + ImmutableSet> testSetsImmutableEnumSet1() { + return ImmutableSet.of( + ImmutableSet.of(RoundingMode.UP), ImmutableSet.copyOf(EnumSet.of(RoundingMode.UP))); + } + + ImmutableSet> testSetsImmutableEnumSet2() { + return ImmutableSet.of( + ImmutableSet.of(RoundingMode.UP, RoundingMode.DOWN), + ImmutableSet.copyOf(EnumSet.of(RoundingMode.UP, RoundingMode.DOWN))); + } + + ImmutableSet> testSetsImmutableEnumSet3() { + return ImmutableSet.of( + ImmutableSet.of(RoundingMode.UP, RoundingMode.DOWN, RoundingMode.CEILING), + ImmutableSet.copyOf(EnumSet.of(RoundingMode.UP, RoundingMode.DOWN, RoundingMode.CEILING))); + } + + ImmutableSet> testSetsImmutableEnumSet4() { + return ImmutableSet.of( + ImmutableSet.of( + RoundingMode.UP, RoundingMode.DOWN, RoundingMode.CEILING, RoundingMode.FLOOR), + ImmutableSet.copyOf( + EnumSet.of( + RoundingMode.UP, RoundingMode.DOWN, RoundingMode.CEILING, RoundingMode.FLOOR))); + } + + ImmutableSet> testSetsImmutableEnumSet5() { + return ImmutableSet.of( + ImmutableSet.of( + RoundingMode.UP, + RoundingMode.DOWN, + RoundingMode.CEILING, + RoundingMode.FLOOR, + RoundingMode.UNNECESSARY), + ImmutableSet.copyOf( + EnumSet.of( + RoundingMode.UP, + RoundingMode.DOWN, + RoundingMode.CEILING, + RoundingMode.FLOOR, + RoundingMode.UNNECESSARY))); + } + + ImmutableSet testSetsImmutableEnumSet6() { + return ImmutableSet.of( + RoundingMode.UP, + RoundingMode.DOWN, + RoundingMode.CEILING, + RoundingMode.FLOOR, + RoundingMode.UNNECESSARY, + RoundingMode.HALF_EVEN); + } + + ImmutableSet testSetsImmutableEnumSetVarArgs() { + return ImmutableSet.copyOf( + EnumSet.of( + RoundingMode.UP, + RoundingMode.DOWN, + RoundingMode.CEILING, + RoundingMode.FLOOR, + RoundingMode.UNNECESSARY, + RoundingMode.HALF_EVEN)); + } + + ImmutableSet testStreamToImmutableEnumSet() { + return Stream.of(BoundType.OPEN).collect(toImmutableSet()); + } +} diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ImmutableEnumSetRulesTestOutput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ImmutableEnumSetRulesTestOutput.java new file mode 100644 index 00000000..c96b01db --- /dev/null +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ImmutableEnumSetRulesTestOutput.java @@ -0,0 +1,96 @@ +package tech.picnic.errorprone.refasterrules; + +import static com.google.common.collect.ImmutableSet.toImmutableSet; +import static com.google.common.collect.Sets.toImmutableEnumSet; + +import com.google.common.collect.BoundType; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Iterables; +import com.google.common.collect.Sets; +import java.math.RoundingMode; +import java.util.Arrays; +import java.util.EnumSet; +import java.util.stream.Stream; +import tech.picnic.errorprone.refaster.test.RefasterRuleCollectionTestCase; + +final class ImmutableEnumSetRulesTest implements RefasterRuleCollectionTestCase { + @Override + public ImmutableSet elidedTypesAndStaticImports() { + return ImmutableSet.of(EnumSet.class, toImmutableSet()); + } + + ImmutableSet> testSetsImmutableEnumSetIterable() { + return ImmutableSet.of( + Sets.immutableEnumSet(Iterables.cycle(RoundingMode.UP)), + Sets.immutableEnumSet(EnumSet.allOf(RoundingMode.class))); + } + + ImmutableSet testSetsImmutableEnumSetArraysAsList() { + return Sets.immutableEnumSet(Arrays.asList(RoundingMode.values())); + } + + ImmutableSet> testSetsImmutableEnumSet1() { + return ImmutableSet.of( + Sets.immutableEnumSet(RoundingMode.UP), Sets.immutableEnumSet(RoundingMode.UP)); + } + + ImmutableSet> testSetsImmutableEnumSet2() { + return ImmutableSet.of( + Sets.immutableEnumSet(RoundingMode.UP, RoundingMode.DOWN), + Sets.immutableEnumSet(RoundingMode.UP, RoundingMode.DOWN)); + } + + ImmutableSet> testSetsImmutableEnumSet3() { + return ImmutableSet.of( + Sets.immutableEnumSet(RoundingMode.UP, RoundingMode.DOWN, RoundingMode.CEILING), + Sets.immutableEnumSet(RoundingMode.UP, RoundingMode.DOWN, RoundingMode.CEILING)); + } + + ImmutableSet> testSetsImmutableEnumSet4() { + return ImmutableSet.of( + Sets.immutableEnumSet( + RoundingMode.UP, RoundingMode.DOWN, RoundingMode.CEILING, RoundingMode.FLOOR), + Sets.immutableEnumSet( + RoundingMode.UP, RoundingMode.DOWN, RoundingMode.CEILING, RoundingMode.FLOOR)); + } + + ImmutableSet> testSetsImmutableEnumSet5() { + return ImmutableSet.of( + Sets.immutableEnumSet( + RoundingMode.UP, + RoundingMode.DOWN, + RoundingMode.CEILING, + RoundingMode.FLOOR, + RoundingMode.UNNECESSARY), + Sets.immutableEnumSet( + RoundingMode.UP, + RoundingMode.DOWN, + RoundingMode.CEILING, + RoundingMode.FLOOR, + RoundingMode.UNNECESSARY)); + } + + ImmutableSet testSetsImmutableEnumSet6() { + return Sets.immutableEnumSet( + RoundingMode.UP, + RoundingMode.DOWN, + RoundingMode.CEILING, + RoundingMode.FLOOR, + RoundingMode.UNNECESSARY, + RoundingMode.HALF_EVEN); + } + + ImmutableSet testSetsImmutableEnumSetVarArgs() { + return Sets.immutableEnumSet( + RoundingMode.UP, + RoundingMode.DOWN, + RoundingMode.CEILING, + RoundingMode.FLOOR, + RoundingMode.UNNECESSARY, + RoundingMode.HALF_EVEN); + } + + ImmutableSet testStreamToImmutableEnumSet() { + return Stream.of(BoundType.OPEN).collect(toImmutableEnumSet()); + } +} From 56b60f5cf63854e8c1a8c269ca8b10014ca79486 Mon Sep 17 00:00:00 2001 From: Danylo Naumenko Date: Sat, 26 Oct 2024 14:56:11 +0200 Subject: [PATCH 270/312] Introduce `MicrometerRules` Refaster rule collection (#1365) --- error-prone-contrib/pom.xml | 5 ++ .../refasterrules/MicrometerRules.java | 88 +++++++++++++++++++ .../refasterrules/RefasterRulesTest.java | 1 + .../MicrometerRulesTestInput.java | 57 ++++++++++++ .../MicrometerRulesTestOutput.java | 56 ++++++++++++ pom.xml | 5 ++ 6 files changed, 212 insertions(+) create mode 100644 error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/MicrometerRules.java create mode 100644 error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/MicrometerRulesTestInput.java create mode 100644 error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/MicrometerRulesTestOutput.java diff --git a/error-prone-contrib/pom.xml b/error-prone-contrib/pom.xml index 385f0867..f33573f4 100644 --- a/error-prone-contrib/pom.xml +++ b/error-prone-contrib/pom.xml @@ -87,6 +87,11 @@ guava provided + + io.micrometer + micrometer-core + provided + io.projectreactor reactor-core diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/MicrometerRules.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/MicrometerRules.java new file mode 100644 index 00000000..40800c6d --- /dev/null +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/MicrometerRules.java @@ -0,0 +1,88 @@ +package tech.picnic.errorprone.refasterrules; + +import com.google.common.collect.ImmutableCollection; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; +import com.google.errorprone.refaster.Refaster; +import com.google.errorprone.refaster.annotation.AfterTemplate; +import com.google.errorprone.refaster.annotation.BeforeTemplate; +import io.micrometer.core.instrument.Tag; +import io.micrometer.core.instrument.Tags; +import tech.picnic.errorprone.refaster.annotation.OnlineDocumentation; + +/** Refaster rules related to expressions dealing with Micrometer. */ +// XXX: Consider replacing the `TagsOf[N]` rules with a bug checker, so that various other +// expressions (e.g. those creating other collection types, those passing in tags some other way, or +// those passing in more tags) can be replaced as wel. +@OnlineDocumentation +final class MicrometerRules { + private MicrometerRules() {} + + /** Prefer using {@link Tags} over other immutable collections. */ + static final class TagsOf1 { + @BeforeTemplate + ImmutableCollection before(Tag tag) { + return Refaster.anyOf(ImmutableSet.of(tag), ImmutableList.of(tag)); + } + + @AfterTemplate + Iterable after(Tag tag) { + return Tags.of(tag); + } + } + + /** Prefer using {@link Tags} over other immutable collections. */ + static final class TagsOf2 { + @BeforeTemplate + ImmutableCollection before(Tag tag1, Tag tag2) { + return Refaster.anyOf(ImmutableSet.of(tag1, tag2), ImmutableList.of(tag1, tag2)); + } + + @AfterTemplate + Iterable after(Tag tag1, Tag tag2) { + return Tags.of(tag1, tag2); + } + } + + /** Prefer using {@link Tags} over other immutable collections. */ + static final class TagsOf3 { + @BeforeTemplate + ImmutableCollection before(Tag tag1, Tag tag2, Tag tag3) { + return Refaster.anyOf(ImmutableSet.of(tag1, tag2, tag3), ImmutableList.of(tag1, tag2, tag3)); + } + + @AfterTemplate + Iterable after(Tag tag1, Tag tag2, Tag tag3) { + return Tags.of(tag1, tag2, tag3); + } + } + + /** Prefer using {@link Tags} over other immutable collections. */ + static final class TagsOf4 { + @BeforeTemplate + ImmutableCollection before(Tag tag1, Tag tag2, Tag tag3, Tag tag4) { + return Refaster.anyOf( + ImmutableSet.of(tag1, tag2, tag3, tag4), ImmutableList.of(tag1, tag2, tag3, tag4)); + } + + @AfterTemplate + Iterable after(Tag tag1, Tag tag2, Tag tag3, Tag tag4) { + return Tags.of(tag1, tag2, tag3, tag4); + } + } + + /** Prefer using {@link Tags} over other immutable collections. */ + static final class TagsOf5 { + @BeforeTemplate + ImmutableCollection before(Tag tag1, Tag tag2, Tag tag3, Tag tag4, Tag tag5) { + return Refaster.anyOf( + ImmutableSet.of(tag1, tag2, tag3, tag4, tag5), + ImmutableList.of(tag1, tag2, tag3, tag4, tag5)); + } + + @AfterTemplate + Iterable after(Tag tag1, Tag tag2, Tag tag3, Tag tag4, Tag tag5) { + return Tags.of(tag1, tag2, tag3, tag4, tag5); + } + } +} diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/refasterrules/RefasterRulesTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/refasterrules/RefasterRulesTest.java index 30839af9..fd5cb296 100644 --- a/error-prone-contrib/src/test/java/tech/picnic/errorprone/refasterrules/RefasterRulesTest.java +++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/refasterrules/RefasterRulesTest.java @@ -59,6 +59,7 @@ final class RefasterRulesTest { LongStreamRules.class, MapEntryRules.class, MapRules.class, + MicrometerRules.class, MockitoRules.class, MultimapRules.class, NullRules.class, diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/MicrometerRulesTestInput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/MicrometerRulesTestInput.java new file mode 100644 index 00000000..256c9494 --- /dev/null +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/MicrometerRulesTestInput.java @@ -0,0 +1,57 @@ +package tech.picnic.errorprone.refasterrules; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; +import io.micrometer.core.instrument.Tag; +import tech.picnic.errorprone.refaster.test.RefasterRuleCollectionTestCase; + +final class MicrometerRulesTest implements RefasterRuleCollectionTestCase { + @Override + public ImmutableSet elidedTypesAndStaticImports() { + return ImmutableSet.of(ImmutableList.class); + } + + ImmutableSet> testTagsOf1() { + return ImmutableSet.of( + ImmutableSet.of(Tag.of("foo", "v1")), ImmutableList.of(Tag.of("bar", "v2"))); + } + + ImmutableSet> testTagsOf2() { + return ImmutableSet.of( + ImmutableSet.of(Tag.of("foo", "v1"), Tag.of("bar", "v2")), + ImmutableList.of(Tag.of("baz", "v3"), Tag.of("qux", "v4"))); + } + + ImmutableSet> testTagsOf3() { + return ImmutableSet.of( + ImmutableSet.of(Tag.of("foo", "v1"), Tag.of("bar", "v2"), Tag.of("baz", "v3")), + ImmutableList.of(Tag.of("qux", "v4"), Tag.of("quux", "v5"), Tag.of("corge", "v6"))); + } + + ImmutableSet> testTagsOf4() { + return ImmutableSet.of( + ImmutableSet.of( + Tag.of("foo", "v1"), Tag.of("bar", "v2"), Tag.of("baz", "v3"), Tag.of("qux", "v4")), + ImmutableList.of( + Tag.of("quux", "v5"), + Tag.of("corge", "v6"), + Tag.of("grault", "v7"), + Tag.of("garply", "v8"))); + } + + ImmutableSet> testTagsOf5() { + return ImmutableSet.of( + ImmutableSet.of( + Tag.of("foo", "v1"), + Tag.of("bar", "v2"), + Tag.of("baz", "v3"), + Tag.of("qux", "v4"), + Tag.of("quux", "v5")), + ImmutableList.of( + Tag.of("corge", "v6"), + Tag.of("grault", "v7"), + Tag.of("garply", "v8"), + Tag.of("waldo", "v9"), + Tag.of("fred", "v10"))); + } +} diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/MicrometerRulesTestOutput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/MicrometerRulesTestOutput.java new file mode 100644 index 00000000..74c4dd50 --- /dev/null +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/MicrometerRulesTestOutput.java @@ -0,0 +1,56 @@ +package tech.picnic.errorprone.refasterrules; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; +import io.micrometer.core.instrument.Tag; +import io.micrometer.core.instrument.Tags; +import tech.picnic.errorprone.refaster.test.RefasterRuleCollectionTestCase; + +final class MicrometerRulesTest implements RefasterRuleCollectionTestCase { + @Override + public ImmutableSet elidedTypesAndStaticImports() { + return ImmutableSet.of(ImmutableList.class); + } + + ImmutableSet> testTagsOf1() { + return ImmutableSet.of(Tags.of(Tag.of("foo", "v1")), Tags.of(Tag.of("bar", "v2"))); + } + + ImmutableSet> testTagsOf2() { + return ImmutableSet.of( + Tags.of(Tag.of("foo", "v1"), Tag.of("bar", "v2")), + Tags.of(Tag.of("baz", "v3"), Tag.of("qux", "v4"))); + } + + ImmutableSet> testTagsOf3() { + return ImmutableSet.of( + Tags.of(Tag.of("foo", "v1"), Tag.of("bar", "v2"), Tag.of("baz", "v3")), + Tags.of(Tag.of("qux", "v4"), Tag.of("quux", "v5"), Tag.of("corge", "v6"))); + } + + ImmutableSet> testTagsOf4() { + return ImmutableSet.of( + Tags.of(Tag.of("foo", "v1"), Tag.of("bar", "v2"), Tag.of("baz", "v3"), Tag.of("qux", "v4")), + Tags.of( + Tag.of("quux", "v5"), + Tag.of("corge", "v6"), + Tag.of("grault", "v7"), + Tag.of("garply", "v8"))); + } + + ImmutableSet> testTagsOf5() { + return ImmutableSet.of( + Tags.of( + Tag.of("foo", "v1"), + Tag.of("bar", "v2"), + Tag.of("baz", "v3"), + Tag.of("qux", "v4"), + Tag.of("quux", "v5")), + Tags.of( + Tag.of("corge", "v6"), + Tag.of("grault", "v7"), + Tag.of("garply", "v8"), + Tag.of("waldo", "v9"), + Tag.of("fred", "v10"))); + } +} diff --git a/pom.xml b/pom.xml index c0764d50..07f4d433 100644 --- a/pom.xml +++ b/pom.xml @@ -365,6 +365,11 @@ nullaway ${version.nullaway} + + io.micrometer + micrometer-core + 1.13.6 + io.projectreactor reactor-bom From 5922c5b03277d6b03d2040f46b258195ef433bcd Mon Sep 17 00:00:00 2001 From: Picnic-DevPla-Bot <168541957+Picnic-DevPla-Bot@users.noreply.github.com> Date: Sun, 27 Oct 2024 12:12:35 +0100 Subject: [PATCH 271/312] Upgrade Checkstyle 10.18.2 -> 10.19.0 (#1376) See: - https://checkstyle.sourceforge.io/releasenotes.html - https://github.com/checkstyle/checkstyle/releases/tag/checkstyle-10.19.0 - https://github.com/checkstyle/checkstyle/compare/checkstyle-10.18.2...checkstyle-10.19.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 07f4d433..a7cafa3e 100644 --- a/pom.xml +++ b/pom.xml @@ -921,7 +921,7 @@ com.puppycrawl.tools checkstyle - 10.18.2 + 10.19.0 io.spring.nohttp From d1765fea0ed0dcca9a09ec280d42c1460893e4ff Mon Sep 17 00:00:00 2001 From: Picnic-DevPla-Bot <168541957+Picnic-DevPla-Bot@users.noreply.github.com> Date: Sun, 27 Oct 2024 12:37:15 +0100 Subject: [PATCH 272/312] Upgrade maven-dependency-plugin 3.8.0 -> 3.8.1 (#1375) See: - https://github.com/apache/maven-dependency-plugin/releases/tag/maven-dependency-plugin-3.8.1 - https://github.com/apache/maven-dependency-plugin/compare/maven-dependency-plugin-3.8.0...maven-dependency-plugin-3.8.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a7cafa3e..9a66617a 100644 --- a/pom.xml +++ b/pom.xml @@ -1025,7 +1025,7 @@ org.apache.maven.plugins maven-dependency-plugin - 3.8.0 + 3.8.1 - Operating system (e.g. MacOS Monterey). -- Java version (i.e. `java --version`, e.g. `17.0.10`). -- Error Prone version (e.g. `2.25.0`). -- Error Prone Support version (e.g. `0.15.0`). +- Java version (i.e. `java --version`, e.g. `17.0.13`). +- Error Prone version (e.g. `2.35.1`). +- Error Prone Support version (e.g. `0.19.0`). ### Additional context diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index aa8e3d8c..0c7dbdd1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,16 +10,16 @@ jobs: strategy: matrix: os: [ ubuntu-22.04 ] - jdk: [ 17.0.10, 21.0.2, 22.0.2 ] + jdk: [ 17.0.13, 21.0.5, 23.0.1 ] distribution: [ temurin ] experimental: [ false ] include: - os: macos-14 - jdk: 17.0.10 + jdk: 17.0.13 distribution: temurin experimental: false - os: windows-2022 - jdk: 17.0.10 + jdk: 17.0.13 distribution: temurin experimental: false runs-on: ${{ matrix.os }} diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 0d3f6acb..34384e89 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -36,7 +36,7 @@ jobs: - name: Check out code and set up JDK and Maven uses: s4u/setup-maven-action@489441643219d2b93ee2a127b2402eb640a1b947 # v1.13.0 with: - java-version: 17.0.10 + java-version: 17.0.13 java-distribution: temurin maven-version: 3.9.9 - name: Initialize CodeQL diff --git a/.github/workflows/pitest-analyze-pr.yml b/.github/workflows/pitest-analyze-pr.yml index a45f77bc..4c443ab5 100644 --- a/.github/workflows/pitest-analyze-pr.yml +++ b/.github/workflows/pitest-analyze-pr.yml @@ -25,7 +25,7 @@ jobs: uses: s4u/setup-maven-action@489441643219d2b93ee2a127b2402eb640a1b947 # v1.13.0 with: checkout-fetch-depth: 2 - java-version: 17.0.10 + java-version: 17.0.13 java-distribution: temurin maven-version: 3.9.9 - name: Run Pitest diff --git a/.github/workflows/pitest-update-pr.yml b/.github/workflows/pitest-update-pr.yml index 6d5b181c..96441ee0 100644 --- a/.github/workflows/pitest-update-pr.yml +++ b/.github/workflows/pitest-update-pr.yml @@ -33,7 +33,7 @@ jobs: - name: Check out code and set up JDK and Maven uses: s4u/setup-maven-action@489441643219d2b93ee2a127b2402eb640a1b947 # v1.13.0 with: - java-version: 17.0.10 + java-version: 17.0.13 java-distribution: temurin maven-version: 3.9.9 - name: Download Pitest analysis artifact diff --git a/.github/workflows/run-integration-tests.yml b/.github/workflows/run-integration-tests.yml index 51e20086..2a70eb85 100644 --- a/.github/workflows/run-integration-tests.yml +++ b/.github/workflows/run-integration-tests.yml @@ -36,7 +36,7 @@ jobs: uses: s4u/setup-maven-action@489441643219d2b93ee2a127b2402eb640a1b947 # v1.13.0 with: checkout-ref: "refs/pull/${{ github.event.issue.number }}/head" - java-version: 17.0.10 + java-version: 17.0.13 java-distribution: temurin maven-version: 3.9.9 - name: Install project to local Maven repository diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 9e944536..cf0d018e 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -38,7 +38,7 @@ jobs: uses: s4u/setup-maven-action@489441643219d2b93ee2a127b2402eb640a1b947 # v1.13.0 with: checkout-fetch-depth: 0 - java-version: 17.0.10 + java-version: 17.0.13 java-distribution: temurin maven-version: 3.9.9 - name: Create missing `test` directory diff --git a/pom.xml b/pom.xml index a87dca75..d6a0deaa 100644 --- a/pom.xml +++ b/pom.xml @@ -486,6 +486,13 @@ mongodb-driver-core 5.2.0 + + + org.openrewrite + rewrite-java-17 + 8.38.1 + org.openrewrite rewrite-templating diff --git a/website/generate-version-compatibility-overview.sh b/website/generate-version-compatibility-overview.sh index ad29e4db..7513a035 100755 --- a/website/generate-version-compatibility-overview.sh +++ b/website/generate-version-compatibility-overview.sh @@ -12,7 +12,7 @@ set -e -u -o pipefail # Currently all released Error Prone Support versions are compatible with Java # 17. -java_version=17.0.10-tem +java_version=17.0.13-tem (set +u && echo n | sdk install java "${java_version}") sdk use java "${java_version}" From caf2a869229463592a71cfffd18dd53d4fd7a48f Mon Sep 17 00:00:00 2001 From: Mohamed Sameh <110535847+mohamedsamehsalah@users.noreply.github.com> Date: Tue, 29 Oct 2024 10:35:36 +0100 Subject: [PATCH 281/312] Introduce `ClassCastLambdaUsage` check (#1381) This new check replaces the `ClassLiteralCast` Refaster rule, as the latter produced invalid code by suggesting expressions of the form `T.class::cast` for generic `T`. --- .../bugpatterns/ClassCastLambdaUsage.java | 65 ++++++++++++++++++ .../bugpatterns/IsInstanceLambdaUsage.java | 2 + .../errorprone/refasterrules/ClassRules.java | 18 ----- .../bugpatterns/ClassCastLambdaUsageTest.java | 68 +++++++++++++++++++ .../IsInstanceLambdaUsageTest.java | 17 ++--- .../refasterrules/ClassRulesTestInput.java | 4 -- .../refasterrules/ClassRulesTestOutput.java | 4 -- 7 files changed, 144 insertions(+), 34 deletions(-) create mode 100644 error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/ClassCastLambdaUsage.java create mode 100644 error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/ClassCastLambdaUsageTest.java diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/ClassCastLambdaUsage.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/ClassCastLambdaUsage.java new file mode 100644 index 00000000..11af5823 --- /dev/null +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/ClassCastLambdaUsage.java @@ -0,0 +1,65 @@ +package tech.picnic.errorprone.bugpatterns; + +import static com.google.errorprone.BugPattern.LinkType.CUSTOM; +import static com.google.errorprone.BugPattern.SeverityLevel.SUGGESTION; +import static com.google.errorprone.BugPattern.StandardTags.SIMPLIFICATION; +import static tech.picnic.errorprone.utils.Documentation.BUG_PATTERNS_BASE_URL; + +import com.google.auto.service.AutoService; +import com.google.common.collect.Iterables; +import com.google.errorprone.BugPattern; +import com.google.errorprone.VisitorState; +import com.google.errorprone.bugpatterns.BugChecker; +import com.google.errorprone.bugpatterns.BugChecker.LambdaExpressionTreeMatcher; +import com.google.errorprone.fixes.SuggestedFix; +import com.google.errorprone.matchers.Description; +import com.google.errorprone.util.ASTHelpers; +import com.sun.source.tree.LambdaExpressionTree; +import com.sun.source.tree.TypeCastTree; +import com.sun.source.tree.VariableTree; +import com.sun.tools.javac.code.Type; +import tech.picnic.errorprone.utils.SourceCode; + +/** + * A {@link BugChecker} that flags lambda expressions that can be replaced with a method reference + * of the form {@code T.class::cast}. + */ +// XXX: Consider folding this logic into the `MethodReferenceUsage` check of the +// `error-prone-experimental` module. +// XXX: This check and its tests are structurally nearly identical to `IsInstanceLambdaUsage`. +// Unless folded into `MethodReferenceUsage`, consider merging the two. +@AutoService(BugChecker.class) +@BugPattern( + summary = "Prefer `Class::cast` method reference over equivalent lambda expression", + link = BUG_PATTERNS_BASE_URL + "ClassCastLambdaUsage", + linkType = CUSTOM, + severity = SUGGESTION, + tags = SIMPLIFICATION) +public final class ClassCastLambdaUsage extends BugChecker implements LambdaExpressionTreeMatcher { + private static final long serialVersionUID = 1L; + + /** Instantiates a new {@link ClassCastLambdaUsage} instance. */ + public ClassCastLambdaUsage() {} + + @Override + public Description matchLambdaExpression(LambdaExpressionTree tree, VisitorState state) { + if (tree.getParameters().size() != 1 || !(tree.getBody() instanceof TypeCastTree typeCast)) { + return Description.NO_MATCH; + } + + Type type = ASTHelpers.getType(typeCast); + if (type == null || type.isParameterized()) { + return Description.NO_MATCH; + } + + VariableTree param = Iterables.getOnlyElement(tree.getParameters()); + if (!ASTHelpers.getSymbol(param).equals(ASTHelpers.getSymbol(typeCast.getExpression()))) { + return Description.NO_MATCH; + } + + return describeMatch( + tree, + SuggestedFix.replace( + tree, SourceCode.treeToString(typeCast.getType(), state) + ".class::cast")); + } +} diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/IsInstanceLambdaUsage.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/IsInstanceLambdaUsage.java index 2fa02a75..62bd72da 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/IsInstanceLambdaUsage.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/IsInstanceLambdaUsage.java @@ -25,6 +25,8 @@ import tech.picnic.errorprone.utils.SourceCode; */ // XXX: Consider folding this logic into the `MethodReferenceUsage` check of the // `error-prone-experimental` module. +// XXX: This check and its tests are structurally nearly identical to `ClassCastLambdaUsage`. Unless +// folded into `MethodReferenceUsage`, consider merging the two. @AutoService(BugChecker.class) @BugPattern( summary = "Prefer `Class::isInstance` method reference over equivalent lambda expression", diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/ClassRules.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/ClassRules.java index 496b1f1f..5b0d4780 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/ClassRules.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/ClassRules.java @@ -73,24 +73,6 @@ final class ClassRules { } } - /** - * Prefer {@link Class#cast(Object)} method references over lambda expressions that require naming - * a variable. - */ - // XXX: Once the `ClassReferenceCast` rule is dropped, rename this rule to just `ClassCast`. - static final class ClassLiteralCast { - @BeforeTemplate - @SuppressWarnings("unchecked") - Function before() { - return t -> (S) t; - } - - @AfterTemplate - Function after() { - return Refaster.clazz()::cast; - } - } - /** * Prefer {@link Class#cast(Object)} method references over lambda expressions that require naming * a variable. diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/ClassCastLambdaUsageTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/ClassCastLambdaUsageTest.java new file mode 100644 index 00000000..5b445eca --- /dev/null +++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/ClassCastLambdaUsageTest.java @@ -0,0 +1,68 @@ +package tech.picnic.errorprone.bugpatterns; + +import com.google.errorprone.BugCheckerRefactoringTestHelper; +import com.google.errorprone.BugCheckerRefactoringTestHelper.TestMode; +import com.google.errorprone.CompilationTestHelper; +import org.junit.jupiter.api.Test; + +final class ClassCastLambdaUsageTest { + @Test + void identification() { + CompilationTestHelper.newInstance(ClassCastLambdaUsage.class, getClass()) + .addSourceLines( + "A.java", + "import com.google.common.collect.ImmutableSet;", + "import java.util.stream.Stream;", + "", + "class A {", + " void m() {", + " Number localVariable = 0;", + "", + " Stream.of(0).map(i -> i);", + " Stream.of(1).map(i -> i + 1);", + " Stream.of(2).map(Integer.class::cast);", + " Stream.of(3).map(i -> (Integer) 2);", + " Stream.of(4).map(i -> (Integer) localVariable);", + " // XXX: Ideally this case is also flagged. Pick this up in the context of merging the", + " // `ClassCastLambdaUsage` and `MethodReferenceUsage` checks, or introduce a separate check that", + " // simplifies unnecessary block lambda expressions.", + " Stream.of(5)", + " .map(", + " i -> {", + " return (Integer) i;", + " });", + " Stream.of(ImmutableSet.of(5)).map(l -> (ImmutableSet) l);", + " Stream.of(ImmutableSet.of(6)).map(l -> (ImmutableSet) l);", + " Stream.of(7).reduce((a, b) -> (Integer) a);", + "", + " // BUG: Diagnostic contains:", + " Stream.of(8).map(i -> (Integer) i);", + " }", + "}") + .doTest(); + } + + @Test + void replacement() { + BugCheckerRefactoringTestHelper.newInstance(ClassCastLambdaUsage.class, getClass()) + .addInputLines( + "A.java", + "import java.util.stream.Stream;", + "", + "class A {", + " void m() {", + " Stream.of(1).map(i -> (Integer) i);", + " }", + "}") + .addOutputLines( + "A.java", + "import java.util.stream.Stream;", + "", + "class A {", + " void m() {", + " Stream.of(1).map(Integer.class::cast);", + " }", + "}") + .doTest(TestMode.TEXT_MATCH); + } +} diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/IsInstanceLambdaUsageTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/IsInstanceLambdaUsageTest.java index a6204c5a..e57f0fbd 100644 --- a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/IsInstanceLambdaUsageTest.java +++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/IsInstanceLambdaUsageTest.java @@ -18,22 +18,23 @@ final class IsInstanceLambdaUsageTest { " void m() {", " Integer localVariable = 0;", "", - " Stream.of(0).map(i -> i + 1);", - " Stream.of(1).filter(Integer.class::isInstance);", - " Stream.of(2).filter(i -> i.getClass() instanceof Class);", - " Stream.of(3).filter(i -> localVariable instanceof Integer);", + " Stream.of(0).map(i -> i);", + " Stream.of(1).map(i -> i + 1);", + " Stream.of(2).filter(Integer.class::isInstance);", + " Stream.of(3).filter(i -> i.getClass() instanceof Class);", + " Stream.of(4).filter(i -> localVariable instanceof Integer);", " // XXX: Ideally this case is also flagged. Pick this up in the context of merging the", " // `IsInstanceLambdaUsage` and `MethodReferenceUsage` checks, or introduce a separate check that", " // simplifies unnecessary block lambda expressions.", - " Stream.of(4)", + " Stream.of(5)", " .filter(", " i -> {", - " return localVariable instanceof Integer;", + " return i instanceof Integer;", " });", - " Flux.just(5, \"foo\").distinctUntilChanged(v -> v, (a, b) -> a instanceof Integer);", + " Flux.just(6, \"foo\").distinctUntilChanged(v -> v, (a, b) -> a instanceof Integer);", "", " // BUG: Diagnostic contains:", - " Stream.of(6).filter(i -> i instanceof Integer);", + " Stream.of(7).filter(i -> i instanceof Integer);", " }", "}") .doTest(); diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ClassRulesTestInput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ClassRulesTestInput.java index 94f6db36..59897bc3 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ClassRulesTestInput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ClassRulesTestInput.java @@ -24,10 +24,6 @@ final class ClassRulesTest implements RefasterRuleCollectionTestCase { return s -> clazz.isInstance(s); } - Function testClassLiteralCast() { - return i -> (Integer) i; - } - Function testClassReferenceCast() { return i -> Integer.class.cast(i); } diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ClassRulesTestOutput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ClassRulesTestOutput.java index 2c431415..fd205051 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ClassRulesTestOutput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ClassRulesTestOutput.java @@ -24,10 +24,6 @@ final class ClassRulesTest implements RefasterRuleCollectionTestCase { return clazz::isInstance; } - Function testClassLiteralCast() { - return Integer.class::cast; - } - Function testClassReferenceCast() { return Integer.class::cast; } From 9940576ea8cd8fcef4e257dc8a7e0dcb09744817 Mon Sep 17 00:00:00 2001 From: Stephan Schroevers Date: Tue, 29 Oct 2024 10:55:55 +0100 Subject: [PATCH 282/312] Introduce `NameContentEquals` Refaster rule (#1379) --- .../bugpatterns/ConstantNaming.java | 2 +- .../refasterrules/BugCheckerRules.java | 19 +++++++++++++++++++ .../BugCheckerRulesTestInput.java | 7 +++++++ .../BugCheckerRulesTestOutput.java | 7 +++++++ 4 files changed, 34 insertions(+), 1 deletion(-) diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/ConstantNaming.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/ConstantNaming.java index a0354a83..73522b7c 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/ConstantNaming.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/ConstantNaming.java @@ -112,7 +112,7 @@ public final class ConstantNaming extends BugChecker implements VariableTreeMatc new TreeScanner() { @Override public Boolean visitVariable(VariableTree tree, @Nullable Void unused) { - return ASTHelpers.getSymbol(tree).getSimpleName().toString().equals(name) + return ASTHelpers.getSymbol(tree).getSimpleName().contentEquals(name) || super.visitVariable(tree, null); } diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/BugCheckerRules.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/BugCheckerRules.java index db21ddb7..9ce8236f 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/BugCheckerRules.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/BugCheckerRules.java @@ -9,6 +9,7 @@ import com.google.errorprone.refaster.annotation.AfterTemplate; import com.google.errorprone.refaster.annotation.BeforeTemplate; import com.sun.tools.javac.util.Constants; import com.sun.tools.javac.util.Convert; +import javax.lang.model.element.Name; import tech.picnic.errorprone.refaster.annotation.OnlineDocumentation; /** Refaster rules related to {@link com.google.errorprone.bugpatterns.BugChecker} classes. */ @@ -67,4 +68,22 @@ final class BugCheckerRules { return Constants.format(value); } } + + /** Prefer {@link Name#contentEquals(CharSequence)} over more verbose alternatives. */ + static final class NameContentEquals { + @BeforeTemplate + boolean before(Name name, CharSequence string) { + return name.toString().equals(string.toString()); + } + + @BeforeTemplate + boolean before(Name name, String string) { + return name.toString().equals(string); + } + + @AfterTemplate + boolean after(Name name, CharSequence string) { + return name.contentEquals(string); + } + } } diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/BugCheckerRulesTestInput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/BugCheckerRulesTestInput.java index 91b0bf59..6d1ac1db 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/BugCheckerRulesTestInput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/BugCheckerRulesTestInput.java @@ -5,6 +5,7 @@ import com.google.errorprone.BugCheckerRefactoringTestHelper; import com.google.errorprone.BugCheckerRefactoringTestHelper.FixChoosers; import com.google.errorprone.bugpatterns.BugChecker; import com.sun.tools.javac.util.Convert; +import javax.lang.model.element.Name; import tech.picnic.errorprone.refaster.test.RefasterRuleCollectionTestCase; final class BugCheckerRulesTest implements RefasterRuleCollectionTestCase { @@ -31,4 +32,10 @@ final class BugCheckerRulesTest implements RefasterRuleCollectionTestCase { String testConstantsFormat() { return String.format("\"%s\"", Convert.quote("foo")); } + + ImmutableSet testNameContentEquals() { + return ImmutableSet.of( + ((Name) null).toString().equals("foo".subSequence(0, 1).toString()), + ((com.sun.tools.javac.util.Name) null).toString().equals("bar")); + } } diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/BugCheckerRulesTestOutput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/BugCheckerRulesTestOutput.java index 013617aa..3227c420 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/BugCheckerRulesTestOutput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/BugCheckerRulesTestOutput.java @@ -6,6 +6,7 @@ import com.google.errorprone.BugCheckerRefactoringTestHelper.FixChoosers; import com.google.errorprone.bugpatterns.BugChecker; import com.sun.tools.javac.util.Constants; import com.sun.tools.javac.util.Convert; +import javax.lang.model.element.Name; import tech.picnic.errorprone.refaster.test.RefasterRuleCollectionTestCase; final class BugCheckerRulesTest implements RefasterRuleCollectionTestCase { @@ -30,4 +31,10 @@ final class BugCheckerRulesTest implements RefasterRuleCollectionTestCase { String testConstantsFormat() { return Constants.format("foo"); } + + ImmutableSet testNameContentEquals() { + return ImmutableSet.of( + ((Name) null).contentEquals("foo".subSequence(0, 1)), + ((com.sun.tools.javac.util.Name) null).contentEquals("bar")); + } } From ce6931cc360095f61dcf3acd830031b9ea662f04 Mon Sep 17 00:00:00 2001 From: Mohamed Sameh <110535847+mohamedsamehsalah@users.noreply.github.com> Date: Wed, 30 Oct 2024 15:37:40 +0100 Subject: [PATCH 283/312] Ignore primitive casts in `ClassCastLambdaUsage` check (#1385) --- .../errorprone/bugpatterns/ClassCastLambdaUsage.java | 9 ++++++++- .../errorprone/bugpatterns/ClassCastLambdaUsageTest.java | 6 ++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/ClassCastLambdaUsage.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/ClassCastLambdaUsage.java index 11af5823..fb4e311a 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/ClassCastLambdaUsage.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/ClassCastLambdaUsage.java @@ -48,7 +48,14 @@ public final class ClassCastLambdaUsage extends BugChecker implements LambdaExpr } Type type = ASTHelpers.getType(typeCast); - if (type == null || type.isParameterized()) { + if (type == null || type.isParameterized() || type.isPrimitive()) { + /* + * The method reference syntax does not support casting to parameterized types. Additionally, + * `Class#cast` does not support the same range of type conversions between (boxed) primitive + * types as the cast operator. + */ + // XXX: Depending on the declared type of the value being cast, in some cases we _can_ rewrite + // primitive casts. Add support for this. return Description.NO_MATCH; } diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/ClassCastLambdaUsageTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/ClassCastLambdaUsageTest.java index 5b445eca..ed5c8f3e 100644 --- a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/ClassCastLambdaUsageTest.java +++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/ClassCastLambdaUsageTest.java @@ -12,6 +12,7 @@ final class ClassCastLambdaUsageTest { .addSourceLines( "A.java", "import com.google.common.collect.ImmutableSet;", + "import java.util.stream.IntStream;", "import java.util.stream.Stream;", "", "class A {", @@ -31,9 +32,10 @@ final class ClassCastLambdaUsageTest { " i -> {", " return (Integer) i;", " });", - " Stream.of(ImmutableSet.of(5)).map(l -> (ImmutableSet) l);", - " Stream.of(ImmutableSet.of(6)).map(l -> (ImmutableSet) l);", + " Stream.of(ImmutableSet.of(5)).map(s -> (ImmutableSet) s);", + " Stream.of(ImmutableSet.of(6)).map(s -> (ImmutableSet) s);", " Stream.of(7).reduce((a, b) -> (Integer) a);", + " IntStream.of(8).mapToObj(i -> (char) i);", "", " // BUG: Diagnostic contains:", " Stream.of(8).map(i -> (Integer) i);", From 0317cb73d6f186cb5417492c0736d8219099ffcc Mon Sep 17 00:00:00 2001 From: Stephan Schroevers Date: Thu, 31 Oct 2024 20:57:03 +0100 Subject: [PATCH 284/312] [maven-release-plugin] prepare release v0.19.0 --- documentation-support/pom.xml | 2 +- error-prone-contrib/pom.xml | 2 +- error-prone-experimental/pom.xml | 2 +- error-prone-guidelines/pom.xml | 2 +- error-prone-utils/pom.xml | 2 +- pom.xml | 6 +++--- refaster-compiler/pom.xml | 2 +- refaster-runner/pom.xml | 2 +- refaster-support/pom.xml | 2 +- refaster-test-support/pom.xml | 2 +- 10 files changed, 12 insertions(+), 12 deletions(-) diff --git a/documentation-support/pom.xml b/documentation-support/pom.xml index e71a8ed1..7c10b2c5 100644 --- a/documentation-support/pom.xml +++ b/documentation-support/pom.xml @@ -5,7 +5,7 @@ tech.picnic.error-prone-support error-prone-support - 0.18.1-SNAPSHOT + 0.19.0 documentation-support diff --git a/error-prone-contrib/pom.xml b/error-prone-contrib/pom.xml index f33573f4..f6d5b5f0 100644 --- a/error-prone-contrib/pom.xml +++ b/error-prone-contrib/pom.xml @@ -5,7 +5,7 @@ tech.picnic.error-prone-support error-prone-support - 0.18.1-SNAPSHOT + 0.19.0 error-prone-contrib diff --git a/error-prone-experimental/pom.xml b/error-prone-experimental/pom.xml index 3af0c9e8..749b1c9d 100644 --- a/error-prone-experimental/pom.xml +++ b/error-prone-experimental/pom.xml @@ -5,7 +5,7 @@ tech.picnic.error-prone-support error-prone-support - 0.18.1-SNAPSHOT + 0.19.0 error-prone-experimental diff --git a/error-prone-guidelines/pom.xml b/error-prone-guidelines/pom.xml index 2d1ba3f3..959ad7a3 100644 --- a/error-prone-guidelines/pom.xml +++ b/error-prone-guidelines/pom.xml @@ -5,7 +5,7 @@ tech.picnic.error-prone-support error-prone-support - 0.18.1-SNAPSHOT + 0.19.0 error-prone-guidelines diff --git a/error-prone-utils/pom.xml b/error-prone-utils/pom.xml index 1c6cffe2..40d37a3e 100644 --- a/error-prone-utils/pom.xml +++ b/error-prone-utils/pom.xml @@ -5,7 +5,7 @@ tech.picnic.error-prone-support error-prone-support - 0.18.1-SNAPSHOT + 0.19.0 error-prone-utils diff --git a/pom.xml b/pom.xml index d6a0deaa..f0c892db 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ tech.picnic.error-prone-support error-prone-support - 0.18.1-SNAPSHOT + 0.19.0 pom Picnic :: Error Prone Support @@ -52,7 +52,7 @@ scm:git:git@github.com:PicnicSupermarket/error-prone-support.git - HEAD + v0.19.0 https://github.com/PicnicSupermarket/error-prone-support @@ -151,7 +151,7 @@ com.google.errorprone - 2024-08-11T13:05:54Z + 2024-10-31T19:53:18Z UTF-8 - 2024-10-31T19:53:18Z + 2024-10-31T19:57:03Z UTF-8 ${project.groupId} From f06a2e4d4390f9b7808623f734f7ef0a506f833c Mon Sep 17 00:00:00 2001 From: Stephan Schroevers Date: Sun, 3 Nov 2024 16:58:19 +0100 Subject: [PATCH 288/312] [maven-release-plugin] prepare release v0.19.1 --- documentation-support/pom.xml | 2 +- error-prone-contrib/pom.xml | 2 +- error-prone-experimental/pom.xml | 2 +- error-prone-guidelines/pom.xml | 2 +- error-prone-utils/pom.xml | 2 +- pom.xml | 6 +++--- refaster-compiler/pom.xml | 2 +- refaster-runner/pom.xml | 2 +- refaster-support/pom.xml | 2 +- refaster-test-support/pom.xml | 2 +- 10 files changed, 12 insertions(+), 12 deletions(-) diff --git a/documentation-support/pom.xml b/documentation-support/pom.xml index affbf635..0dce6f24 100644 --- a/documentation-support/pom.xml +++ b/documentation-support/pom.xml @@ -5,7 +5,7 @@ tech.picnic.error-prone-support error-prone-support - 0.19.1-SNAPSHOT + 0.19.1 documentation-support diff --git a/error-prone-contrib/pom.xml b/error-prone-contrib/pom.xml index 96dd9baf..90aca07d 100644 --- a/error-prone-contrib/pom.xml +++ b/error-prone-contrib/pom.xml @@ -5,7 +5,7 @@ tech.picnic.error-prone-support error-prone-support - 0.19.1-SNAPSHOT + 0.19.1 error-prone-contrib diff --git a/error-prone-experimental/pom.xml b/error-prone-experimental/pom.xml index 8987092b..23eeb483 100644 --- a/error-prone-experimental/pom.xml +++ b/error-prone-experimental/pom.xml @@ -5,7 +5,7 @@ tech.picnic.error-prone-support error-prone-support - 0.19.1-SNAPSHOT + 0.19.1 error-prone-experimental diff --git a/error-prone-guidelines/pom.xml b/error-prone-guidelines/pom.xml index 49760ac6..f8bbee1d 100644 --- a/error-prone-guidelines/pom.xml +++ b/error-prone-guidelines/pom.xml @@ -5,7 +5,7 @@ tech.picnic.error-prone-support error-prone-support - 0.19.1-SNAPSHOT + 0.19.1 error-prone-guidelines diff --git a/error-prone-utils/pom.xml b/error-prone-utils/pom.xml index 7c0298d9..1993a08d 100644 --- a/error-prone-utils/pom.xml +++ b/error-prone-utils/pom.xml @@ -5,7 +5,7 @@ tech.picnic.error-prone-support error-prone-support - 0.19.1-SNAPSHOT + 0.19.1 error-prone-utils diff --git a/pom.xml b/pom.xml index 763822df..3800d3a1 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ tech.picnic.error-prone-support error-prone-support - 0.19.1-SNAPSHOT + 0.19.1 pom Picnic :: Error Prone Support @@ -52,7 +52,7 @@ scm:git:git@github.com:PicnicSupermarket/error-prone-support.git - HEAD + v0.19.1 https://github.com/PicnicSupermarket/error-prone-support @@ -151,7 +151,7 @@ com.google.errorprone - 2024-10-31T19:57:03Z + 2024-11-03T15:57:02Z UTF-8 - 2024-11-03T15:57:02Z + 2024-11-03T15:58:19Z UTF-8 From 86fbaf74031d7ce172f63a6cf528b6f06ca8cab0 Mon Sep 17 00:00:00 2001 From: Picnic-DevPla-Bot <168541957+Picnic-DevPla-Bot@users.noreply.github.com> Date: Fri, 8 Nov 2024 19:37:12 +0100 Subject: [PATCH 299/312] Upgrade Checkstyle 10.20.0 -> 10.20.1 (#1407) See: - https://checkstyle.sourceforge.io/releasenotes.html - https://github.com/checkstyle/checkstyle/releases/tag/checkstyle-10.20.1 - https://github.com/checkstyle/checkstyle/compare/checkstyle-10.20.0...checkstyle-10.20.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 94264413..74e613a4 100644 --- a/pom.xml +++ b/pom.xml @@ -928,7 +928,7 @@ com.puppycrawl.tools checkstyle - 10.20.0 + 10.20.1 io.spring.nohttp From 99aa656a1eb33550059682ca90c7dfed1242183a Mon Sep 17 00:00:00 2001 From: Picnic-DevPla-Bot <168541957+Picnic-DevPla-Bot@users.noreply.github.com> Date: Sat, 9 Nov 2024 10:27:57 +0100 Subject: [PATCH 300/312] Upgrade s4u/setup-maven-action v1.13.0 -> v1.16.0 (#1400) See: - https://github.com/s4u/setup-maven-action/releases/tag/v1.16.0 - https://github.com/s4u/setup-maven-action/releases/tag/v1.15.0 - https://github.com/s4u/setup-maven-action/releases/tag/v1.14.0 --- .github/workflows/build.yml | 2 +- .github/workflows/codeql.yml | 2 +- .github/workflows/pitest-analyze-pr.yml | 2 +- .github/workflows/pitest-update-pr.yml | 2 +- .github/workflows/run-integration-tests.yml | 2 +- .github/workflows/sonarcloud.yml | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 546eeb2a..cc5b57df 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -42,7 +42,7 @@ jobs: # additionally enabling all checks defined in this project and any Error # Prone checks available only from other artifact repositories. - name: Check out code and set up JDK and Maven - uses: s4u/setup-maven-action@489441643219d2b93ee2a127b2402eb640a1b947 # v1.13.0 + uses: s4u/setup-maven-action@382542f77617f34e56bf83868920a4d45b7451e7 # v1.16.0 with: java-version: ${{ matrix.jdk }} java-distribution: ${{ matrix.distribution }} diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 7bd79ef0..74e01235 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -34,7 +34,7 @@ jobs: repo.maven.apache.org:443 uploads.github.com:443 - name: Check out code and set up JDK and Maven - uses: s4u/setup-maven-action@489441643219d2b93ee2a127b2402eb640a1b947 # v1.13.0 + uses: s4u/setup-maven-action@382542f77617f34e56bf83868920a4d45b7451e7 # v1.16.0 with: java-version: 17.0.13 java-distribution: temurin diff --git a/.github/workflows/pitest-analyze-pr.yml b/.github/workflows/pitest-analyze-pr.yml index e9e6fbf3..5afaecd1 100644 --- a/.github/workflows/pitest-analyze-pr.yml +++ b/.github/workflows/pitest-analyze-pr.yml @@ -22,7 +22,7 @@ jobs: objects.githubusercontent.com:443 repo.maven.apache.org:443 - name: Check out code and set up JDK and Maven - uses: s4u/setup-maven-action@489441643219d2b93ee2a127b2402eb640a1b947 # v1.13.0 + uses: s4u/setup-maven-action@382542f77617f34e56bf83868920a4d45b7451e7 # v1.16.0 with: checkout-fetch-depth: 2 java-version: 17.0.13 diff --git a/.github/workflows/pitest-update-pr.yml b/.github/workflows/pitest-update-pr.yml index 401d0b2d..162a16e8 100644 --- a/.github/workflows/pitest-update-pr.yml +++ b/.github/workflows/pitest-update-pr.yml @@ -31,7 +31,7 @@ jobs: objects.githubusercontent.com:443 repo.maven.apache.org:443 - name: Check out code and set up JDK and Maven - uses: s4u/setup-maven-action@489441643219d2b93ee2a127b2402eb640a1b947 # v1.13.0 + uses: s4u/setup-maven-action@382542f77617f34e56bf83868920a4d45b7451e7 # v1.16.0 with: java-version: 17.0.13 java-distribution: temurin diff --git a/.github/workflows/run-integration-tests.yml b/.github/workflows/run-integration-tests.yml index 774716a6..abf0e32f 100644 --- a/.github/workflows/run-integration-tests.yml +++ b/.github/workflows/run-integration-tests.yml @@ -33,7 +33,7 @@ jobs: repo.maven.apache.org:443 repository.sonatype.org:443 - name: Check out code and set up JDK and Maven - uses: s4u/setup-maven-action@489441643219d2b93ee2a127b2402eb640a1b947 # v1.13.0 + uses: s4u/setup-maven-action@382542f77617f34e56bf83868920a4d45b7451e7 # v1.16.0 with: checkout-ref: "refs/pull/${{ github.event.issue.number }}/head" java-version: 17.0.13 diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 4d73726a..ba8d2cc7 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -35,7 +35,7 @@ jobs: *.sonarcloud.io:443 sonarcloud.io:443 - name: Check out code and set up JDK and Maven - uses: s4u/setup-maven-action@489441643219d2b93ee2a127b2402eb640a1b947 # v1.13.0 + uses: s4u/setup-maven-action@382542f77617f34e56bf83868920a4d45b7451e7 # v1.16.0 with: checkout-fetch-depth: 0 java-version: 17.0.13 From f08fc344f5c0c5eb146e74e8079993794da11e3e Mon Sep 17 00:00:00 2001 From: Stephan Schroevers Date: Sun, 10 Nov 2024 15:14:08 +0100 Subject: [PATCH 301/312] Track `StreamFlatMapOptional` Refaster rule caveat (#1410) --- .../tech/picnic/errorprone/refasterrules/OptionalRules.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/OptionalRules.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/OptionalRules.java index e053959b..99b7acd5 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/OptionalRules.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/OptionalRules.java @@ -279,6 +279,9 @@ final class OptionalRules { */ // XXX: Do we need the `.filter(Optional::isPresent)`? If it's absent the caller probably assumed // that the values are present. (If we drop it, we should rewrite vacuous filter steps.) + // XXX: The rewritten `filter`/`map` expression may be more performant than its replacement. See + // https://github.com/palantir/gradle-baseline/pull/2946. (There are plans to pair Refaster rules + // with JMH benchmarks; this would be a great use case.) static final class StreamFlatMapOptional { @BeforeTemplate Stream before(Stream> stream) { From 89f918c23e3b3038a85aa0b2e53cf9e8e2c6e6a5 Mon Sep 17 00:00:00 2001 From: Stephan Schroevers Date: Sun, 10 Nov 2024 18:26:40 +0100 Subject: [PATCH 302/312] Update `step-security/harden-runner` configuration (#1411) By allowing Docker Hub and Maven Central access. --- .github/workflows/openssf-scorecard.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/openssf-scorecard.yml b/.github/workflows/openssf-scorecard.yml index a0f62732..9c1fd274 100644 --- a/.github/workflows/openssf-scorecard.yml +++ b/.github/workflows/openssf-scorecard.yml @@ -31,7 +31,9 @@ jobs: api.scorecard.dev:443 api.securityscorecards.dev:443 github.com:443 + index.docker.io:443 oss-fuzz-build-logs.storage.googleapis.com:443 + repo.maven.apache.org:443 *.sigstore.dev:443 www.bestpractices.dev:443 - name: Check out code From 08eb7e7699a24c3eb0ff6005f6e30d252f92ea9a Mon Sep 17 00:00:00 2001 From: Picnic-DevPla-Bot <168541957+Picnic-DevPla-Bot@users.noreply.github.com> Date: Sun, 10 Nov 2024 18:38:30 +0100 Subject: [PATCH 303/312] Upgrade OpenRewrite Templating 1.16.3 -> 1.17.0 (#1409) See: - https://github.com/openrewrite/rewrite-templating/releases/tag/v1.17.0 - https://github.com/openrewrite/rewrite-templating/compare/v1.16.3...v1.17.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 74e613a4..67f07b02 100644 --- a/pom.xml +++ b/pom.xml @@ -220,7 +220,7 @@ 1.0.1 0.12.1 1.1.4 - 1.16.3 + 1.17.0 3.2.3 From 7599b0f22f5bdd9a5ae5ea73073c2c8c17cbb301 Mon Sep 17 00:00:00 2001 From: Picnic-DevPla-Bot <168541957+Picnic-DevPla-Bot@users.noreply.github.com> Date: Sun, 10 Nov 2024 21:33:56 +0100 Subject: [PATCH 304/312] Upgrade step-security/harden-runner v2.8.0 -> v2.10.1 (#1404) See: - https://github.com/step-security/harden-runner/releases/tag/v2.10.1 - https://github.com/step-security/harden-runner/releases/tag/v2.10.0 - https://github.com/step-security/harden-runner/releases/tag/v2.9.1 - https://github.com/step-security/harden-runner/releases/tag/v2.9.0 - https://github.com/step-security/harden-runner/releases/tag/v2.8.1 --- .github/workflows/build.yml | 2 +- .github/workflows/codeql.yml | 2 +- .github/workflows/deploy-website.yml | 4 ++-- .github/workflows/openssf-scorecard.yml | 2 +- .github/workflows/pitest-analyze-pr.yml | 2 +- .github/workflows/pitest-update-pr.yml | 2 +- .github/workflows/run-integration-tests.yml | 2 +- .github/workflows/sonarcloud.yml | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cc5b57df..1d04d05b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -26,7 +26,7 @@ jobs: continue-on-error: ${{ matrix.experimental }} steps: - name: Install Harden-Runner - uses: step-security/harden-runner@f086349bfa2bd1361f7909c78558e816508cdc10 # v2.8.0 + uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1 with: disable-sudo: true egress-policy: block diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 74e01235..00461690 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -22,7 +22,7 @@ jobs: runs-on: ubuntu-24.04 steps: - name: Install Harden-Runner - uses: step-security/harden-runner@f086349bfa2bd1361f7909c78558e816508cdc10 # v2.8.0 + uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1 with: disable-sudo: true egress-policy: block diff --git a/.github/workflows/deploy-website.yml b/.github/workflows/deploy-website.yml index eb10e862..dba163b2 100644 --- a/.github/workflows/deploy-website.yml +++ b/.github/workflows/deploy-website.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-24.04 steps: - name: Install Harden-Runner - uses: step-security/harden-runner@f086349bfa2bd1361f7909c78558e816508cdc10 # v2.8.0 + uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1 with: disable-sudo: true egress-policy: block @@ -74,7 +74,7 @@ jobs: url: ${{ steps.deployment.outputs.page_url }} steps: - name: Install Harden-Runner - uses: step-security/harden-runner@f086349bfa2bd1361f7909c78558e816508cdc10 # v2.8.0 + uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1 with: disable-sudo: true egress-policy: block diff --git a/.github/workflows/openssf-scorecard.yml b/.github/workflows/openssf-scorecard.yml index 9c1fd274..0f74e657 100644 --- a/.github/workflows/openssf-scorecard.yml +++ b/.github/workflows/openssf-scorecard.yml @@ -21,7 +21,7 @@ jobs: runs-on: ubuntu-24.04 steps: - name: Install Harden-Runner - uses: step-security/harden-runner@f086349bfa2bd1361f7909c78558e816508cdc10 # v2.8.0 + uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1 with: disable-sudo: true egress-policy: block diff --git a/.github/workflows/pitest-analyze-pr.yml b/.github/workflows/pitest-analyze-pr.yml index 5afaecd1..c003a4c0 100644 --- a/.github/workflows/pitest-analyze-pr.yml +++ b/.github/workflows/pitest-analyze-pr.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-24.04 steps: - name: Install Harden-Runner - uses: step-security/harden-runner@f086349bfa2bd1361f7909c78558e816508cdc10 # v2.8.0 + uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1 with: disable-sudo: true egress-policy: block diff --git a/.github/workflows/pitest-update-pr.yml b/.github/workflows/pitest-update-pr.yml index 162a16e8..92c78957 100644 --- a/.github/workflows/pitest-update-pr.yml +++ b/.github/workflows/pitest-update-pr.yml @@ -20,7 +20,7 @@ jobs: runs-on: ubuntu-24.04 steps: - name: Install Harden-Runner - uses: step-security/harden-runner@f086349bfa2bd1361f7909c78558e816508cdc10 # v2.8.0 + uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1 with: disable-sudo: true egress-policy: block diff --git a/.github/workflows/run-integration-tests.yml b/.github/workflows/run-integration-tests.yml index abf0e32f..013e45f7 100644 --- a/.github/workflows/run-integration-tests.yml +++ b/.github/workflows/run-integration-tests.yml @@ -19,7 +19,7 @@ jobs: runs-on: ubuntu-24.04 steps: - name: Install Harden-Runner - uses: step-security/harden-runner@f086349bfa2bd1361f7909c78558e816508cdc10 # v2.8.0 + uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1 with: disable-sudo: true egress-policy: block diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index ba8d2cc7..43aa6c4e 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -19,7 +19,7 @@ jobs: runs-on: ubuntu-24.04 steps: - name: Install Harden-Runner - uses: step-security/harden-runner@f086349bfa2bd1361f7909c78558e816508cdc10 # v2.8.0 + uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1 with: disable-sudo: true egress-policy: block From 6396def5889ec768b845963be6bec90e9a22016e Mon Sep 17 00:00:00 2001 From: Picnic-DevPla-Bot <168541957+Picnic-DevPla-Bot@users.noreply.github.com> Date: Sun, 10 Nov 2024 22:04:47 +0100 Subject: [PATCH 305/312] Upgrade sonar-maven-plugin 4.0.0.4121 -> 5.0.0.4389 (#1405) See: - https://github.com/SonarSource/sonar-scanner-maven/releases/tag/5.0.0.4389 - https://github.com/SonarSource/sonar-scanner-maven/compare/4.0.0.4121...5.0.0.4389 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 67f07b02..8664709d 100644 --- a/pom.xml +++ b/pom.xml @@ -1580,7 +1580,7 @@ org.sonarsource.scanner.maven sonar-maven-plugin - 4.0.0.4121 + 5.0.0.4389 From 13f1fa3167adb6e117fefc7b9f1f6f89c252582d Mon Sep 17 00:00:00 2001 From: Picnic-DevPla-Bot <168541957+Picnic-DevPla-Bot@users.noreply.github.com> Date: Mon, 11 Nov 2024 07:44:12 +0100 Subject: [PATCH 306/312] Upgrade ossf/scorecard-action v2.3.3 -> v2.4.0 (#1403) See: - https://github.com/ossf/scorecard-action/releases/tag/v2.4.0 - https://github.com/ossf/scorecard-action/compare/v2.3.3...v2.4.0 --- .github/workflows/openssf-scorecard.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/openssf-scorecard.yml b/.github/workflows/openssf-scorecard.yml index 0f74e657..6b0e7a31 100644 --- a/.github/workflows/openssf-scorecard.yml +++ b/.github/workflows/openssf-scorecard.yml @@ -41,7 +41,7 @@ jobs: with: persist-credentials: false - name: Run OpenSSF Scorecard analysis - uses: ossf/scorecard-action@dc50aa9510b46c811795eb24b2f1ba02a914e534 # v2.3.3 + uses: ossf/scorecard-action@62b2cac7ed8198b15735ed49ab1e5cf35480ba46 # v2.4.0 with: results_file: results.sarif results_format: sarif From 00549a3ba6a7624a8f6c6ead0aad0aa007c00412 Mon Sep 17 00:00:00 2001 From: Picnic-DevPla-Bot <168541957+Picnic-DevPla-Bot@users.noreply.github.com> Date: Mon, 11 Nov 2024 07:54:49 +0100 Subject: [PATCH 307/312] Upgrade org.openrewrite:rewrite-java-17 8.38.1 -> 8.40.0 (#1390) See: - https://github.com/openrewrite/rewrite/releases/tag/v8.40.0 - https://github.com/openrewrite/rewrite/releases/tag/v8.39.0 - https://github.com/openrewrite/rewrite/releases/tag/v8.38.3 - https://github.com/openrewrite/rewrite/releases/tag/v8.38.2 - https://github.com/openrewrite/rewrite/compare/v8.38.1...v8.40.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 8664709d..8d28abad 100644 --- a/pom.xml +++ b/pom.xml @@ -491,7 +491,7 @@ org.openrewrite rewrite-java-17 - 8.38.1 + 8.40.0 org.openrewrite From ed32cbae067694e8e5a0d0f0d15454260993ce23 Mon Sep 17 00:00:00 2001 From: Stephan Schroevers Date: Mon, 11 Nov 2024 08:46:49 +0100 Subject: [PATCH 308/312] Update `step-security/harden-runner` configuration (#1412) By allowing access to Open Source Insights. --- .github/workflows/openssf-scorecard.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/openssf-scorecard.yml b/.github/workflows/openssf-scorecard.yml index 6b0e7a31..80a4e3de 100644 --- a/.github/workflows/openssf-scorecard.yml +++ b/.github/workflows/openssf-scorecard.yml @@ -26,6 +26,7 @@ jobs: disable-sudo: true egress-policy: block allowed-endpoints: > + api.deps.dev:443 api.github.com:443 api.osv.dev:443 api.scorecard.dev:443 From 6a50fe2d9c0e56457c9633e84b1d4040e42a0cba Mon Sep 17 00:00:00 2001 From: Phil Werli Date: Mon, 11 Nov 2024 10:42:05 +0100 Subject: [PATCH 309/312] Introduce `Instant{Identity,TruncatedTo{Milliseconds,Seconds}}` Refaster rules (#1395) While there, have `IdentityConversion` support `Instant#from`. --- .../bugpatterns/IdentityConversion.java | 2 + .../refasterrules/OptionalRules.java | 5 +- .../errorprone/refasterrules/TimeRules.java | 57 +++++++++++++++++++ .../bugpatterns/IdentityConversionTest.java | 6 ++ .../refasterrules/TimeRulesTestInput.java | 26 +++++++++ .../refasterrules/TimeRulesTestOutput.java | 25 ++++++++ 6 files changed, 117 insertions(+), 4 deletions(-) diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/IdentityConversion.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/IdentityConversion.java index 0c369404..14464da9 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/IdentityConversion.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/IdentityConversion.java @@ -39,6 +39,7 @@ import com.sun.source.tree.MemberSelectTree; import com.sun.source.tree.MethodInvocationTree; import com.sun.tools.javac.code.Type; import com.sun.tools.javac.code.Types; +import java.time.Instant; import java.util.Arrays; import java.util.List; import tech.picnic.errorprone.utils.SourceCode; @@ -84,6 +85,7 @@ public final class IdentityConversion extends BugChecker implements MethodInvoca ImmutableSetMultimap.class.getCanonicalName(), ImmutableTable.class.getCanonicalName()) .named("copyOf"), + staticMethod().onClass(Instant.class.getCanonicalName()).namedAnyOf("from"), staticMethod().onClass(Matchers.class.getCanonicalName()).namedAnyOf("allOf", "anyOf"), staticMethod().onClass("reactor.adapter.rxjava.RxJava2Adapter"), staticMethod() diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/OptionalRules.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/OptionalRules.java index 99b7acd5..cc8928aa 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/OptionalRules.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/OptionalRules.java @@ -398,10 +398,7 @@ final class OptionalRules { } } - /** - * Avoid unnecessary operations on an {@link Optional} that ultimately result in that very same - * {@link Optional}. - */ + /** Don't unnecessarily transform an {@link Optional} to an equivalent instance. */ static final class OptionalIdentity { @BeforeTemplate @SuppressWarnings("NestedOptionals") diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/TimeRules.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/TimeRules.java index 9e48cf80..be2382d5 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/TimeRules.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/TimeRules.java @@ -142,6 +142,63 @@ final class TimeRules { } } + /** Don't unnecessarily transform an {@link Instant} to an equivalent instance. */ + static final class InstantIdentity { + @BeforeTemplate + Instant before(Instant instant, TemporalUnit temporalUnit) { + return Refaster.anyOf( + instant.plus(Duration.ZERO), + instant.plus(0, temporalUnit), + instant.plusNanos(0), + instant.plusMillis(0), + instant.plusSeconds(0), + instant.minus(Duration.ZERO), + instant.minus(0, temporalUnit), + instant.minusNanos(0), + instant.minusMillis(0), + instant.minusSeconds(0), + Instant.parse(instant.toString()), + instant.truncatedTo(ChronoUnit.NANOS), + Instant.ofEpochSecond(instant.getEpochSecond(), instant.getNano())); + } + + @AfterTemplate + Instant after(Instant instant) { + return instant; + } + } + + /** + * Prefer {@link Instant#truncatedTo(TemporalUnit)} over less obvious alternatives. + * + *

Note that {@link Instant#toEpochMilli()} throws an {@link ArithmeticException} for dates + * very far in the past or future, while the suggested alternative doesn't. + */ + static final class InstantTruncatedToMilliseconds { + @BeforeTemplate + Instant before(Instant instant) { + return Instant.ofEpochMilli(instant.toEpochMilli()); + } + + @AfterTemplate + Instant after(Instant instant) { + return instant.truncatedTo(ChronoUnit.MILLIS); + } + } + + /** Prefer {@link Instant#truncatedTo(TemporalUnit)} over less obvious alternatives. */ + static final class InstantTruncatedToSeconds { + @BeforeTemplate + Instant before(Instant instant) { + return Instant.ofEpochSecond(instant.getEpochSecond()); + } + + @AfterTemplate + Instant after(Instant instant) { + return instant.truncatedTo(ChronoUnit.SECONDS); + } + } + /** Prefer {@link Instant#atOffset(ZoneOffset)} over more verbose alternatives. */ static final class InstantAtOffset { @BeforeTemplate diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/IdentityConversionTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/IdentityConversionTest.java index 631acdad..f9286f4e 100644 --- a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/IdentityConversionTest.java +++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/IdentityConversionTest.java @@ -28,6 +28,8 @@ final class IdentityConversionTest { "import com.google.common.collect.ImmutableTable;", "import com.google.errorprone.matchers.Matcher;", "import com.google.errorprone.matchers.Matchers;", + "import java.time.Instant;", + "import java.time.ZonedDateTime;", "import reactor.adapter.rxjava.RxJava2Adapter;", "import reactor.core.publisher.Flux;", "import reactor.core.publisher.Mono;", @@ -149,6 +151,10 @@ final class IdentityConversionTest { " // BUG: Diagnostic contains:", " ImmutableTable o11 = ImmutableTable.copyOf(ImmutableTable.of());", "", + " Instant instant1 = Instant.from(ZonedDateTime.now());", + " // BUG: Diagnostic contains:", + " Instant instant2 = Instant.from(Instant.now());", + "", " // BUG: Diagnostic contains:", " Matcher allOf1 = Matchers.allOf(instanceMethod());", " Matcher allOf2 = Matchers.allOf(instanceMethod(), staticMethod());", diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/TimeRulesTestInput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/TimeRulesTestInput.java index 58bac6c5..8b22e112 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/TimeRulesTestInput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/TimeRulesTestInput.java @@ -66,6 +66,32 @@ final class TimeRulesTest implements RefasterRuleCollectionTestCase { return Instant.EPOCH.atZone(ZoneOffset.UTC).toOffsetDateTime(); } + ImmutableSet testInstantIdentity() { + return ImmutableSet.of( + Instant.EPOCH.plusMillis(1).plus(Duration.ZERO), + Instant.EPOCH.plusMillis(2).plus(0, ChronoUnit.MILLIS), + Instant.EPOCH.plusMillis(3).plusNanos(0L), + Instant.EPOCH.plusMillis(4).plusMillis(0), + Instant.EPOCH.plusMillis(5).plusSeconds(0L), + Instant.EPOCH.plusMillis(6).minus(Duration.ZERO), + Instant.EPOCH.plusMillis(7).minus(0, ChronoUnit.SECONDS), + Instant.EPOCH.plusMillis(8).minusNanos(0L), + Instant.EPOCH.plusMillis(9).minusMillis(0), + Instant.EPOCH.plusMillis(10).minusSeconds(0L), + Instant.parse(Instant.EPOCH.plusMillis(11).toString()), + Instant.EPOCH.plusMillis(12).truncatedTo(ChronoUnit.NANOS), + Instant.ofEpochSecond( + Instant.EPOCH.plusMillis(13).getEpochSecond(), Instant.EPOCH.plusMillis(13).getNano())); + } + + Instant testInstantTruncatedToMilliseconds() { + return Instant.ofEpochMilli(Instant.EPOCH.toEpochMilli()); + } + + Instant testInstantTruncatedToSeconds() { + return Instant.ofEpochSecond(Instant.EPOCH.getEpochSecond()); + } + OffsetDateTime testInstantAtOffset() { return OffsetDateTime.ofInstant(Instant.EPOCH, ZoneOffset.UTC); } diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/TimeRulesTestOutput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/TimeRulesTestOutput.java index ee4f347b..cd739835 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/TimeRulesTestOutput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/TimeRulesTestOutput.java @@ -66,6 +66,31 @@ final class TimeRulesTest implements RefasterRuleCollectionTestCase { return OffsetDateTime.ofInstant(Instant.EPOCH, ZoneOffset.UTC); } + ImmutableSet testInstantIdentity() { + return ImmutableSet.of( + Instant.EPOCH.plusMillis(1), + Instant.EPOCH.plusMillis(2), + Instant.EPOCH.plusMillis(3), + Instant.EPOCH.plusMillis(4), + Instant.EPOCH.plusMillis(5), + Instant.EPOCH.plusMillis(6), + Instant.EPOCH.plusMillis(7), + Instant.EPOCH.plusMillis(8), + Instant.EPOCH.plusMillis(9), + Instant.EPOCH.plusMillis(10), + Instant.EPOCH.plusMillis(11), + Instant.EPOCH.plusMillis(12), + Instant.EPOCH.plusMillis(13)); + } + + Instant testInstantTruncatedToMilliseconds() { + return Instant.EPOCH.truncatedTo(ChronoUnit.MILLIS); + } + + Instant testInstantTruncatedToSeconds() { + return Instant.EPOCH.truncatedTo(ChronoUnit.SECONDS); + } + OffsetDateTime testInstantAtOffset() { return Instant.EPOCH.atOffset(ZoneOffset.UTC); } From da9b313ff7f6607b98fdd6f0bd36374a450d9df1 Mon Sep 17 00:00:00 2001 From: Phil Werli Date: Mon, 11 Nov 2024 14:08:05 +0100 Subject: [PATCH 310/312] Introduce assorted Reactor `StepVerifier` Refaster rules (#1132) --- .../refasterrules/ReactorRules.java | 84 +++++++++++++++++++ .../refasterrules/ReactorRulesTestInput.java | 48 +++++++++-- .../refasterrules/ReactorRulesTestOutput.java | 40 ++++++++- 3 files changed, 163 insertions(+), 9 deletions(-) diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/ReactorRules.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/ReactorRules.java index d1202f83..404f7830 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/ReactorRules.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/ReactorRules.java @@ -1768,6 +1768,60 @@ final class ReactorRules { } } + /** + * Prefer {@link StepVerifier#verify()} over a dangling {@link + * StepVerifier#verifyThenAssertThat()}. + */ + // XXX: Application of this rule (and several others in this class) will cause invalid code if the + // result of the rewritten expression is dereferenced. Consider introducing a bug checker that + // identifies rules that change the return type of an expression and annotates them accordingly. + // The associated annotation can then be used to instruct an annotation processor to generate + // corresponding `void` rules that match only statements. This would allow the `Refaster` check to + // conditionally skip "not fully safe" rules. This allows conditionally flagging more dubious + // code, at the risk of compilation failures. With this rule, for example, we want to explicitly + // nudge users towards `StepVerifier.Step#assertNext(Consumer)` or + // `StepVerifier.Step#expectNext(Object)`, together with `Step#verifyComplete()`. + static final class StepVerifierVerify { + @BeforeTemplate + StepVerifier.Assertions before(StepVerifier stepVerifier) { + return stepVerifier.verifyThenAssertThat(); + } + + @AfterTemplate + Duration after(StepVerifier stepVerifier) { + return stepVerifier.verify(); + } + } + + /** + * Prefer {@link StepVerifier#verify(Duration)} over a dangling {@link + * StepVerifier#verifyThenAssertThat(Duration)}. + */ + static final class StepVerifierVerifyDuration { + @BeforeTemplate + StepVerifier.Assertions before(StepVerifier stepVerifier, Duration duration) { + return stepVerifier.verifyThenAssertThat(duration); + } + + @AfterTemplate + Duration after(StepVerifier stepVerifier, Duration duration) { + return stepVerifier.verify(duration); + } + } + + /** Don't unnecessarily invoke {@link StepVerifier#verifyLater()} multiple times. */ + static final class StepVerifierVerifyLater { + @BeforeTemplate + StepVerifier before(StepVerifier stepVerifier) { + return stepVerifier.verifyLater().verifyLater(); + } + + @AfterTemplate + StepVerifier after(StepVerifier stepVerifier) { + return stepVerifier.verifyLater(); + } + } + /** Don't unnecessarily have {@link StepVerifier.Step} expect no elements. */ static final class StepVerifierStepIdentity { @BeforeTemplate @@ -1868,6 +1922,12 @@ final class ReactorRules { return step.expectErrorMatches(predicate).verify(); } + @BeforeTemplate + @SuppressWarnings("StepVerifierVerify" /* This is a more specific template. */) + StepVerifier.Assertions before2(StepVerifier.LastStep step, Predicate predicate) { + return step.expectError().verifyThenAssertThat().hasOperatorErrorMatching(predicate); + } + @AfterTemplate Duration after(StepVerifier.LastStep step, Predicate predicate) { return step.verifyErrorMatches(predicate); @@ -1890,6 +1950,30 @@ final class ReactorRules { } } + /** + * Prefer {@link StepVerifier.LastStep#verifyErrorSatisfies(Consumer)} with AssertJ over more + * contrived alternatives. + */ + static final class StepVerifierLastStepVerifyErrorSatisfiesAssertJ { + @BeforeTemplate + @SuppressWarnings("StepVerifierVerify" /* This is a more specific template. */) + StepVerifier.Assertions before(StepVerifier.LastStep step, Class clazz, String message) { + return Refaster.anyOf( + step.expectError() + .verifyThenAssertThat() + .hasOperatorErrorOfType(clazz) + .hasOperatorErrorWithMessage(message), + step.expectError(clazz).verifyThenAssertThat().hasOperatorErrorWithMessage(message), + step.expectErrorMessage(message).verifyThenAssertThat().hasOperatorErrorOfType(clazz)); + } + + @AfterTemplate + @UseImportPolicy(STATIC_IMPORT_ALWAYS) + Duration after(StepVerifier.LastStep step, Class clazz, String message) { + return step.verifyErrorSatisfies(t -> assertThat(t).isInstanceOf(clazz).hasMessage(message)); + } + } + /** * Prefer {@link StepVerifier.LastStep#verifyErrorMessage(String)} over more verbose alternatives. */ diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ReactorRulesTestInput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ReactorRulesTestInput.java index bd6b6ffb..80375ea4 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ReactorRulesTestInput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ReactorRulesTestInput.java @@ -598,6 +598,18 @@ final class ReactorRulesTest implements RefasterRuleCollectionTestCase { return StepVerifier.create(Flux.just(1)); } + Object testStepVerifierVerify() { + return Mono.empty().as(StepVerifier::create).expectError().verifyThenAssertThat(); + } + + Object testStepVerifierVerifyDuration() { + return Mono.empty().as(StepVerifier::create).expectError().verifyThenAssertThat(Duration.ZERO); + } + + StepVerifier testStepVerifierVerifyLater() { + return Mono.empty().as(StepVerifier::create).expectError().verifyLater().verifyLater(); + } + ImmutableSet> testStepVerifierStepIdentity() { return ImmutableSet.of( Mono.just(1).as(StepVerifier::create).expectNext(), @@ -638,17 +650,43 @@ final class ReactorRulesTest implements RefasterRuleCollectionTestCase { .verifyErrorSatisfies(t -> assertThat(t).isInstanceOf(AssertionError.class))); } - Duration testStepVerifierLastStepVerifyErrorMatches() { - return Mono.empty() - .as(StepVerifier::create) - .expectErrorMatches(IllegalArgumentException.class::equals) - .verify(); + ImmutableSet testStepVerifierLastStepVerifyErrorMatches() { + return ImmutableSet.of( + Mono.empty() + .as(StepVerifier::create) + .expectErrorMatches(IllegalArgumentException.class::equals) + .verify(), + Mono.empty() + .as(StepVerifier::create) + .expectError() + .verifyThenAssertThat() + .hasOperatorErrorMatching(IllegalStateException.class::equals)); } Duration testStepVerifierLastStepVerifyErrorSatisfies() { return Mono.empty().as(StepVerifier::create).expectErrorSatisfies(t -> {}).verify(); } + ImmutableSet testStepVerifierLastStepVerifyErrorSatisfiesAssertJ() { + return ImmutableSet.of( + Mono.empty() + .as(StepVerifier::create) + .expectError() + .verifyThenAssertThat() + .hasOperatorErrorOfType(IllegalArgumentException.class) + .hasOperatorErrorWithMessage("foo"), + Mono.empty() + .as(StepVerifier::create) + .expectError(IllegalStateException.class) + .verifyThenAssertThat() + .hasOperatorErrorWithMessage("bar"), + Mono.empty() + .as(StepVerifier::create) + .expectErrorMessage("baz") + .verifyThenAssertThat() + .hasOperatorErrorOfType(AssertionError.class)); + } + Duration testStepVerifierLastStepVerifyErrorMessage() { return Mono.empty().as(StepVerifier::create).expectErrorMessage("foo").verify(); } diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ReactorRulesTestOutput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ReactorRulesTestOutput.java index 048e0895..37f8f4f8 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ReactorRulesTestOutput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ReactorRulesTestOutput.java @@ -586,6 +586,18 @@ final class ReactorRulesTest implements RefasterRuleCollectionTestCase { return Flux.just(1).as(StepVerifier::create); } + Object testStepVerifierVerify() { + return Mono.empty().as(StepVerifier::create).expectError().verify(); + } + + Object testStepVerifierVerifyDuration() { + return Mono.empty().as(StepVerifier::create).expectError().verify(Duration.ZERO); + } + + StepVerifier testStepVerifierVerifyLater() { + return Mono.empty().as(StepVerifier::create).expectError().verifyLater(); + } + ImmutableSet> testStepVerifierStepIdentity() { return ImmutableSet.of( Mono.just(1).as(StepVerifier::create), @@ -619,16 +631,36 @@ final class ReactorRulesTest implements RefasterRuleCollectionTestCase { Mono.empty().as(StepVerifier::create).verifyError(AssertionError.class)); } - Duration testStepVerifierLastStepVerifyErrorMatches() { - return Mono.empty() - .as(StepVerifier::create) - .verifyErrorMatches(IllegalArgumentException.class::equals); + ImmutableSet testStepVerifierLastStepVerifyErrorMatches() { + return ImmutableSet.of( + Mono.empty() + .as(StepVerifier::create) + .verifyErrorMatches(IllegalArgumentException.class::equals), + Mono.empty() + .as(StepVerifier::create) + .verifyErrorMatches(IllegalStateException.class::equals)); } Duration testStepVerifierLastStepVerifyErrorSatisfies() { return Mono.empty().as(StepVerifier::create).verifyErrorSatisfies(t -> {}); } + ImmutableSet testStepVerifierLastStepVerifyErrorSatisfiesAssertJ() { + return ImmutableSet.of( + Mono.empty() + .as(StepVerifier::create) + .verifyErrorSatisfies( + t -> assertThat(t).isInstanceOf(IllegalArgumentException.class).hasMessage("foo")), + Mono.empty() + .as(StepVerifier::create) + .verifyErrorSatisfies( + t -> assertThat(t).isInstanceOf(IllegalStateException.class).hasMessage("bar")), + Mono.empty() + .as(StepVerifier::create) + .verifyErrorSatisfies( + t -> assertThat(t).isInstanceOf(AssertionError.class).hasMessage("baz"))); + } + Duration testStepVerifierLastStepVerifyErrorMessage() { return Mono.empty().as(StepVerifier::create).verifyErrorMessage("foo"); } From a51ff4de4e0d0f9fa131185fb1f9fb670c01c867 Mon Sep 17 00:00:00 2001 From: Picnic-DevPla-Bot <168541957+Picnic-DevPla-Bot@users.noreply.github.com> Date: Tue, 12 Nov 2024 11:11:52 +0100 Subject: [PATCH 311/312] Upgrade actions/checkout v4.1.6 -> v4.2.2 (#1401) See: - https://github.com/actions/checkout/blob/HEAD/CHANGELOG.md#v422 - https://github.com/actions/checkout/blob/HEAD/CHANGELOG.md#v421 - https://github.com/actions/checkout/blob/HEAD/CHANGELOG.md#v420 - https://github.com/actions/checkout/blob/HEAD/CHANGELOG.md#v417 --- .github/workflows/deploy-website.yml | 2 +- .github/workflows/openssf-scorecard.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-website.yml b/.github/workflows/deploy-website.yml index dba163b2..eb5084b0 100644 --- a/.github/workflows/deploy-website.yml +++ b/.github/workflows/deploy-website.yml @@ -39,7 +39,7 @@ jobs: www.youtube.com:443 youtrack.jetbrains.com:443 - name: Check out code - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: persist-credentials: false - uses: ruby/setup-ruby@7d3497fd78c07c0d84ebafa58d8dac60cd1f0763 # v1.199.0 diff --git a/.github/workflows/openssf-scorecard.yml b/.github/workflows/openssf-scorecard.yml index 80a4e3de..5d2ea817 100644 --- a/.github/workflows/openssf-scorecard.yml +++ b/.github/workflows/openssf-scorecard.yml @@ -38,7 +38,7 @@ jobs: *.sigstore.dev:443 www.bestpractices.dev:443 - name: Check out code - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: persist-credentials: false - name: Run OpenSSF Scorecard analysis From 13684ec59d98c22e115434e70f7aff7991e7b5e8 Mon Sep 17 00:00:00 2001 From: Stephan Schroevers Date: Wed, 13 Nov 2024 18:27:41 +0100 Subject: [PATCH 312/312] Replace deprecated `build-helper:remove-project-artifact` goal (#1413) --- .github/workflows/build.yml | 2 +- .github/workflows/run-integration-tests.yml | 2 +- pom.xml | 5 ----- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1d04d05b..74d4a4f0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -54,6 +54,6 @@ jobs: - name: Build project with self-check against Error Prone fork run: mvn -T1C clean verify -Perror-prone-fork -Pnon-maven-central -Pself-check -s settings.xml - name: Remove installed project artifacts - run: mvn build-helper:remove-project-artifact + run: mvn dependency:purge-local-repository -DmanualInclude='${project.groupId}' -DresolutionFuzziness=groupId # XXX: Enable Codecov once we "go public". diff --git a/.github/workflows/run-integration-tests.yml b/.github/workflows/run-integration-tests.yml index 013e45f7..dd4b8b97 100644 --- a/.github/workflows/run-integration-tests.yml +++ b/.github/workflows/run-integration-tests.yml @@ -50,4 +50,4 @@ jobs: name: integration-test-checkstyle path: "${{ runner.temp }}/artifacts" - name: Remove installed project artifacts - run: mvn build-helper:remove-project-artifact + run: mvn dependency:purge-local-repository -DmanualInclude='${project.groupId}' -DresolutionFuzziness=groupId diff --git a/pom.xml b/pom.xml index 8d28abad..c3d3e4d0 100644 --- a/pom.xml +++ b/pom.xml @@ -1310,11 +1310,6 @@ true - - org.codehaus.mojo - build-helper-maven-plugin - 3.6.0 - org.codehaus.mojo license-maven-plugin