From a7fafcdc91d0aae50f01a811fef3945eb264131f Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Thu, 16 Mar 2023 15:24:22 +0000 Subject: [PATCH 001/129] Excavator: Upgrade dependencies (#2523) --- gradle-baseline-java/src/main/resources/checkstyle.version | 2 +- versions.props | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle-baseline-java/src/main/resources/checkstyle.version b/gradle-baseline-java/src/main/resources/checkstyle.version index e102ec566..e3cbcda79 100644 --- a/gradle-baseline-java/src/main/resources/checkstyle.version +++ b/gradle-baseline-java/src/main/resources/checkstyle.version @@ -1 +1 @@ -10.8.1 \ No newline at end of file +10.9.0 \ No newline at end of file diff --git a/versions.props b/versions.props index 52192f6e3..ca7e17f37 100644 --- a/versions.props +++ b/versions.props @@ -12,7 +12,7 @@ org.immutables:* = 2.9.3 org.ow2.asm:asm = 9.4 com.google.errorprone:error_prone_* = 2.18.0 com.googlecode.java-diff-utils:diffutils = 1.3.0 -com.puppycrawl.tools:checkstyle = 10.8.1 +com.puppycrawl.tools:checkstyle = 10.9.0 com.palantir.gradle.utils:* = 0.1.0 com.uber.nullaway:nullaway = 0.10.10 From 13318670c25136eacfcb2e6fd7ea689f98fd3c73 Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Thu, 16 Mar 2023 16:44:09 +0000 Subject: [PATCH 002/129] Excavator: Upgrades Baseline to the latest version (#2524) --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index fc6b277e0..2882fdb52 100644 --- a/build.gradle +++ b/build.gradle @@ -14,7 +14,7 @@ buildscript { classpath 'com.palantir.gradle.externalpublish:gradle-external-publish-plugin:1.12.0' classpath 'com.palantir.gradle.consistentversions:gradle-consistent-versions:2.11.0' classpath 'com.gradle.publish:plugin-publish-plugin:1.1.0' - classpath 'com.palantir.baseline:gradle-baseline-java:4.192.0' + classpath 'com.palantir.baseline:gradle-baseline-java:5.0.0' classpath 'com.palantir.javaformat:gradle-palantir-java-format:2.28.0' } } From b9008c0cd80835d370d80794a238c99f4f8563e2 Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Wed, 22 Mar 2023 11:43:00 +0000 Subject: [PATCH 003/129] Excavator: Update policy-bot config (#2527) --- .policy.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.policy.yml b/.policy.yml index a436f8b96..b9dc830bb 100644 --- a/.policy.yml +++ b/.policy.yml @@ -81,6 +81,7 @@ approval_rules: - "^versions.lock$" - "^internal/generated/.*" - "^internal/generated_src/.*" + - "^gradle-baseline-java/src/main/resources/checkstyle.version$" has_valid_signatures_by_keys: key_ids: ["C9AF124A484882E0"] From 1ee4197524b3cc71a3a9e5b95ca2dbdbecf3e1f9 Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Wed, 22 Mar 2023 21:17:14 +0000 Subject: [PATCH 004/129] Excavator: Upgrade dependencies (#2525) --- .../src/main/resources/checkstyle.version | 2 +- versions.lock | 6 +++--- versions.props | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/gradle-baseline-java/src/main/resources/checkstyle.version b/gradle-baseline-java/src/main/resources/checkstyle.version index e3cbcda79..686743019 100644 --- a/gradle-baseline-java/src/main/resources/checkstyle.version +++ b/gradle-baseline-java/src/main/resources/checkstyle.version @@ -1 +1 @@ -10.9.0 \ No newline at end of file +10.9.2 \ No newline at end of file diff --git a/versions.lock b/versions.lock index d4b00fca6..35ba768f7 100644 --- a/versions.lock +++ b/versions.lock @@ -91,7 +91,7 @@ com.netflix.nebula:nebula-test:10.2.0 (1 constraints: 35052d3b) com.palantir.conjure.java:conjure-lib:6.77.0 (1 constraints: 4605743b) com.palantir.conjure.java.api:errors:2.34.0 (2 constraints: 6d21c6b0) com.palantir.conjure.java.api:test-utils:2.34.0 (1 constraints: 3b05433b) -com.palantir.conjure.java.runtime:conjure-java-annotations:7.40.0 (1 constraints: 3d05593b) +com.palantir.conjure.java.runtime:conjure-java-annotations:7.41.0 (1 constraints: 3e055c3b) com.palantir.ri:resource-identifier:2.5.0 (1 constraints: ef0f7999) com.palantir.safe-logging:logger:3.2.0 (2 constraints: da127d36) com.palantir.safe-logging:logger-slf4j:3.2.0 (1 constraints: 000e5942) @@ -100,7 +100,7 @@ com.palantir.safe-logging:preconditions:3.2.0 (6 constraints: 1457bcb5) com.palantir.safe-logging:preconditions-assertj:3.2.0 (1 constraints: 07050036) com.palantir.safe-logging:safe-logging:3.2.0 (8 constraints: 5f77a6d7) com.palantir.tokens:auth-tokens:3.17.0 (2 constraints: 5f1502db) -com.palantir.tritium:tritium-registry:0.62.0 (1 constraints: 3a053d3b) +com.palantir.tritium:tritium-registry:0.63.0 (1 constraints: 3b05403b) io.dropwizard.metrics:metrics-core:4.1.1 (1 constraints: 901088a5) io.r2dbc:r2dbc-spi:1.0.0.RELEASE (1 constraints: ea08e898) javax.ws.rs:javax.ws.rs-api:2.1.1 (1 constraints: ec0f6e99) @@ -116,7 +116,7 @@ org.hamcrest:hamcrest:2.2 (2 constraints: 43187376) org.hamcrest:hamcrest-core:2.2 (4 constraints: 2b2b359e) org.hamcrest:hamcrest-library:2.2 (1 constraints: fc138e38) org.jetbrains:annotations:23.0.0 (2 constraints: f8204e6d) -org.jooq:jooq:3.18.0 (1 constraints: 3e054d3b) +org.jooq:jooq:3.18.1 (1 constraints: 3f054e3b) org.junit.jupiter:junit-jupiter:5.9.2 (1 constraints: 12052136) org.junit.jupiter:junit-jupiter-api:5.9.2 (5 constraints: 6353b5bf) org.junit.jupiter:junit-jupiter-engine:5.9.2 (1 constraints: 0d0ee23b) diff --git a/versions.props b/versions.props index ca7e17f37..3dd709396 100644 --- a/versions.props +++ b/versions.props @@ -6,13 +6,13 @@ commons-lang:commons-lang = 2.6 org.apache.maven.shared:maven-dependency-analyzer = 1.13.0 org.apache.maven:maven-core = 3.8.5 org.inferred:freebuilder = 1.14.6 -org.jooq:jooq = 3.18.0 +org.jooq:jooq = 3.18.1 org.slf4j:* = 1.7.36 org.immutables:* = 2.9.3 org.ow2.asm:asm = 9.4 com.google.errorprone:error_prone_* = 2.18.0 com.googlecode.java-diff-utils:diffutils = 1.3.0 -com.puppycrawl.tools:checkstyle = 10.9.0 +com.puppycrawl.tools:checkstyle = 10.9.2 com.palantir.gradle.utils:* = 0.1.0 com.uber.nullaway:nullaway = 0.10.10 @@ -22,9 +22,9 @@ com.github.stefanbirkner:system-rules = 1.19.0 com.netflix.nebula:nebula-test = 10.2.0 com.palantir.conjure.java:* = 6.77.0 com.palantir.conjure.java.api:* = 2.34.0 -com.palantir.conjure.java.runtime:* = 7.40.0 +com.palantir.conjure.java.runtime:* = 7.41.0 com.palantir.tokens:auth-tokens = 3.17.0 -com.palantir.tritium:* = 0.62.0 +com.palantir.tritium:* = 0.63.0 commons-io:* = 2.11.0 junit:junit = 4.13.2 net.lingala.zip4j:zip4j = 1.3.2 From bbde9316537b385e37a909da5ba5b12e763aea96 Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Thu, 23 Mar 2023 02:58:14 +0000 Subject: [PATCH 005/129] Excavator: Upgrade dependencies (#2528) --- versions.lock | 2 +- versions.props | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/versions.lock b/versions.lock index 35ba768f7..a5d405f1e 100644 --- a/versions.lock +++ b/versions.lock @@ -91,7 +91,7 @@ com.netflix.nebula:nebula-test:10.2.0 (1 constraints: 35052d3b) com.palantir.conjure.java:conjure-lib:6.77.0 (1 constraints: 4605743b) com.palantir.conjure.java.api:errors:2.34.0 (2 constraints: 6d21c6b0) com.palantir.conjure.java.api:test-utils:2.34.0 (1 constraints: 3b05433b) -com.palantir.conjure.java.runtime:conjure-java-annotations:7.41.0 (1 constraints: 3e055c3b) +com.palantir.conjure.java.runtime:conjure-java-annotations:7.42.0 (1 constraints: 3f055f3b) com.palantir.ri:resource-identifier:2.5.0 (1 constraints: ef0f7999) com.palantir.safe-logging:logger:3.2.0 (2 constraints: da127d36) com.palantir.safe-logging:logger-slf4j:3.2.0 (1 constraints: 000e5942) diff --git a/versions.props b/versions.props index 3dd709396..2836a1bb8 100644 --- a/versions.props +++ b/versions.props @@ -22,7 +22,7 @@ com.github.stefanbirkner:system-rules = 1.19.0 com.netflix.nebula:nebula-test = 10.2.0 com.palantir.conjure.java:* = 6.77.0 com.palantir.conjure.java.api:* = 2.34.0 -com.palantir.conjure.java.runtime:* = 7.41.0 +com.palantir.conjure.java.runtime:* = 7.42.0 com.palantir.tokens:auth-tokens = 3.17.0 com.palantir.tritium:* = 0.63.0 commons-io:* = 2.11.0 From 538c1e4711dfae62aaa6de524660efc8cf832897 Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Thu, 23 Mar 2023 18:18:54 +0000 Subject: [PATCH 006/129] Excavator: Upgrade dependencies (#2529) --- versions.lock | 2 +- versions.props | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/versions.lock b/versions.lock index a5d405f1e..c20d21c3d 100644 --- a/versions.lock +++ b/versions.lock @@ -91,7 +91,7 @@ com.netflix.nebula:nebula-test:10.2.0 (1 constraints: 35052d3b) com.palantir.conjure.java:conjure-lib:6.77.0 (1 constraints: 4605743b) com.palantir.conjure.java.api:errors:2.34.0 (2 constraints: 6d21c6b0) com.palantir.conjure.java.api:test-utils:2.34.0 (1 constraints: 3b05433b) -com.palantir.conjure.java.runtime:conjure-java-annotations:7.42.0 (1 constraints: 3f055f3b) +com.palantir.conjure.java.runtime:conjure-java-annotations:7.43.0 (1 constraints: 4005623b) com.palantir.ri:resource-identifier:2.5.0 (1 constraints: ef0f7999) com.palantir.safe-logging:logger:3.2.0 (2 constraints: da127d36) com.palantir.safe-logging:logger-slf4j:3.2.0 (1 constraints: 000e5942) diff --git a/versions.props b/versions.props index 2836a1bb8..7309e275d 100644 --- a/versions.props +++ b/versions.props @@ -22,7 +22,7 @@ com.github.stefanbirkner:system-rules = 1.19.0 com.netflix.nebula:nebula-test = 10.2.0 com.palantir.conjure.java:* = 6.77.0 com.palantir.conjure.java.api:* = 2.34.0 -com.palantir.conjure.java.runtime:* = 7.42.0 +com.palantir.conjure.java.runtime:* = 7.43.0 com.palantir.tokens:auth-tokens = 3.17.0 com.palantir.tritium:* = 0.63.0 commons-io:* = 2.11.0 From e04a3071b62308434fff03e611200fc1859153d8 Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Sat, 25 Mar 2023 05:50:44 +0000 Subject: [PATCH 007/129] Excavator: Upgrade dependencies (#2531) --- versions.lock | 2 +- versions.props | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/versions.lock b/versions.lock index c20d21c3d..d4b32abac 100644 --- a/versions.lock +++ b/versions.lock @@ -70,7 +70,7 @@ org.eclipse.sisu:org.eclipse.sisu.inject:0.3.5 (3 constraints: 852caa93) org.eclipse.sisu:org.eclipse.sisu.plexus:0.3.5 (2 constraints: 141abc34) org.immutables:value:2.9.3 (1 constraints: 10051336) org.inferred:freebuilder:1.14.6 (1 constraints: 3e053b3b) -org.ow2.asm:asm:9.4 (3 constraints: eb2289eb) +org.ow2.asm:asm:9.5 (3 constraints: ec22dfeb) org.pcollections:pcollections:3.1.4 (1 constraints: f51029b8) org.slf4j:slf4j-api:1.7.36 (8 constraints: a3719ea2) diff --git a/versions.props b/versions.props index 7309e275d..f9aa5c479 100644 --- a/versions.props +++ b/versions.props @@ -9,7 +9,7 @@ org.inferred:freebuilder = 1.14.6 org.jooq:jooq = 3.18.1 org.slf4j:* = 1.7.36 org.immutables:* = 2.9.3 -org.ow2.asm:asm = 9.4 +org.ow2.asm:asm = 9.5 com.google.errorprone:error_prone_* = 2.18.0 com.googlecode.java-diff-utils:diffutils = 1.3.0 com.puppycrawl.tools:checkstyle = 10.9.2 From 8d58986e5b6e7487ea43c13173204c16d3084688 Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Sun, 26 Mar 2023 02:31:16 +0100 Subject: [PATCH 008/129] Excavator: Upgrade dependencies (#2532) --- gradle-baseline-java/src/main/resources/checkstyle.version | 2 +- versions.props | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle-baseline-java/src/main/resources/checkstyle.version b/gradle-baseline-java/src/main/resources/checkstyle.version index 686743019..ef848858d 100644 --- a/gradle-baseline-java/src/main/resources/checkstyle.version +++ b/gradle-baseline-java/src/main/resources/checkstyle.version @@ -1 +1 @@ -10.9.2 \ No newline at end of file +10.9.3 \ No newline at end of file diff --git a/versions.props b/versions.props index f9aa5c479..17fa049d5 100644 --- a/versions.props +++ b/versions.props @@ -12,7 +12,7 @@ org.immutables:* = 2.9.3 org.ow2.asm:asm = 9.5 com.google.errorprone:error_prone_* = 2.18.0 com.googlecode.java-diff-utils:diffutils = 1.3.0 -com.puppycrawl.tools:checkstyle = 10.9.2 +com.puppycrawl.tools:checkstyle = 10.9.3 com.palantir.gradle.utils:* = 0.1.0 com.uber.nullaway:nullaway = 0.10.10 From 0f4dd36ee54eee3bdb42a7e1e7084b6dc6847448 Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Tue, 28 Mar 2023 20:06:38 +0100 Subject: [PATCH 009/129] Excavator: Upgrade dependencies (#2533) --- versions.lock | 2 +- versions.props | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/versions.lock b/versions.lock index d4b32abac..bbd4917fc 100644 --- a/versions.lock +++ b/versions.lock @@ -91,7 +91,7 @@ com.netflix.nebula:nebula-test:10.2.0 (1 constraints: 35052d3b) com.palantir.conjure.java:conjure-lib:6.77.0 (1 constraints: 4605743b) com.palantir.conjure.java.api:errors:2.34.0 (2 constraints: 6d21c6b0) com.palantir.conjure.java.api:test-utils:2.34.0 (1 constraints: 3b05433b) -com.palantir.conjure.java.runtime:conjure-java-annotations:7.43.0 (1 constraints: 4005623b) +com.palantir.conjure.java.runtime:conjure-java-annotations:7.44.0 (1 constraints: 4105653b) com.palantir.ri:resource-identifier:2.5.0 (1 constraints: ef0f7999) com.palantir.safe-logging:logger:3.2.0 (2 constraints: da127d36) com.palantir.safe-logging:logger-slf4j:3.2.0 (1 constraints: 000e5942) diff --git a/versions.props b/versions.props index 17fa049d5..745f389f1 100644 --- a/versions.props +++ b/versions.props @@ -22,7 +22,7 @@ com.github.stefanbirkner:system-rules = 1.19.0 com.netflix.nebula:nebula-test = 10.2.0 com.palantir.conjure.java:* = 6.77.0 com.palantir.conjure.java.api:* = 2.34.0 -com.palantir.conjure.java.runtime:* = 7.43.0 +com.palantir.conjure.java.runtime:* = 7.44.0 com.palantir.tokens:auth-tokens = 3.17.0 com.palantir.tritium:* = 0.63.0 commons-io:* = 2.11.0 From b39a706c9efdefd407cd692c20f3881452a99784 Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Wed, 29 Mar 2023 19:23:44 +0100 Subject: [PATCH 010/129] Excavator: Upgrade dependencies (#2536) --- versions.lock | 2 +- versions.props | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/versions.lock b/versions.lock index bbd4917fc..a6124ab19 100644 --- a/versions.lock +++ b/versions.lock @@ -116,7 +116,7 @@ org.hamcrest:hamcrest:2.2 (2 constraints: 43187376) org.hamcrest:hamcrest-core:2.2 (4 constraints: 2b2b359e) org.hamcrest:hamcrest-library:2.2 (1 constraints: fc138e38) org.jetbrains:annotations:23.0.0 (2 constraints: f8204e6d) -org.jooq:jooq:3.18.1 (1 constraints: 3f054e3b) +org.jooq:jooq:3.18.2 (1 constraints: 40054f3b) org.junit.jupiter:junit-jupiter:5.9.2 (1 constraints: 12052136) org.junit.jupiter:junit-jupiter-api:5.9.2 (5 constraints: 6353b5bf) org.junit.jupiter:junit-jupiter-engine:5.9.2 (1 constraints: 0d0ee23b) diff --git a/versions.props b/versions.props index 745f389f1..6bd47afe6 100644 --- a/versions.props +++ b/versions.props @@ -6,7 +6,7 @@ commons-lang:commons-lang = 2.6 org.apache.maven.shared:maven-dependency-analyzer = 1.13.0 org.apache.maven:maven-core = 3.8.5 org.inferred:freebuilder = 1.14.6 -org.jooq:jooq = 3.18.1 +org.jooq:jooq = 3.18.2 org.slf4j:* = 1.7.36 org.immutables:* = 2.9.3 org.ow2.asm:asm = 9.5 From 71612e78313cd26bad532e97c2f3508add4bbdc1 Mon Sep 17 00:00:00 2001 From: Carter Kozak Date: Thu, 30 Mar 2023 10:08:56 -0400 Subject: [PATCH 011/129] SafeLoggingPropagation uses new ASTHelpers.isRecord function (#2535) SafeLoggingPropagation uses new ASTHelpers.isRecord function --- .../baseline/errorprone/SafeLoggingPropagation.java | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/SafeLoggingPropagation.java b/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/SafeLoggingPropagation.java index 2a41a8dcb..4edbce4a9 100644 --- a/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/SafeLoggingPropagation.java +++ b/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/SafeLoggingPropagation.java @@ -114,7 +114,7 @@ public Description matchClass(ClassTree classTree, VisitorState state) { if (classSymbol == null || classSymbol.isAnonymous()) { return Description.NO_MATCH; } - if (isRecord(classSymbol)) { + if (ASTHelpers.isRecord(classSymbol)) { return matchRecord(classTree, classSymbol, state); } else { return matchClassOrInterface(classTree, classSymbol, state); @@ -165,11 +165,6 @@ private static boolean immutablesDefaultAsDefault(Attribute.Compound styleAnnota .orElse(false); } - private static boolean isRecord(ClassSymbol classSymbol) { - // Can use classSymbol.isRecord() in future versions - return (classSymbol.flags() & 1L << 61) != 0; - } - @SuppressWarnings("unchecked") private static List getRecordComponents(ClassSymbol classSymbol) { // Can use classSymbol.getRecordComponents() in future versions From db7cd7222bcebf72908e510ecafec77907471c9e Mon Sep 17 00:00:00 2001 From: Carter Kozak Date: Thu, 30 Mar 2023 16:49:11 -0400 Subject: [PATCH 012/129] StrictUnusedVariable is not suppressed when UnusedVariable is disabled (#2537) StrictUnusedVariable is not suppressed when UnusedVariable is disabled --- .../errorprone/StrictUnusedVariable.java | 22 +++++++++- .../errorprone/StrictUnusedVariableTest.java | 43 ++++++++++++++++++- changelog/@unreleased/pr-2537.v2.yml | 5 +++ 3 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 changelog/@unreleased/pr-2537.v2.yml diff --git a/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/StrictUnusedVariable.java b/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/StrictUnusedVariable.java index 47e094108..875bfd46a 100644 --- a/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/StrictUnusedVariable.java +++ b/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/StrictUnusedVariable.java @@ -67,7 +67,10 @@ import com.google.errorprone.bugpatterns.UnusedVariable; import com.google.errorprone.fixes.SuggestedFix; import com.google.errorprone.fixes.SuggestedFixes; +import com.google.errorprone.matchers.ChildMultiMatcher.MatchType; import com.google.errorprone.matchers.Description; +import com.google.errorprone.matchers.Matcher; +import com.google.errorprone.matchers.Matchers; import com.google.errorprone.suppliers.Suppliers; import com.google.errorprone.util.ASTHelpers; import com.sun.source.tree.AnnotationTree; @@ -92,6 +95,7 @@ import com.sun.source.tree.ReturnTree; import com.sun.source.tree.StatementTree; import com.sun.source.tree.Tree; +import com.sun.source.tree.Tree.Kind; import com.sun.source.tree.TryTree; import com.sun.source.tree.UnaryTree; import com.sun.source.tree.VariableTree; @@ -124,7 +128,7 @@ */ @AutoService(BugChecker.class) @BugPattern( - altNames = {"unused", "UnusedVariable"}, + altNames = "unused", link = "https://github.com/palantir/gradle-baseline#baseline-error-prone-checks", linkType = BugPattern.LinkType.CUSTOM, summary = "Unused.", @@ -160,6 +164,17 @@ public final class StrictUnusedVariable extends BugChecker implements BugChecker "TAG"); private static final String UNUSED = "unused"; + private static final Matcher ALTERNATIVE_SUPPRESSED = Matchers.allOf( + // Matchers.annotations will throw given a tree that doesn't support annotations, so we must enumerate + // supported types. + Matchers.kindAnyOf(Set.of( + Kind.CLASS, Kind.VARIABLE, Kind.METHOD, Kind.ANNOTATED_TYPE, Kind.PACKAGE, Kind.COMPILATION_UNIT)), + Matchers.annotations( + MatchType.AT_LEAST_ONE, + Matchers.allOf( + Matchers.isType("java.lang.SuppressWarnings"), + Matchers.hasArgumentWithValue("value", Matchers.stringLiteral("UnusedVariable"))))); + @Override public Description matchCompilationUnit(CompilationUnitTree tree, VisitorState state) { // We will skip reporting on the whole compilation if there are any native methods found. @@ -277,6 +292,11 @@ private void checkUsedVariables(VisitorState state, VariableFinder variableFinde }); } + @Override + public boolean isSuppressed(Tree tree, VisitorState state) { + return super.isSuppressed(tree, state) || ALTERNATIVE_SUPPRESSED.matches(tree, state); + } + private static SuggestedFix constructUsedVariableSuggestedFix(List usagePaths, VisitorState state) { SuggestedFix.Builder fix = SuggestedFix.builder(); for (TreePath usagePath : usagePaths) { diff --git a/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/StrictUnusedVariableTest.java b/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/StrictUnusedVariableTest.java index a65ac008c..49393f91f 100644 --- a/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/StrictUnusedVariableTest.java +++ b/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/StrictUnusedVariableTest.java @@ -325,7 +325,7 @@ public void testRecord() { } @Test - public void testSuppression() { + public void testParameterSuppression() { refactoringTestHelper .addInputLines( "Test.java", @@ -339,6 +339,47 @@ public void testSuppression() { .doTest(TestMode.TEXT_MATCH); } + @Test + public void testMethodSuppression() { + refactoringTestHelper + .addInputLines( + "Test.java", + "class Test {", + " @SuppressWarnings(\"StrictUnusedVariable\")", + " public static void a(int val) {}", + " @SuppressWarnings(\"UnusedVariable\")", + " public static void b(int val) {}", + " @SuppressWarnings(\"unused\")", + " public static void c(int val) {}", + " public static void d(int _val) {}", + "}") + .expectUnchanged() + .doTest(TestMode.TEXT_MATCH); + } + + @Test + public void testClassSuppression() { + refactoringTestHelper + .addInputLines( + "Test.java", + "class Test {", + " @SuppressWarnings(\"StrictUnusedVariable\")", + " class Test1 {", + " public static void a(int val) {}", + " }", + " @SuppressWarnings(\"UnusedVariable\")", + " class Test2 {", + " public static void a(int val) {}", + " }", + " @SuppressWarnings(\"unused\")", + " class Test3 {", + " public static void a(int val) {}", + " }", + "}") + .expectUnchanged() + .doTest(TestMode.TEXT_MATCH); + } + @Test public void allows_unused_loggers() { compilationHelper diff --git a/changelog/@unreleased/pr-2537.v2.yml b/changelog/@unreleased/pr-2537.v2.yml new file mode 100644 index 000000000..d7970b57d --- /dev/null +++ b/changelog/@unreleased/pr-2537.v2.yml @@ -0,0 +1,5 @@ +type: fix +fix: + description: StrictUnusedVariable is not suppressed when UnusedVariable is disabled + links: + - https://github.com/palantir/gradle-baseline/pull/2537 From 18de5e450f0a7f3169f9180908d7bb21d5f0a176 Mon Sep 17 00:00:00 2001 From: svc-autorelease Date: Thu, 30 Mar 2023 20:49:19 +0000 Subject: [PATCH 013/129] Autorelease 5.1.0 [skip ci] --- changelog/{@unreleased => 5.1.0}/pr-2537.v2.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename changelog/{@unreleased => 5.1.0}/pr-2537.v2.yml (100%) diff --git a/changelog/@unreleased/pr-2537.v2.yml b/changelog/5.1.0/pr-2537.v2.yml similarity index 100% rename from changelog/@unreleased/pr-2537.v2.yml rename to changelog/5.1.0/pr-2537.v2.yml From bbf722a25e831d0680b30059048dbf8211518504 Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Fri, 31 Mar 2023 00:12:41 +0100 Subject: [PATCH 014/129] Excavator: Upgrades Baseline to the latest version (#2538) --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 2882fdb52..da4871900 100644 --- a/build.gradle +++ b/build.gradle @@ -14,7 +14,7 @@ buildscript { classpath 'com.palantir.gradle.externalpublish:gradle-external-publish-plugin:1.12.0' classpath 'com.palantir.gradle.consistentversions:gradle-consistent-versions:2.11.0' classpath 'com.gradle.publish:plugin-publish-plugin:1.1.0' - classpath 'com.palantir.baseline:gradle-baseline-java:5.0.0' + classpath 'com.palantir.baseline:gradle-baseline-java:5.1.0' classpath 'com.palantir.javaformat:gradle-palantir-java-format:2.28.0' } } From 0f4ce778dd01820b019599a52a6bb6ad6255631b Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Fri, 31 Mar 2023 01:17:17 +0100 Subject: [PATCH 015/129] Excavator: Upgrade dependencies (#2539) --- versions.lock | 2 +- versions.props | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/versions.lock b/versions.lock index a6124ab19..b2eda5317 100644 --- a/versions.lock +++ b/versions.lock @@ -100,7 +100,7 @@ com.palantir.safe-logging:preconditions:3.2.0 (6 constraints: 1457bcb5) com.palantir.safe-logging:preconditions-assertj:3.2.0 (1 constraints: 07050036) com.palantir.safe-logging:safe-logging:3.2.0 (8 constraints: 5f77a6d7) com.palantir.tokens:auth-tokens:3.17.0 (2 constraints: 5f1502db) -com.palantir.tritium:tritium-registry:0.63.0 (1 constraints: 3b05403b) +com.palantir.tritium:tritium-registry:0.64.0 (1 constraints: 3c05433b) io.dropwizard.metrics:metrics-core:4.1.1 (1 constraints: 901088a5) io.r2dbc:r2dbc-spi:1.0.0.RELEASE (1 constraints: ea08e898) javax.ws.rs:javax.ws.rs-api:2.1.1 (1 constraints: ec0f6e99) diff --git a/versions.props b/versions.props index 6bd47afe6..d0cff8073 100644 --- a/versions.props +++ b/versions.props @@ -24,7 +24,7 @@ com.palantir.conjure.java:* = 6.77.0 com.palantir.conjure.java.api:* = 2.34.0 com.palantir.conjure.java.runtime:* = 7.44.0 com.palantir.tokens:auth-tokens = 3.17.0 -com.palantir.tritium:* = 0.63.0 +com.palantir.tritium:* = 0.64.0 commons-io:* = 2.11.0 junit:junit = 4.13.2 net.lingala.zip4j:zip4j = 1.3.2 From 33fb217fc4f91f8f06e2bdb5257ac1987464a2aa Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Fri, 31 Mar 2023 12:22:50 +0100 Subject: [PATCH 016/129] Excavator: Update gradle-jdks infrastructure plugins (#2540) --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index da4871900..6e67c0aa9 100644 --- a/build.gradle +++ b/build.gradle @@ -8,7 +8,7 @@ buildscript { dependencies { classpath 'com.palantir.jakartapackagealignment:jakarta-package-alignment:0.5.0' - classpath 'com.palantir.gradle.jdks:gradle-jdks:0.31.0' + classpath 'com.palantir.gradle.jdks:gradle-jdks:0.32.0' classpath 'com.palantir.gradle.jdkslatest:gradle-jdks-latest:0.7.0' classpath 'com.diffplug.gradle:goomph:3.32.1' classpath 'com.palantir.gradle.externalpublish:gradle-external-publish-plugin:1.12.0' From 11ef5b51f9495a2dd6db9773e6f04d18bc4846c7 Mon Sep 17 00:00:00 2001 From: Pritham Marupaka Date: Fri, 31 Mar 2023 14:38:13 -0400 Subject: [PATCH 017/129] Add check: Use Collection.isEmpty() instead of comparing size() with 0 (#2530) Add check: Use Collection.isEmpty() instead of comparing size() with 0 --- .../errorprone/CardinalityEqualsZero.java | 138 ++++++++ .../errorprone/CardinalityEqualsZeroTest.java | 311 ++++++++++++++++++ changelog/@unreleased/pr-2530.v2.yml | 6 + 3 files changed, 455 insertions(+) create mode 100644 baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/CardinalityEqualsZero.java create mode 100644 baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/CardinalityEqualsZeroTest.java create mode 100644 changelog/@unreleased/pr-2530.v2.yml diff --git a/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/CardinalityEqualsZero.java b/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/CardinalityEqualsZero.java new file mode 100644 index 000000000..778bd25f7 --- /dev/null +++ b/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/CardinalityEqualsZero.java @@ -0,0 +1,138 @@ +/* + * (c) Copyright 2023 Palantir Technologies Inc. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.palantir.baseline.errorprone; + +import com.google.auto.service.AutoService; +import com.google.errorprone.BugPattern; +import com.google.errorprone.BugPattern.SeverityLevel; +import com.google.errorprone.VisitorState; +import com.google.errorprone.bugpatterns.BugChecker; +import com.google.errorprone.fixes.SuggestedFix; +import com.google.errorprone.matchers.Description; +import com.google.errorprone.matchers.Matcher; +import com.google.errorprone.matchers.Matchers; +import com.google.errorprone.matchers.method.MethodMatchers; +import com.google.errorprone.util.ASTHelpers; +import com.sun.source.tree.BinaryTree; +import com.sun.source.tree.ExpressionTree; +import com.sun.source.tree.IdentifierTree; +import com.sun.source.tree.MemberSelectTree; +import java.util.Collection; +import java.util.Optional; +import org.immutables.value.Value.Immutable; + +@AutoService(BugChecker.class) +@BugPattern( + link = "https://github.com/palantir/gradle-baseline#baseline-error-prone-checks", + linkType = BugPattern.LinkType.CUSTOM, + severity = SeverityLevel.SUGGESTION, + summary = "Use the isEmpty method instead of checking collection size") +public final class CardinalityEqualsZero extends BugChecker implements BugChecker.BinaryTreeMatcher { + private static final Matcher COLLECTION_SIZE_METHOD_MATCHER = MethodMatchers.instanceMethod() + .onDescendantOf(Collection.class.getName()) + .named("size") + .withNoParameters(); + + private static final Matcher INT_ZERO = Matchers.intLiteral(0); + + @Override + public Description matchBinary(BinaryTree tree, VisitorState state) { + Optional maybeEqualsZeroExpression = getEqualsZeroExpression(tree, state); + if (maybeEqualsZeroExpression.isEmpty()) { + return Description.NO_MATCH; + } + + EqualsZeroExpression equalsZeroExpression = maybeEqualsZeroExpression.get(); + ExpressionTree operand = equalsZeroExpression.operand(); + ExpressionTree collectionInstance = ASTHelpers.getReceiver(operand); + + if (collectionInstance == null || isExpressionThis(collectionInstance)) { + return Description.NO_MATCH; + } + + if (COLLECTION_SIZE_METHOD_MATCHER.matches(operand, state)) { + return describeMatch( + tree, + SuggestedFix.replace( + tree, + (equalsZeroExpression.type() == ExpressionType.NEQ ? "!" : "") + + state.getSourceForNode(collectionInstance) + + ".isEmpty()")); + } + + return Description.NO_MATCH; + } + + private static boolean isExpressionThis(ExpressionTree tree) { + switch (tree.getKind()) { + case IDENTIFIER: + return ((IdentifierTree) tree).getName().contentEquals("this"); + case MEMBER_SELECT: + return ((MemberSelectTree) tree).getIdentifier().contentEquals("this"); + default: + return false; + } + } + + private static Optional getEqualsZeroExpression(BinaryTree tree, VisitorState state) { + ExpressionType ret; + switch (tree.getKind()) { + case EQUAL_TO: + ret = ExpressionType.EQ; + break; + case NOT_EQUAL_TO: + ret = ExpressionType.NEQ; + break; + default: + return Optional.empty(); + } + ExpressionTree leftOperand = tree.getLeftOperand(); + ExpressionTree rightOperand = tree.getRightOperand(); + + if (INT_ZERO.matches(leftOperand, state)) { + return Optional.of(EqualsZeroExpression.builder() + .type(ret) + .operand(rightOperand) + .build()); + } else if (INT_ZERO.matches(rightOperand, state)) { + return Optional.of(EqualsZeroExpression.builder() + .type(ret) + .operand(leftOperand) + .build()); + } + + return Optional.empty(); + } + + enum ExpressionType { + EQ, + NEQ + } + + @Immutable + interface EqualsZeroExpression { + ExpressionType type(); + + ExpressionTree operand(); + + class Builder extends ImmutableEqualsZeroExpression.Builder {} + + static Builder builder() { + return new Builder(); + } + } +} diff --git a/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/CardinalityEqualsZeroTest.java b/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/CardinalityEqualsZeroTest.java new file mode 100644 index 000000000..3742f0440 --- /dev/null +++ b/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/CardinalityEqualsZeroTest.java @@ -0,0 +1,311 @@ +/* + * (c) Copyright 2023 Palantir Technologies Inc. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.palantir.baseline.errorprone; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; +import org.junit.jupiter.api.Test; + +public class CardinalityEqualsZeroTest { + @Test + public void test_size_equals_zero() { + fix().addInputLines( + "Test.java", + "import " + List.class.getCanonicalName() + ";", + "class Test {", + " static boolean f(List foo) {", + " return foo.size() == 0;", + " }", + "}") + .addOutputLines( + "Test.java", + "import " + List.class.getCanonicalName() + ";", + "class Test {", + " static boolean f(List foo) {", + " return foo.isEmpty();", + " }", + "}") + .doTest(); + } + + @Test + public void test_size_does_not_equal_zero() { + fix().addInputLines( + "Test.java", + "import " + List.class.getCanonicalName() + ";", + "class Test {", + " static boolean f(List foo) {", + " return foo.size() != 0;", + " }", + "}") + .addOutputLines( + "Test.java", + "import " + List.class.getCanonicalName() + ";", + "class Test {", + " static boolean f(List foo) {", + " return !foo.isEmpty();", + " }", + "}") + .doTest(); + } + + @Test + public void test_zero_equals_size() { + fix().addInputLines( + "Test.java", + "import " + List.class.getCanonicalName() + ";", + "class Test {", + " static boolean f(List foo) {", + " return 0 == foo.size();", + " }", + "}") + .addOutputLines( + "Test.java", + "import " + List.class.getCanonicalName() + ";", + "class Test {", + " static boolean f(List foo) {", + " return foo.isEmpty();", + " }", + "}") + .doTest(); + } + + @Test + public void test_zero_does_not_equal_size() { + fix().addInputLines( + "Test.java", + "import " + List.class.getCanonicalName() + ";", + "class Test {", + " static boolean f(List foo) {", + " return 0 != foo.size();", + " }", + "}") + .addOutputLines( + "Test.java", + "import " + List.class.getCanonicalName() + ";", + "class Test {", + " static boolean f(List foo) {", + " return !foo.isEmpty();", + " }", + "}") + .doTest(); + } + + @Test + public void test_other_collection_types() { + fix().addInputLines( + "Test.java", + "import " + Set.class.getCanonicalName() + ";", + "class Test {", + " static boolean f(Set foo) {", + " return foo.size() != 0;", + " }", + "}") + .addOutputLines( + "Test.java", + "import " + Set.class.getCanonicalName() + ";", + "class Test {", + " static boolean f(Set foo) {", + " return !foo.isEmpty();", + " }", + "}") + .doTest(); + } + + @Test + public void test_conjunction() { + fix().addInputLines( + "Test.java", + "import " + List.class.getCanonicalName() + ";", + "class Test {", + " static boolean f(List foo, List bar) {", + " return 0 != foo.size() && 0 != bar.size();", + " }", + "}") + .addOutputLines( + "Test.java", + "import " + List.class.getCanonicalName() + ";", + "class Test {", + " static boolean f(List foo, List bar) {", + " return !foo.isEmpty() && !bar.isEmpty();", + " }", + "}") + .doTest(); + } + + @Test + public void test_not_in_method() { + // Ensure instances of `size() == 0` are matched when they're enclosed in a function call, or a + // variable assignment. + fix().addInputLines( + "Test.java", + "import " + List.class.getCanonicalName() + ";", + "class Test {", + " private static boolean H = List.of(\"Hello\").size() == 0;", + " static boolean g(boolean x) { return x; }", + " static boolean f(List foo) {", + " return g(foo.size() == 0);", + " }", + "}") + .addOutputLines( + "Test.java", + "import " + List.class.getCanonicalName() + ";", + "class Test {", + " private static boolean H = List.of(\"Hello\").isEmpty();", + " static boolean g(boolean x) { return x; }", + " static boolean f(List foo) {", + " return g(foo.isEmpty());", + " }", + "}") + .doTest(); + } + + @Test + public void test_no_match() { + fix().addInputLines( + "Test.java", + "import " + List.class.getCanonicalName() + ";", + "class Test {", + " static boolean f(List foo) {", + " return foo.size() == 1 && foo.size() != 1 && 1 == foo.size() && 1 != foo.size();", + " }", + "}") + .expectUnchanged() + .doTest(); + } + + @Test + public void test_implementation_of_isEmpty() { + fix().addInputLines( + "TestCollection.java", + "import " + ArrayList.class.getCanonicalName() + ";", + "class TestCollection extends ArrayList {", + " @Override", + " public boolean isEmpty() {", + " return size() == 0;", + " }", + " public boolean customIsEmpty() {", + " return size() == 0;", + " }", + "}") + .expectUnchanged() + .doTest(); + } + + @Test + public void test_implementation_of_isEmpty_using_this() { + fix().addInputLines( + "TestCollection.java", + "import " + ArrayList.class.getCanonicalName() + ";", + "class TestCollection extends ArrayList {", + " @Override", + " public boolean isEmpty() {", + " return this.size() == 0;", + " }", + "}") + .expectUnchanged() + .doTest(); + } + + @Test + public void test_implementation_of_isEmpty_with_other_collection() { + fix().addInputLines( + "TestCollection.java", + "import " + ArrayList.class.getCanonicalName() + ";", + "import " + List.class.getCanonicalName() + ";", + "class TestCollection extends ArrayList {", + " @Override", + " public boolean isEmpty() {", + " return this.size() == 0 && List.of(\"test\").size() == 0;", + " }", + "}") + .addOutputLines( + "TestCollection.java", + "import " + ArrayList.class.getCanonicalName() + ";", + "import " + List.class.getCanonicalName() + ";", + "class TestCollection extends ArrayList {", + " @Override", + " public boolean isEmpty() {", + " return this.size() == 0 && List.of(\"test\").isEmpty();", + " }", + "}") + .doTest(); + } + + @Test + public void test_size_on_non_collection() { + fix().addInputLines( + "TestNonCollection.java", + "class TestNonCollection {", + " public int size() {", + " return 0;", + " }", + " public boolean myIsEmpty() {", + " return size() == 0;", + " }", + " public boolean anotherIsEmpty() {", + " return this.size() == 0;", + " }", + "}") + .expectUnchanged() + .doTest(); + } + + @Test + public void test_qualified_this() { + fix().addInputLines( + "TestQualifiedThis.java", + "import " + ArrayList.class.getCanonicalName() + ";", + "import " + List.class.getCanonicalName() + ";", + "class TestQualifiedThis extends ArrayList {", + " boolean myIsEmpty() {", + " return this.size() == 0;", + " }", + " class Inner extends ArrayList {", + " boolean myIsEmpty() {", + " return TestQualifiedThis.this.size() == 0;", + " }", + " boolean anotherIsEmpty() {", + " return List.of().size() == 0 && this.size() == 0;", + " }", + " }", + "}") + .addOutputLines( + "TestQualifiedThis.java", + "import " + ArrayList.class.getCanonicalName() + ";", + "import " + List.class.getCanonicalName() + ";", + "class TestQualifiedThis extends ArrayList {", + " boolean myIsEmpty() {", + " return this.size() == 0;", + " }", + " class Inner extends ArrayList {", + " boolean myIsEmpty() {", + " return TestQualifiedThis.this.size() == 0;", + " }", + " boolean anotherIsEmpty() {", + " return List.of().isEmpty() && this.size() == 0;", + " }", + " }", + "}") + .doTest(); + } + + private RefactoringValidator fix() { + return RefactoringValidator.of(CardinalityEqualsZero.class, getClass()); + } +} diff --git a/changelog/@unreleased/pr-2530.v2.yml b/changelog/@unreleased/pr-2530.v2.yml new file mode 100644 index 000000000..ac9f84ac9 --- /dev/null +++ b/changelog/@unreleased/pr-2530.v2.yml @@ -0,0 +1,6 @@ +type: improvement +improvement: + description: 'Add check: Use Collection.isEmpty() instead of comparing size() with + 0' + links: + - https://github.com/palantir/gradle-baseline/pull/2530 From 3d9b353b0854f86b7b280f5d4d6d763cb33e2815 Mon Sep 17 00:00:00 2001 From: svc-autorelease Date: Fri, 31 Mar 2023 18:38:21 +0000 Subject: [PATCH 018/129] Autorelease 5.2.0 [skip ci] --- changelog/{@unreleased => 5.2.0}/pr-2530.v2.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename changelog/{@unreleased => 5.2.0}/pr-2530.v2.yml (100%) diff --git a/changelog/@unreleased/pr-2530.v2.yml b/changelog/5.2.0/pr-2530.v2.yml similarity index 100% rename from changelog/@unreleased/pr-2530.v2.yml rename to changelog/5.2.0/pr-2530.v2.yml From 63856ba76721de1e17a42561365750415e65cf48 Mon Sep 17 00:00:00 2001 From: David Schlosnagle Date: Sat, 1 Apr 2023 00:06:27 -0400 Subject: [PATCH 019/129] Fix #2543 CardinalityEqualsZero equality comparison check (#2544) Fix #2543 CardinalityEqualsZero equality comparison check --- .../errorprone/CardinalityEqualsZero.java | 7 +++++- .../errorprone/CardinalityEqualsZeroTest.java | 22 +++++++++++++++++++ changelog/@unreleased/pr-2544.v2.yml | 5 +++++ 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 changelog/@unreleased/pr-2544.v2.yml diff --git a/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/CardinalityEqualsZero.java b/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/CardinalityEqualsZero.java index 778bd25f7..0507c5f5a 100644 --- a/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/CardinalityEqualsZero.java +++ b/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/CardinalityEqualsZero.java @@ -31,7 +31,9 @@ import com.sun.source.tree.ExpressionTree; import com.sun.source.tree.IdentifierTree; import com.sun.source.tree.MemberSelectTree; +import com.sun.source.tree.Tree.Kind; import java.util.Collection; +import java.util.Objects; import java.util.Optional; import org.immutables.value.Value.Immutable; @@ -58,8 +60,11 @@ public Description matchBinary(BinaryTree tree, VisitorState state) { EqualsZeroExpression equalsZeroExpression = maybeEqualsZeroExpression.get(); ExpressionTree operand = equalsZeroExpression.operand(); - ExpressionTree collectionInstance = ASTHelpers.getReceiver(operand); + if (!Objects.equals(operand.getKind(), Kind.METHOD_INVOCATION)) { + return Description.NO_MATCH; + } + ExpressionTree collectionInstance = ASTHelpers.getReceiver(operand); if (collectionInstance == null || isExpressionThis(collectionInstance)) { return Description.NO_MATCH; } diff --git a/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/CardinalityEqualsZeroTest.java b/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/CardinalityEqualsZeroTest.java index 3742f0440..ee89eef68 100644 --- a/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/CardinalityEqualsZeroTest.java +++ b/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/CardinalityEqualsZeroTest.java @@ -266,6 +266,28 @@ public void test_size_on_non_collection() { .doTest(); } + @Test + public void test_equals_on_non_collection() { + fix().addInputLines( + "TestNonCollection.java", + "class TestNonCollection {", + " public int size() {", + " return 0;", + " }", + " public boolean foo(String key) {", + " String current = \"x\";", + " int comparisonResult = current.compareTo(key);", + " if (comparisonResult == 0) {", + " return true;", + " } else {", + " return false;", + " }", + " }", + "}") + .expectUnchanged() + .doTest(); + } + @Test public void test_qualified_this() { fix().addInputLines( diff --git a/changelog/@unreleased/pr-2544.v2.yml b/changelog/@unreleased/pr-2544.v2.yml new file mode 100644 index 000000000..1e4a05ea4 --- /dev/null +++ b/changelog/@unreleased/pr-2544.v2.yml @@ -0,0 +1,5 @@ +type: fix +fix: + description: 'Fix #2543 CardinalityEqualsZero equality comparison check' + links: + - https://github.com/palantir/gradle-baseline/pull/2544 From d3e5fafcc21119e7fec0a10df3cebaf257152a38 Mon Sep 17 00:00:00 2001 From: svc-autorelease Date: Sat, 1 Apr 2023 04:06:33 +0000 Subject: [PATCH 020/129] Autorelease 5.3.0 [skip ci] --- changelog/{@unreleased => 5.3.0}/pr-2544.v2.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename changelog/{@unreleased => 5.3.0}/pr-2544.v2.yml (100%) diff --git a/changelog/@unreleased/pr-2544.v2.yml b/changelog/5.3.0/pr-2544.v2.yml similarity index 100% rename from changelog/@unreleased/pr-2544.v2.yml rename to changelog/5.3.0/pr-2544.v2.yml From 9482b9fd7897a89048c9fae91e28e3bb28deaaf0 Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Sat, 1 Apr 2023 08:49:43 +0100 Subject: [PATCH 021/129] Excavator: Upgrades Baseline to the latest version (#2542) --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 6e67c0aa9..11060c28c 100644 --- a/build.gradle +++ b/build.gradle @@ -14,7 +14,7 @@ buildscript { classpath 'com.palantir.gradle.externalpublish:gradle-external-publish-plugin:1.12.0' classpath 'com.palantir.gradle.consistentversions:gradle-consistent-versions:2.11.0' classpath 'com.gradle.publish:plugin-publish-plugin:1.1.0' - classpath 'com.palantir.baseline:gradle-baseline-java:5.1.0' + classpath 'com.palantir.baseline:gradle-baseline-java:5.3.0' classpath 'com.palantir.javaformat:gradle-palantir-java-format:2.28.0' } } From df78651b1f93a2e1843a851bbdfdfcd520c79b9c Mon Sep 17 00:00:00 2001 From: David132639 <8679913+David132639@users.noreply.github.com> Date: Tue, 4 Apr 2023 21:00:05 +0100 Subject: [PATCH 022/129] Add OptionalOrElseMethodInvocation to README.md (#2534) Add a line for an error-prone check added in #655, which is missing from the README. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 29be6b1f2..3fb310332 100644 --- a/README.md +++ b/README.md @@ -166,6 +166,7 @@ Safe Logging can be found at [github.com/palantir/safe-logging](https://github.c - `DangerousStringInternUsage`: Disallow String.intern() invocations in favor of more predictable, scalable alternatives. - `OptionalOrElseThrowThrows`: Optional.orElseThrow argument must return an exception, not throw one. - `OptionalOrElseGetValue`: Prefer `Optional.orElse(value)` over `Optional.orElseGet(() -> value)` for trivial expressions. +- `OptionalOrElseMethodInvocation`: Prefer `Optional.orElseGet(() -> methodInvocation())` over `Optional.orElse(methodInvocation())`. - `LambdaMethodReference`: Lambda should use a method reference. - `SafeLoggingExceptionMessageFormat`: SafeLoggable exceptions do not interpolate parameters. - `StrictUnusedVariable`: Functions shouldn't have unused parameters. From d3a622c308100668bf69f1b2c21a207ce1c8a88e Mon Sep 17 00:00:00 2001 From: Pritham Marupaka Date: Tue, 4 Apr 2023 16:49:58 -0400 Subject: [PATCH 023/129] Add check: Use InvoationTargetException.getCause instead of getTargetException (#2541) Add check: Use InvocationTargetException.getCause instead of getTargetException. --- README.md | 1 + ...tionTargetExceptionGetTargetException.java | 56 +++++++++++++++ ...TargetExceptionGetTargetExceptionTest.java | 70 +++++++++++++++++++ changelog/@unreleased/pr-2541.v2.yml | 5 ++ 4 files changed, 132 insertions(+) create mode 100644 baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/InvocationTargetExceptionGetTargetException.java create mode 100644 baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/InvocationTargetExceptionGetTargetExceptionTest.java create mode 100644 changelog/@unreleased/pr-2541.v2.yml diff --git a/README.md b/README.md index 3fb310332..c6b550611 100644 --- a/README.md +++ b/README.md @@ -216,6 +216,7 @@ Safe Logging can be found at [github.com/palantir/safe-logging](https://github.c - `BugCheckerAutoService`: Concrete BugChecker implementations should be annotated `@AutoService(BugChecker.class)` for auto registration with error-prone. - `DangerousCollapseKeysUsage`: Disallow usage of `EntryStream#collapseKeys()`. - `JooqBatchWithoutBindArgs`: jOOQ batch methods that execute without bind args can cause performance problems. +- `InvocationTargetExceptionGetTargetException`: InvocationTargetException.getTargetException() predates the general-purpose exception chaining facility. The Throwable.getCause() method is now the preferred means of obtaining this information. [(source)](https://docs.oracle.com/en/java/javase/17/docs/api//java.base/java/lang/reflect/InvocationTargetException.html#getTargetException()) ### Programmatic Application diff --git a/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/InvocationTargetExceptionGetTargetException.java b/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/InvocationTargetExceptionGetTargetException.java new file mode 100644 index 000000000..2e033375d --- /dev/null +++ b/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/InvocationTargetExceptionGetTargetException.java @@ -0,0 +1,56 @@ +/* + * (c) Copyright 2023 Palantir Technologies Inc. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.palantir.baseline.errorprone; + +import com.google.auto.service.AutoService; +import com.google.errorprone.BugPattern; +import com.google.errorprone.BugPattern.SeverityLevel; +import com.google.errorprone.VisitorState; +import com.google.errorprone.bugpatterns.BugChecker; +import com.google.errorprone.fixes.SuggestedFixes; +import com.google.errorprone.matchers.Description; +import com.google.errorprone.matchers.Matcher; +import com.google.errorprone.matchers.Matchers; +import com.sun.source.tree.ExpressionTree; +import com.sun.source.tree.MethodInvocationTree; +import java.lang.reflect.InvocationTargetException; + +@AutoService(BugChecker.class) +@BugPattern( + link = "https://github.com/palantir/gradle-baseline#baseline-error-prone-checks", + linkType = BugPattern.LinkType.CUSTOM, + severity = SeverityLevel.SUGGESTION, + summary = + "InvocationTargetException.getTargetException() predates the general-purpose exception chaining" + + " facility. The Throwable.getCause() method is now the preferred means of obtaining this" + + " information. Source: " + + "https://docs.oracle.com/en/java/javase/17/docs/api//java.base/java/lang/reflect/InvocationTargetException.html#getTargetException()") +public final class InvocationTargetExceptionGetTargetException extends BugChecker + implements BugChecker.MethodInvocationTreeMatcher { + + private static final Matcher ITE_GET_TARGET_EXCEPTION_MATCHER = Matchers.instanceMethod() + .onDescendantOf(InvocationTargetException.class.getName()) + .named("getTargetException") + .withNoParameters(); + + @Override + public Description matchMethodInvocation(MethodInvocationTree tree, VisitorState state) { + return ITE_GET_TARGET_EXCEPTION_MATCHER.matches(tree, state) + ? describeMatch(tree, SuggestedFixes.renameMethodInvocation(tree, "getCause", state)) + : Description.NO_MATCH; + } +} diff --git a/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/InvocationTargetExceptionGetTargetExceptionTest.java b/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/InvocationTargetExceptionGetTargetExceptionTest.java new file mode 100644 index 000000000..4bfb3f202 --- /dev/null +++ b/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/InvocationTargetExceptionGetTargetExceptionTest.java @@ -0,0 +1,70 @@ +/* + * (c) Copyright 2023 Palantir Technologies Inc. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.palantir.baseline.errorprone; + +import java.lang.reflect.InvocationTargetException; +import org.junit.jupiter.api.Test; + +public class InvocationTargetExceptionGetTargetExceptionTest { + @Test + public void test_basic() { + fix().addInputLines( + "Test.java", + "import " + InvocationTargetException.class.getName() + ";", + "class Test {", + " static Throwable f(InvocationTargetException foo) {", + " return foo.getTargetException();", + " }", + "}") + .addOutputLines( + "Test.java", + "import " + InvocationTargetException.class.getName() + ";", + "class Test {", + " static Throwable f(InvocationTargetException foo) {", + " return foo.getCause();", + " }", + "}") + .doTest(); + } + + @Test + public void test_subclass() { + fix().addInputLines( + "Test.java", + "import " + InvocationTargetException.class.getName() + ";", + "class Test {", + " class TestException extends InvocationTargetException {}", + " public Throwable getCause(TestException foo) {", + " return foo.getTargetException();", // This should change + " }", + "}") + .addOutputLines( + "Test.java", + "import " + InvocationTargetException.class.getName() + ";", + "class Test {", + " class TestException extends InvocationTargetException {}", + " public Throwable getCause(TestException foo) {", + " return foo.getCause();", + " }", + "}") + .doTest(); + } + + private RefactoringValidator fix() { + return RefactoringValidator.of(InvocationTargetExceptionGetTargetException.class, getClass()); + } +} diff --git a/changelog/@unreleased/pr-2541.v2.yml b/changelog/@unreleased/pr-2541.v2.yml new file mode 100644 index 000000000..28d640520 --- /dev/null +++ b/changelog/@unreleased/pr-2541.v2.yml @@ -0,0 +1,5 @@ +type: feature +feature: + description: 'Add check: Use InvocationTargetException.getCause instead of getTargetException.' + links: + - https://github.com/palantir/gradle-baseline/pull/2541 From 1fa42ab35c89c4b28342f8580c67de5146da685c Mon Sep 17 00:00:00 2001 From: svc-autorelease Date: Tue, 4 Apr 2023 20:50:06 +0000 Subject: [PATCH 024/129] Autorelease 5.4.0 [skip ci] --- changelog/{@unreleased => 5.4.0}/pr-2541.v2.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename changelog/{@unreleased => 5.4.0}/pr-2541.v2.yml (100%) diff --git a/changelog/@unreleased/pr-2541.v2.yml b/changelog/5.4.0/pr-2541.v2.yml similarity index 100% rename from changelog/@unreleased/pr-2541.v2.yml rename to changelog/5.4.0/pr-2541.v2.yml From 200dc43ac3b5b3b69140b7a42e4c36c26f33f125 Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Wed, 5 Apr 2023 03:41:57 +0100 Subject: [PATCH 025/129] Excavator: Upgrades Baseline to the latest version (#2546) --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 11060c28c..013fe5031 100644 --- a/build.gradle +++ b/build.gradle @@ -14,7 +14,7 @@ buildscript { classpath 'com.palantir.gradle.externalpublish:gradle-external-publish-plugin:1.12.0' classpath 'com.palantir.gradle.consistentversions:gradle-consistent-versions:2.11.0' classpath 'com.gradle.publish:plugin-publish-plugin:1.1.0' - classpath 'com.palantir.baseline:gradle-baseline-java:5.3.0' + classpath 'com.palantir.baseline:gradle-baseline-java:5.4.0' classpath 'com.palantir.javaformat:gradle-palantir-java-format:2.28.0' } } From 1705edd5559c6ffae48b47c711b0499d791f80bc Mon Sep 17 00:00:00 2001 From: Callum Rogers Date: Thu, 6 Apr 2023 16:45:58 +0100 Subject: [PATCH 026/129] Stop suggesting the save actions plugin (#2547) No longer suggest the "Save Actions" IntelliJ plugin which does not work in IntelliJ 2023.1 for use with Palantir Java Format. Instead, Palantir Java Format will support the IntelliJ native "Actions on save" reformat capability in a future release. --- changelog/@unreleased/pr-2547.v2.yml | 8 +++ .../baseline/plugins/BaselineIdea.groovy | 59 ------------------- .../BaselineIdeaIntegrationTest.groovy | 50 ---------------- 3 files changed, 8 insertions(+), 109 deletions(-) create mode 100644 changelog/@unreleased/pr-2547.v2.yml diff --git a/changelog/@unreleased/pr-2547.v2.yml b/changelog/@unreleased/pr-2547.v2.yml new file mode 100644 index 000000000..7a08e3149 --- /dev/null +++ b/changelog/@unreleased/pr-2547.v2.yml @@ -0,0 +1,8 @@ +type: fix +fix: + description: No longer suggest the "Save Actions" IntelliJ plugin which does not + work in IntelliJ 2023.1 for use with Palantir Java Format. Instead, Palantir Java + Format will support the IntelliJ native "Actions on save" reformat capability + in a future release. + links: + - https://github.com/palantir/gradle-baseline/pull/2547 diff --git a/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineIdea.groovy b/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineIdea.groovy index 40821e54e..9c6d92bfa 100644 --- a/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineIdea.groovy +++ b/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineIdea.groovy @@ -47,9 +47,6 @@ import org.gradle.plugins.ide.idea.model.ModuleDependency // TODO(dfox): separate the xml manipulation (which really benefits from groovy syntax) from typed things //@CompileStatic class BaselineIdea extends AbstractBaselinePlugin { - - static SAVE_ACTIONS_PLUGIN_MINIMUM_VERSION = '1.9.0' - void apply(Project project) { this.project = project @@ -111,18 +108,6 @@ class BaselineIdea extends AbstractBaselinePlugin { addEditorSettings(node) } } - - // Suggest and configure the "save actions" plugin if Palantir Java Format is turned on. - // This plugin can only be applied to the root project, and it applied as a side-effect of applying - // 'com.palantir.java-format' to any subproject. - rootProject.getPluginManager().withPlugin("com.palantir.java-format-idea") { - ideaRootModel.project.ipr.withXml {XmlProvider provider -> - Node node = provider.asNode() - configureSaveActions(node) - configureExternalDependencies(node) - } - configureSaveActionsForIntellijImport(rootProject) - } } @CompileStatic @@ -522,18 +507,6 @@ class BaselineIdea extends AbstractBaselinePlugin { '''.stripIndent())) } - private static void configureSaveActionsForIntellijImport(Project project) { - if (!IntellijSupport.isRunningInIntellij()) { - return - } - XmlUtils.createOrUpdateXmlFile( - project.file(".idea/externalDependencies.xml"), - BaselineIdea.&configureExternalDependencies) - XmlUtils.createOrUpdateXmlFile( - project.file(".idea/saveactions_settings.xml"), - BaselineIdea.&configureSaveActions) - } - /** * Configure the default working directory of RunManager configurations to be the module directory. */ @@ -573,36 +546,4 @@ class BaselineIdea extends AbstractBaselinePlugin { module.dependencies.addAll(projectRefs) } } - - /** - * Configures some defaults on the save-actions plugin, but only if it hasn't been configured before. - */ - private static void configureSaveActions(Node rootNode) { - GroovyXmlUtils.matchOrCreateChild(rootNode, 'component', [name: 'SaveActionSettings'], [:]) { - // Configure defaults if this plugin is configured for the first time only - appendNode('option', [name: 'actions']).appendNode('set').with { - appendNode('option', [value: 'activate']) - appendNode('option', [value: 'noActionIfCompileErrors']) - appendNode('option', [value: 'organizeImports']) - appendNode('option', [value: 'reformat']) - } - appendNode('option', [name: 'configurationPath', value: '']) - appendNode('option', [name: 'inclusions']).appendNode('set').with { - appendNode('option', [value: "src${File.separator}.*\\.java"]) - } - } - } - - private static void configureExternalDependencies(Node rootNode) { - def externalDependencies = - GroovyXmlUtils.matchOrCreateChild(rootNode, 'component', [name: 'ExternalDependencies']) - // I kid you not, this is the id for the save actions plugin: - // https://github.com/dubreuia/intellij-plugin-save-actions/blob/v1.9.0/src/main/resources/META-INF/plugin.xml#L5 - // https://plugins.jetbrains.com/plugin/7642-save-actions/ - GroovyXmlUtils.matchOrCreateChild( - externalDependencies, - 'plugin', - [id: 'com.dubreuia'], - ['min-version': SAVE_ACTIONS_PLUGIN_MINIMUM_VERSION]) - } } diff --git a/gradle-baseline-java/src/test/groovy/com/palantir/baseline/BaselineIdeaIntegrationTest.groovy b/gradle-baseline-java/src/test/groovy/com/palantir/baseline/BaselineIdeaIntegrationTest.groovy index e35c3a823..de2160a42 100644 --- a/gradle-baseline-java/src/test/groovy/com/palantir/baseline/BaselineIdeaIntegrationTest.groovy +++ b/gradle-baseline-java/src/test/groovy/com/palantir/baseline/BaselineIdeaIntegrationTest.groovy @@ -313,56 +313,6 @@ class BaselineIdeaIntegrationTest extends AbstractPluginTest { !otherSubprojectIml.exists() } - def "idea configures the save-action plugin when PJF is enabled on a subproject"() { - buildFile << standardBuildFile - multiProject.addSubproject('formatted-project', """ - apply plugin: 'com.palantir.java-format' - """.stripIndent()) - - when: - with('idea').build() - - then: - def iprFile = new File(projectDir, "${moduleName}.ipr") - def ipr = new XmlSlurper().parse(iprFile) - ipr.component.find { it.@name == "ExternalDependencies" } - ipr.component.find { it.@name == "SaveActionSettings" } - } - - def "idea does not configure the save-action plugin when PJF is not enabled"() { - buildFile << standardBuildFile - - when: - with('idea').build() - - then: - def iprFile = new File(projectDir, "${moduleName}.ipr") - def ipr = new XmlSlurper().parse(iprFile) - !ipr.component.find { it.@name == "ExternalDependencies" } - !ipr.component.find { it.@name == "SaveActionSettings" } - } - - @RestoreSystemProperties - def "idea configures the save-action plugin for IntelliJ import"() { - buildFile << standardBuildFile - multiProject.addSubproject('formatted-project', """ - apply plugin: 'com.palantir.java-format' - """.stripIndent()) - - when: - System.setProperty("idea.active", "true") - with().build() - - then: - def saveActionsSettingsFile = new File(projectDir, ".idea/saveactions_settings.xml") - def settings = new XmlSlurper().parse(saveActionsSettingsFile) - settings.component.find { it.@name == "SaveActionSettings" } - - def externalDepsSettingsFile = new File(projectDir, ".idea/externalDependencies.xml") - def deps = new XmlSlurper().parse(externalDepsSettingsFile) - deps.component.find { it.@name == "ExternalDependencies" } - } - def 'Idea files use versions derived from the baseline-java-versions plugin'() { when: buildFile << standardBuildFile From a18bc7e01245f049a6dfc1fb22d0570a41e4038b Mon Sep 17 00:00:00 2001 From: svc-autorelease Date: Thu, 6 Apr 2023 15:46:06 +0000 Subject: [PATCH 027/129] Autorelease 5.5.0 [skip ci] --- changelog/{@unreleased => 5.5.0}/pr-2547.v2.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename changelog/{@unreleased => 5.5.0}/pr-2547.v2.yml (100%) diff --git a/changelog/@unreleased/pr-2547.v2.yml b/changelog/5.5.0/pr-2547.v2.yml similarity index 100% rename from changelog/@unreleased/pr-2547.v2.yml rename to changelog/5.5.0/pr-2547.v2.yml From 9f6d53a545682319b97db5191498ce4a9c440eaa Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Thu, 6 Apr 2023 18:17:30 +0100 Subject: [PATCH 028/129] Excavator: Upgrades Baseline to the latest version (#2548) --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 013fe5031..018050ce0 100644 --- a/build.gradle +++ b/build.gradle @@ -14,7 +14,7 @@ buildscript { classpath 'com.palantir.gradle.externalpublish:gradle-external-publish-plugin:1.12.0' classpath 'com.palantir.gradle.consistentversions:gradle-consistent-versions:2.11.0' classpath 'com.gradle.publish:plugin-publish-plugin:1.1.0' - classpath 'com.palantir.baseline:gradle-baseline-java:5.4.0' + classpath 'com.palantir.baseline:gradle-baseline-java:5.5.0' classpath 'com.palantir.javaformat:gradle-palantir-java-format:2.28.0' } } From e835aff03e757e4814d12a2bd57bab67c337c9c1 Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Fri, 7 Apr 2023 18:45:39 +0100 Subject: [PATCH 029/129] Excavator: Upgrade dependencies (#2549) --- versions.lock | 10 +++++----- versions.props | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/versions.lock b/versions.lock index b2eda5317..01949f7ff 100644 --- a/versions.lock +++ b/versions.lock @@ -54,9 +54,9 @@ org.apache.maven.resolver:maven-resolver-spi:1.6.3 (3 constraints: 5930fd65) org.apache.maven.resolver:maven-resolver-util:1.6.3 (3 constraints: 5930fd65) org.apache.maven.shared:maven-dependency-analyzer:1.13.0 (1 constraints: 3705323b) org.apache.maven.shared:maven-shared-utils:3.3.4 (1 constraints: e60b61f3) -org.checkerframework:checker-qual:3.32.0 (3 constraints: 08256088) -org.checkerframework:dataflow-errorprone:3.32.0 (4 constraints: 093ebc5f) -org.checkerframework:dataflow-nullaway:3.32.0 (2 constraints: 691171f1) +org.checkerframework:checker-qual:3.33.0 (3 constraints: 08256088) +org.checkerframework:dataflow-errorprone:3.33.0 (4 constraints: 0a3e5c60) +org.checkerframework:dataflow-nullaway:3.33.0 (2 constraints: 6a1198f1) org.codehaus.groovy:groovy:3.0.10 (3 constraints: e32879d6) org.codehaus.groovy:groovy-xml:3.0.10 (1 constraints: 791161da) org.codehaus.plexus:plexus-cipher:2.0 (1 constraints: 641174c7) @@ -91,7 +91,7 @@ com.netflix.nebula:nebula-test:10.2.0 (1 constraints: 35052d3b) com.palantir.conjure.java:conjure-lib:6.77.0 (1 constraints: 4605743b) com.palantir.conjure.java.api:errors:2.34.0 (2 constraints: 6d21c6b0) com.palantir.conjure.java.api:test-utils:2.34.0 (1 constraints: 3b05433b) -com.palantir.conjure.java.runtime:conjure-java-annotations:7.44.0 (1 constraints: 4105653b) +com.palantir.conjure.java.runtime:conjure-java-annotations:7.49.0 (1 constraints: 4605743b) com.palantir.ri:resource-identifier:2.5.0 (1 constraints: ef0f7999) com.palantir.safe-logging:logger:3.2.0 (2 constraints: da127d36) com.palantir.safe-logging:logger-slf4j:3.2.0 (1 constraints: 000e5942) @@ -100,7 +100,7 @@ com.palantir.safe-logging:preconditions:3.2.0 (6 constraints: 1457bcb5) com.palantir.safe-logging:preconditions-assertj:3.2.0 (1 constraints: 07050036) com.palantir.safe-logging:safe-logging:3.2.0 (8 constraints: 5f77a6d7) com.palantir.tokens:auth-tokens:3.17.0 (2 constraints: 5f1502db) -com.palantir.tritium:tritium-registry:0.64.0 (1 constraints: 3c05433b) +com.palantir.tritium:tritium-registry:0.65.0 (1 constraints: 3d05463b) io.dropwizard.metrics:metrics-core:4.1.1 (1 constraints: 901088a5) io.r2dbc:r2dbc-spi:1.0.0.RELEASE (1 constraints: ea08e898) javax.ws.rs:javax.ws.rs-api:2.1.1 (1 constraints: ec0f6e99) diff --git a/versions.props b/versions.props index d0cff8073..84421dedc 100644 --- a/versions.props +++ b/versions.props @@ -22,9 +22,9 @@ com.github.stefanbirkner:system-rules = 1.19.0 com.netflix.nebula:nebula-test = 10.2.0 com.palantir.conjure.java:* = 6.77.0 com.palantir.conjure.java.api:* = 2.34.0 -com.palantir.conjure.java.runtime:* = 7.44.0 +com.palantir.conjure.java.runtime:* = 7.49.0 com.palantir.tokens:auth-tokens = 3.17.0 -com.palantir.tritium:* = 0.64.0 +com.palantir.tritium:* = 0.65.0 commons-io:* = 2.11.0 junit:junit = 4.13.2 net.lingala.zip4j:zip4j = 1.3.2 @@ -32,7 +32,7 @@ net.ltgt.gradle:gradle-errorprone-plugin = 3.0.1 one.util:streamex = 0.8.1 org.apache.commons:commons-lang3 = 3.12.0 org.assertj:assertj-core = 3.24.2 -org.checkerframework:* = 3.32.0 +org.checkerframework:* = 3.33.0 org.hamcrest:hamcrest-core = 2.2 org.junit.jupiter:* = 5.9.2 org.junit.vintage:* = 5.9.2 From 29973057dfb0796d45dff7ba45390f09b979fa7d Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Fri, 7 Apr 2023 21:40:05 +0100 Subject: [PATCH 030/129] Excavator: Update open-source publishing plugins (#2550) --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 018050ce0..d7666bce5 100644 --- a/build.gradle +++ b/build.gradle @@ -13,7 +13,7 @@ buildscript { classpath 'com.diffplug.gradle:goomph:3.32.1' classpath 'com.palantir.gradle.externalpublish:gradle-external-publish-plugin:1.12.0' classpath 'com.palantir.gradle.consistentversions:gradle-consistent-versions:2.11.0' - classpath 'com.gradle.publish:plugin-publish-plugin:1.1.0' + classpath 'com.gradle.publish:plugin-publish-plugin:1.2.0' classpath 'com.palantir.baseline:gradle-baseline-java:5.5.0' classpath 'com.palantir.javaformat:gradle-palantir-java-format:2.28.0' } From 92481dbd1fa5ab34ae41c8dbdb5decb80951b297 Mon Sep 17 00:00:00 2001 From: Callum Rogers Date: Tue, 11 Apr 2023 17:28:51 +0100 Subject: [PATCH 031/129] Remove Save Actions external dep from persistent .idea config (#2551) Ensure all recommendations to install the "Save Actions" plugin are removed in persistent config in the `.idea` config directory. --- changelog/@unreleased/pr-2551.v2.yml | 6 ++++ .../baseline/plugins/BaselineIdea.groovy | 24 +++++++++++++ .../baseline/plugins/GroovyXmlUtils.groovy | 6 ++++ .../palantir/baseline/plugins/XmlUtils.java | 8 +++++ .../BaselineIdeaIntegrationTest.groovy | 34 +++++++++++++++++++ 5 files changed, 78 insertions(+) create mode 100644 changelog/@unreleased/pr-2551.v2.yml diff --git a/changelog/@unreleased/pr-2551.v2.yml b/changelog/@unreleased/pr-2551.v2.yml new file mode 100644 index 000000000..77da61ba7 --- /dev/null +++ b/changelog/@unreleased/pr-2551.v2.yml @@ -0,0 +1,6 @@ +type: fix +fix: + description: Ensure all recommendations to install the "Save Actions" plugin are + removed in persistent config in the `.idea` config directory. + links: + - https://github.com/palantir/gradle-baseline/pull/2551 diff --git a/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineIdea.groovy b/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineIdea.groovy index 9c6d92bfa..b662f6618 100644 --- a/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineIdea.groovy +++ b/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineIdea.groovy @@ -108,6 +108,8 @@ class BaselineIdea extends AbstractBaselinePlugin { addEditorSettings(node) } } + + removeSaveActionsExternalDependency(rootProject) } @CompileStatic @@ -546,4 +548,26 @@ class BaselineIdea extends AbstractBaselinePlugin { module.dependencies.addAll(projectRefs) } } + + /** + * We used to add the 'Save Actions' plugin as an external dependency to support Palantir Java Format, + * however this plugin is broken in IntelliJ 2023.1 and we no longer use it. However, without actually + * removing it from the persistent intellij config people will still get nagged. So this code removing + * needs to remain here a sufficiently long time until every extant repo checkout has had a version of + * baseline run on it that remove the config. + */ + private static void removeSaveActionsExternalDependency(Project rootProject) { + if (!IntellijSupport.isRunningInIntellij()) { + return + } + + XmlUtils.updateXmlFileIfExists(rootProject.file(".idea/externalDependencies.xml")) { rootNode -> + GroovyXmlUtils.matchChild(rootNode, 'component', [name: 'ExternalDependencies']).ifPresent { externalDeps -> + // No joke the Save Actions plugin's id is 'com.dubreuia'. + GroovyXmlUtils.matchChild(externalDeps, 'plugin', [id: 'com.dubreuia']).ifPresent { saveActionsPlugin -> + externalDeps.remove(saveActionsPlugin) + } + } + } + } } diff --git a/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/GroovyXmlUtils.groovy b/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/GroovyXmlUtils.groovy index a498b492e..34f556d10 100644 --- a/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/GroovyXmlUtils.groovy +++ b/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/GroovyXmlUtils.groovy @@ -23,6 +23,7 @@ final class GroovyXmlUtils { Map attributes = [:], Map defaults = [:], @DelegatesTo(value = Node, strategy = Closure.DELEGATE_FIRST) Closure ifCreated = {}) { + def child = base[name].find { it.attributes().entrySet().containsAll(attributes.entrySet()) } if (child) { return child @@ -33,4 +34,9 @@ final class GroovyXmlUtils { ifCreated(created) return created } + + static Optional matchChild(Node base, String name, Map attributes = [:]) { + Node child = base[name].find { it.attributes().entrySet().containsAll(attributes.entrySet()) } + return Optional.ofNullable(child) + } } diff --git a/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/XmlUtils.java b/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/XmlUtils.java index 19186b259..9002fb79a 100644 --- a/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/XmlUtils.java +++ b/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/XmlUtils.java @@ -34,6 +34,14 @@ final class XmlUtils { private XmlUtils() {} + static void updateXmlFileIfExists(File configurationFile, Consumer configure) { + if (!configurationFile.exists()) { + return; + } + + createOrUpdateXmlFile(configurationFile, configure); + } + static void createOrUpdateXmlFile(File configurationFile, Consumer configure) { createOrUpdateXmlFile( configurationFile, configure, () -> new Node(null, "project", ImmutableMap.of("version", "4"))); diff --git a/gradle-baseline-java/src/test/groovy/com/palantir/baseline/BaselineIdeaIntegrationTest.groovy b/gradle-baseline-java/src/test/groovy/com/palantir/baseline/BaselineIdeaIntegrationTest.groovy index de2160a42..53d0a9baa 100644 --- a/gradle-baseline-java/src/test/groovy/com/palantir/baseline/BaselineIdeaIntegrationTest.groovy +++ b/gradle-baseline-java/src/test/groovy/com/palantir/baseline/BaselineIdeaIntegrationTest.groovy @@ -335,4 +335,38 @@ class BaselineIdeaIntegrationTest extends AbstractPluginTest { def rootIml = Files.asCharSource(new File(projectDir, projectDir.name + ".iml"), Charsets.UTF_8).read() rootIml.contains('LANGUAGE_LEVEL="JDK_15') } + + @RestoreSystemProperties + def 'Removes the save-actions external dep if it exists'() { + buildFile << standardBuildFile + + file('.idea/externalDependencies.xml') << /* language=xml */ ''' + + + + + + + + '''.stripIndent(true).trim() + + when: + System.setProperty("idea.active", "true") + with().build() + + then: + def newExternalDeps = file('.idea/externalDependencies.xml').text.trim() + + // language=xml + def expected = ''' + + + + + + + '''.stripIndent(true).trim() + + newExternalDeps == expected + } } From 267dd19dad6dbcc9d9772437340b4abc72deda55 Mon Sep 17 00:00:00 2001 From: svc-autorelease Date: Tue, 11 Apr 2023 16:28:58 +0000 Subject: [PATCH 032/129] Autorelease 5.6.0 [skip ci] --- changelog/{@unreleased => 5.6.0}/pr-2551.v2.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename changelog/{@unreleased => 5.6.0}/pr-2551.v2.yml (100%) diff --git a/changelog/@unreleased/pr-2551.v2.yml b/changelog/5.6.0/pr-2551.v2.yml similarity index 100% rename from changelog/@unreleased/pr-2551.v2.yml rename to changelog/5.6.0/pr-2551.v2.yml From 40a8f3a0369d0d1b94e4c3a5466588adaafe9729 Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Tue, 11 Apr 2023 20:41:27 +0100 Subject: [PATCH 033/129] Excavator: Upgrades Baseline to the latest version (#2553) --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index d7666bce5..88aad7822 100644 --- a/build.gradle +++ b/build.gradle @@ -14,7 +14,7 @@ buildscript { classpath 'com.palantir.gradle.externalpublish:gradle-external-publish-plugin:1.12.0' classpath 'com.palantir.gradle.consistentversions:gradle-consistent-versions:2.11.0' classpath 'com.gradle.publish:plugin-publish-plugin:1.2.0' - classpath 'com.palantir.baseline:gradle-baseline-java:5.5.0' + classpath 'com.palantir.baseline:gradle-baseline-java:5.6.0' classpath 'com.palantir.javaformat:gradle-palantir-java-format:2.28.0' } } From ad9ee08671d0949f5a333b0a567a5f57f81f9733 Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Wed, 12 Apr 2023 06:54:41 +0100 Subject: [PATCH 034/129] Excavator: Format Java files (#2554) --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 88aad7822..419cf78ad 100644 --- a/build.gradle +++ b/build.gradle @@ -15,7 +15,7 @@ buildscript { classpath 'com.palantir.gradle.consistentversions:gradle-consistent-versions:2.11.0' classpath 'com.gradle.publish:plugin-publish-plugin:1.2.0' classpath 'com.palantir.baseline:gradle-baseline-java:5.6.0' - classpath 'com.palantir.javaformat:gradle-palantir-java-format:2.28.0' + classpath 'com.palantir.javaformat:gradle-palantir-java-format:2.29.0' } } From b73d1a9a89a9424db2aa8286b73bd76c17f9caa3 Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Sun, 16 Apr 2023 06:45:03 +0100 Subject: [PATCH 035/129] Excavator: Upgrade dependencies (#2556) --- versions.lock | 12 ++++++------ versions.props | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/versions.lock b/versions.lock index 01949f7ff..d6550ed29 100644 --- a/versions.lock +++ b/versions.lock @@ -91,7 +91,7 @@ com.netflix.nebula:nebula-test:10.2.0 (1 constraints: 35052d3b) com.palantir.conjure.java:conjure-lib:6.77.0 (1 constraints: 4605743b) com.palantir.conjure.java.api:errors:2.34.0 (2 constraints: 6d21c6b0) com.palantir.conjure.java.api:test-utils:2.34.0 (1 constraints: 3b05433b) -com.palantir.conjure.java.runtime:conjure-java-annotations:7.49.0 (1 constraints: 4605743b) +com.palantir.conjure.java.runtime:conjure-java-annotations:7.51.0 (1 constraints: 3f05603b) com.palantir.ri:resource-identifier:2.5.0 (1 constraints: ef0f7999) com.palantir.safe-logging:logger:3.2.0 (2 constraints: da127d36) com.palantir.safe-logging:logger-slf4j:3.2.0 (1 constraints: 000e5942) @@ -106,8 +106,8 @@ io.r2dbc:r2dbc-spi:1.0.0.RELEASE (1 constraints: ea08e898) javax.ws.rs:javax.ws.rs-api:2.1.1 (1 constraints: ec0f6e99) junit:junit:4.13.2 (8 constraints: 1d727319) junit:junit-dep:4.11 (1 constraints: ba1063b3) -net.bytebuddy:byte-buddy:1.14.1 (2 constraints: bd16a34f) -net.bytebuddy:byte-buddy-agent:1.14.1 (1 constraints: 410b3fde) +net.bytebuddy:byte-buddy:1.14.4 (2 constraints: c016a64f) +net.bytebuddy:byte-buddy-agent:1.14.4 (1 constraints: 440b42de) net.lingala.zip4j:zip4j:1.3.2 (1 constraints: 0805fb35) one.util:streamex:0.8.1 (1 constraints: 0b050436) org.apiguardian:apiguardian-api:1.1.2 (7 constraints: 9d791b5f) @@ -116,7 +116,7 @@ org.hamcrest:hamcrest:2.2 (2 constraints: 43187376) org.hamcrest:hamcrest-core:2.2 (4 constraints: 2b2b359e) org.hamcrest:hamcrest-library:2.2 (1 constraints: fc138e38) org.jetbrains:annotations:23.0.0 (2 constraints: f8204e6d) -org.jooq:jooq:3.18.2 (1 constraints: 40054f3b) +org.jooq:jooq:3.18.3 (1 constraints: 4105503b) org.junit.jupiter:junit-jupiter:5.9.2 (1 constraints: 12052136) org.junit.jupiter:junit-jupiter-api:5.9.2 (5 constraints: 6353b5bf) org.junit.jupiter:junit-jupiter-engine:5.9.2 (1 constraints: 0d0ee23b) @@ -125,8 +125,8 @@ org.junit.jupiter:junit-jupiter-params:5.9.2 (1 constraints: 0d0ee23b) org.junit.platform:junit-platform-commons:1.9.2 (2 constraints: df20424b) org.junit.platform:junit-platform-engine:1.9.2 (3 constraints: 622ef47f) org.junit.vintage:junit-vintage-engine:5.9.2 (1 constraints: 12052136) -org.mockito:mockito-core:5.2.0 (3 constraints: 12254117) -org.mockito:mockito-junit-jupiter:5.2.0 (1 constraints: 09050a36) +org.mockito:mockito-core:5.3.0 (3 constraints: 1425a317) +org.mockito:mockito-junit-jupiter:5.3.0 (1 constraints: 0a050d36) org.objenesis:objenesis:3.3 (2 constraints: 9b17f557) org.opentest4j:opentest4j:1.2.0 (2 constraints: cd205b49) org.reactivestreams:reactive-streams:1.0.3 (1 constraints: ef07e77b) diff --git a/versions.props b/versions.props index 84421dedc..f72bda4f3 100644 --- a/versions.props +++ b/versions.props @@ -6,7 +6,7 @@ commons-lang:commons-lang = 2.6 org.apache.maven.shared:maven-dependency-analyzer = 1.13.0 org.apache.maven:maven-core = 3.8.5 org.inferred:freebuilder = 1.14.6 -org.jooq:jooq = 3.18.2 +org.jooq:jooq = 3.18.3 org.slf4j:* = 1.7.36 org.immutables:* = 2.9.3 org.ow2.asm:asm = 9.5 @@ -22,7 +22,7 @@ com.github.stefanbirkner:system-rules = 1.19.0 com.netflix.nebula:nebula-test = 10.2.0 com.palantir.conjure.java:* = 6.77.0 com.palantir.conjure.java.api:* = 2.34.0 -com.palantir.conjure.java.runtime:* = 7.49.0 +com.palantir.conjure.java.runtime:* = 7.51.0 com.palantir.tokens:auth-tokens = 3.17.0 com.palantir.tritium:* = 0.65.0 commons-io:* = 2.11.0 @@ -37,7 +37,7 @@ org.hamcrest:hamcrest-core = 2.2 org.junit.jupiter:* = 5.9.2 org.junit.vintage:* = 5.9.2 org.junit.platform:* = 1.9.2 -org.mockito:* = 5.2.0 +org.mockito:* = 5.3.0 # dependency-upgrader:OFF # Don't upgrade, we will remove this in a future release. From d3771e5231070c7e67adae5b3baff4cbd87f09e4 Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Sun, 16 Apr 2023 09:18:11 +0100 Subject: [PATCH 036/129] Excavator: Upgrade buildscript dependencies (#2557) --- build.gradle | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index 419cf78ad..0cf981813 100644 --- a/build.gradle +++ b/build.gradle @@ -12,7 +12,7 @@ buildscript { classpath 'com.palantir.gradle.jdkslatest:gradle-jdks-latest:0.7.0' classpath 'com.diffplug.gradle:goomph:3.32.1' classpath 'com.palantir.gradle.externalpublish:gradle-external-publish-plugin:1.12.0' - classpath 'com.palantir.gradle.consistentversions:gradle-consistent-versions:2.11.0' + classpath 'com.palantir.gradle.consistentversions:gradle-consistent-versions:2.12.0' classpath 'com.gradle.publish:plugin-publish-plugin:1.2.0' classpath 'com.palantir.baseline:gradle-baseline-java:5.6.0' classpath 'com.palantir.javaformat:gradle-palantir-java-format:2.29.0' @@ -20,8 +20,8 @@ buildscript { } plugins { - id 'com.palantir.git-version' version '0.15.0' - id 'org.inferred.processors' version '3.6.0' +id 'com.palantir.git-version' version '3.0.0' +id 'org.inferred.processors' version '3.7.0' } apply plugin: 'com.palantir.external-publish' From 3db5e603aad7716dea2c1323fccc8fbcfb054fbd Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Mon, 17 Apr 2023 17:31:53 +0100 Subject: [PATCH 037/129] Excavator: Upgrade dependencies (#2558) --- versions.lock | 10 +++++----- versions.props | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/versions.lock b/versions.lock index d6550ed29..df6e8c538 100644 --- a/versions.lock +++ b/versions.lock @@ -31,7 +31,7 @@ com.palantir.gradle.utils:lazily-configured-mapping:0.1.0 (1 constraints: 0305ee com.palantir.javaformat:gradle-palantir-java-format:1.1.0 (1 constraints: 0405f335) com.palantir.javaformat:palantir-java-format-spi:1.1.0 (1 constraints: 711560be) com.uber.nullaway:nullaway:0.10.10 (1 constraints: 64058840) -commons-io:commons-io:2.11.0 (1 constraints: 57119bcb) +commons-io:commons-io:2.11.0 (2 constraints: 1426005d) commons-lang:commons-lang:2.6 (1 constraints: ac04232c) io.github.java-diff-utils:java-diff-utils:4.0 (1 constraints: 811205f6) javax.annotation:javax.annotation-api:1.3.2 (2 constraints: cd204f35) @@ -52,7 +52,7 @@ org.apache.maven.resolver:maven-resolver-api:1.6.3 (5 constraints: 595676e7) org.apache.maven.resolver:maven-resolver-impl:1.6.3 (2 constraints: 2c1db809) org.apache.maven.resolver:maven-resolver-spi:1.6.3 (3 constraints: 5930fd65) org.apache.maven.resolver:maven-resolver-util:1.6.3 (3 constraints: 5930fd65) -org.apache.maven.shared:maven-dependency-analyzer:1.13.0 (1 constraints: 3705323b) +org.apache.maven.shared:maven-dependency-analyzer:1.13.1 (1 constraints: 3805333b) org.apache.maven.shared:maven-shared-utils:3.3.4 (1 constraints: e60b61f3) org.checkerframework:checker-qual:3.33.0 (3 constraints: 08256088) org.checkerframework:dataflow-errorprone:3.33.0 (4 constraints: 0a3e5c60) @@ -64,15 +64,15 @@ org.codehaus.plexus:plexus-classworlds:2.6.0 (3 constraints: 572b5104) org.codehaus.plexus:plexus-component-annotations:2.1.0 (2 constraints: 241d860a) org.codehaus.plexus:plexus-interpolation:1.26 (3 constraints: 7b2bf0f5) org.codehaus.plexus:plexus-sec-dispatcher:2.0 (1 constraints: 5c100b99) -org.codehaus.plexus:plexus-utils:3.4.2 (12 constraints: b6bc07f5) +org.codehaus.plexus:plexus-utils:3.4.1 (11 constraints: 24a8c048) org.eclipse.jgit:org.eclipse.jgit:5.13.0.202109080827-r (3 constraints: a43f6e15) org.eclipse.sisu:org.eclipse.sisu.inject:0.3.5 (3 constraints: 852caa93) org.eclipse.sisu:org.eclipse.sisu.plexus:0.3.5 (2 constraints: 141abc34) org.immutables:value:2.9.3 (1 constraints: 10051336) org.inferred:freebuilder:1.14.6 (1 constraints: 3e053b3b) -org.ow2.asm:asm:9.5 (3 constraints: ec22dfeb) +org.ow2.asm:asm:9.5 (3 constraints: ee22e1eb) org.pcollections:pcollections:3.1.4 (1 constraints: f51029b8) -org.slf4j:slf4j-api:1.7.36 (8 constraints: a3719ea2) +org.slf4j:slf4j-api:1.7.36 (9 constraints: 6d865f95) [Test dependencies] cglib:cglib-nodep:3.2.2 (1 constraints: 490ded24) diff --git a/versions.props b/versions.props index f72bda4f3..952f61fda 100644 --- a/versions.props +++ b/versions.props @@ -3,7 +3,7 @@ com.google.auto.service:auto-service = 1.0.1 com.google.guava:guava = 31.1-jre com.palantir.safe-logging:* = 3.2.0 commons-lang:commons-lang = 2.6 -org.apache.maven.shared:maven-dependency-analyzer = 1.13.0 +org.apache.maven.shared:maven-dependency-analyzer = 1.13.1 org.apache.maven:maven-core = 3.8.5 org.inferred:freebuilder = 1.14.6 org.jooq:jooq = 3.18.3 From d5d4c36c1f9e4874402e010118cec3587e8012ca Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Tue, 18 Apr 2023 00:15:38 +0100 Subject: [PATCH 038/129] Excavator: Upgrade dependencies (#2559) --- versions.lock | 16 ++++++++-------- versions.props | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/versions.lock b/versions.lock index df6e8c538..430aa675f 100644 --- a/versions.lock +++ b/versions.lock @@ -93,12 +93,12 @@ com.palantir.conjure.java.api:errors:2.34.0 (2 constraints: 6d21c6b0) com.palantir.conjure.java.api:test-utils:2.34.0 (1 constraints: 3b05433b) com.palantir.conjure.java.runtime:conjure-java-annotations:7.51.0 (1 constraints: 3f05603b) com.palantir.ri:resource-identifier:2.5.0 (1 constraints: ef0f7999) -com.palantir.safe-logging:logger:3.2.0 (2 constraints: da127d36) -com.palantir.safe-logging:logger-slf4j:3.2.0 (1 constraints: 000e5942) -com.palantir.safe-logging:logger-spi:3.2.0 (2 constraints: 0f1e997a) -com.palantir.safe-logging:preconditions:3.2.0 (6 constraints: 1457bcb5) -com.palantir.safe-logging:preconditions-assertj:3.2.0 (1 constraints: 07050036) -com.palantir.safe-logging:safe-logging:3.2.0 (8 constraints: 5f77a6d7) +com.palantir.safe-logging:logger:3.3.0 (2 constraints: db12a836) +com.palantir.safe-logging:logger-slf4j:3.3.0 (1 constraints: 010e5c42) +com.palantir.safe-logging:logger-spi:3.3.0 (2 constraints: 111ece7a) +com.palantir.safe-logging:preconditions:3.3.0 (6 constraints: 165701b7) +com.palantir.safe-logging:preconditions-assertj:3.3.0 (1 constraints: 08050336) +com.palantir.safe-logging:safe-logging:3.3.0 (8 constraints: 6477e8da) com.palantir.tokens:auth-tokens:3.17.0 (2 constraints: 5f1502db) com.palantir.tritium:tritium-registry:0.65.0 (1 constraints: 3d05463b) io.dropwizard.metrics:metrics-core:4.1.1 (1 constraints: 901088a5) @@ -111,11 +111,11 @@ net.bytebuddy:byte-buddy-agent:1.14.4 (1 constraints: 440b42de) net.lingala.zip4j:zip4j:1.3.2 (1 constraints: 0805fb35) one.util:streamex:0.8.1 (1 constraints: 0b050436) org.apiguardian:apiguardian-api:1.1.2 (7 constraints: 9d791b5f) -org.assertj:assertj-core:3.24.2 (3 constraints: e62ace9f) +org.assertj:assertj-core:3.24.2 (3 constraints: e82ad29f) org.hamcrest:hamcrest:2.2 (2 constraints: 43187376) org.hamcrest:hamcrest-core:2.2 (4 constraints: 2b2b359e) org.hamcrest:hamcrest-library:2.2 (1 constraints: fc138e38) -org.jetbrains:annotations:23.0.0 (2 constraints: f8204e6d) +org.jetbrains:annotations:24.0.1 (2 constraints: fa20546d) org.jooq:jooq:3.18.3 (1 constraints: 4105503b) org.junit.jupiter:junit-jupiter:5.9.2 (1 constraints: 12052136) org.junit.jupiter:junit-jupiter-api:5.9.2 (5 constraints: 6353b5bf) diff --git a/versions.props b/versions.props index 952f61fda..ff35d8686 100644 --- a/versions.props +++ b/versions.props @@ -1,7 +1,7 @@ com.fasterxml.jackson.core:jackson-databind = 2.14.2 com.google.auto.service:auto-service = 1.0.1 com.google.guava:guava = 31.1-jre -com.palantir.safe-logging:* = 3.2.0 +com.palantir.safe-logging:* = 3.3.0 commons-lang:commons-lang = 2.6 org.apache.maven.shared:maven-dependency-analyzer = 1.13.1 org.apache.maven:maven-core = 3.8.5 From b86a264b71a7197fa28bfdca2a53e51a2ea67e25 Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Tue, 18 Apr 2023 16:23:34 +0100 Subject: [PATCH 039/129] Excavator: Upgrade dependencies (#2560) --- versions.lock | 6 +++--- versions.props | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/versions.lock b/versions.lock index 430aa675f..309729617 100644 --- a/versions.lock +++ b/versions.lock @@ -72,7 +72,7 @@ org.immutables:value:2.9.3 (1 constraints: 10051336) org.inferred:freebuilder:1.14.6 (1 constraints: 3e053b3b) org.ow2.asm:asm:9.5 (3 constraints: ee22e1eb) org.pcollections:pcollections:3.1.4 (1 constraints: f51029b8) -org.slf4j:slf4j-api:1.7.36 (9 constraints: 6d865f95) +org.slf4j:slf4j-api:1.7.36 (9 constraints: 6c869d94) [Test dependencies] cglib:cglib-nodep:3.2.2 (1 constraints: 490ded24) @@ -100,8 +100,8 @@ com.palantir.safe-logging:preconditions:3.3.0 (6 constraints: 165701b7) com.palantir.safe-logging:preconditions-assertj:3.3.0 (1 constraints: 08050336) com.palantir.safe-logging:safe-logging:3.3.0 (8 constraints: 6477e8da) com.palantir.tokens:auth-tokens:3.17.0 (2 constraints: 5f1502db) -com.palantir.tritium:tritium-registry:0.65.0 (1 constraints: 3d05463b) -io.dropwizard.metrics:metrics-core:4.1.1 (1 constraints: 901088a5) +com.palantir.tritium:tritium-registry:0.66.0 (1 constraints: 3e05493b) +io.dropwizard.metrics:metrics-core:4.2.18 (1 constraints: c91054b6) io.r2dbc:r2dbc-spi:1.0.0.RELEASE (1 constraints: ea08e898) javax.ws.rs:javax.ws.rs-api:2.1.1 (1 constraints: ec0f6e99) junit:junit:4.13.2 (8 constraints: 1d727319) diff --git a/versions.props b/versions.props index ff35d8686..3a91a086d 100644 --- a/versions.props +++ b/versions.props @@ -24,7 +24,7 @@ com.palantir.conjure.java:* = 6.77.0 com.palantir.conjure.java.api:* = 2.34.0 com.palantir.conjure.java.runtime:* = 7.51.0 com.palantir.tokens:auth-tokens = 3.17.0 -com.palantir.tritium:* = 0.65.0 +com.palantir.tritium:* = 0.66.0 commons-io:* = 2.11.0 junit:junit = 4.13.2 net.lingala.zip4j:zip4j = 1.3.2 From d0da83135f7d8e91c975ab47c497b88a6fee3550 Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Wed, 19 Apr 2023 02:30:26 +0100 Subject: [PATCH 040/129] Excavator: Upgrade dependencies (#2562) --- versions.lock | 6 +++--- versions.props | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/versions.lock b/versions.lock index 309729617..593640102 100644 --- a/versions.lock +++ b/versions.lock @@ -96,11 +96,11 @@ com.palantir.ri:resource-identifier:2.5.0 (1 constraints: ef0f7999) com.palantir.safe-logging:logger:3.3.0 (2 constraints: db12a836) com.palantir.safe-logging:logger-slf4j:3.3.0 (1 constraints: 010e5c42) com.palantir.safe-logging:logger-spi:3.3.0 (2 constraints: 111ece7a) -com.palantir.safe-logging:preconditions:3.3.0 (6 constraints: 165701b7) +com.palantir.safe-logging:preconditions:3.3.0 (6 constraints: 175704b7) com.palantir.safe-logging:preconditions-assertj:3.3.0 (1 constraints: 08050336) -com.palantir.safe-logging:safe-logging:3.3.0 (8 constraints: 6477e8da) +com.palantir.safe-logging:safe-logging:3.3.0 (8 constraints: 6577ebda) com.palantir.tokens:auth-tokens:3.17.0 (2 constraints: 5f1502db) -com.palantir.tritium:tritium-registry:0.66.0 (1 constraints: 3e05493b) +com.palantir.tritium:tritium-registry:0.67.0 (1 constraints: 3f054c3b) io.dropwizard.metrics:metrics-core:4.2.18 (1 constraints: c91054b6) io.r2dbc:r2dbc-spi:1.0.0.RELEASE (1 constraints: ea08e898) javax.ws.rs:javax.ws.rs-api:2.1.1 (1 constraints: ec0f6e99) diff --git a/versions.props b/versions.props index 3a91a086d..42e9aa84b 100644 --- a/versions.props +++ b/versions.props @@ -24,7 +24,7 @@ com.palantir.conjure.java:* = 6.77.0 com.palantir.conjure.java.api:* = 2.34.0 com.palantir.conjure.java.runtime:* = 7.51.0 com.palantir.tokens:auth-tokens = 3.17.0 -com.palantir.tritium:* = 0.66.0 +com.palantir.tritium:* = 0.67.0 commons-io:* = 2.11.0 junit:junit = 4.13.2 net.lingala.zip4j:zip4j = 1.3.2 From 6be194ecd69863544eba380da24b3a17b8843bb7 Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Wed, 19 Apr 2023 17:11:13 +0100 Subject: [PATCH 041/129] Excavator: Upgrade dependencies (#2564) --- versions.lock | 2 +- versions.props | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/versions.lock b/versions.lock index 593640102..ba6a9086e 100644 --- a/versions.lock +++ b/versions.lock @@ -91,7 +91,7 @@ com.netflix.nebula:nebula-test:10.2.0 (1 constraints: 35052d3b) com.palantir.conjure.java:conjure-lib:6.77.0 (1 constraints: 4605743b) com.palantir.conjure.java.api:errors:2.34.0 (2 constraints: 6d21c6b0) com.palantir.conjure.java.api:test-utils:2.34.0 (1 constraints: 3b05433b) -com.palantir.conjure.java.runtime:conjure-java-annotations:7.51.0 (1 constraints: 3f05603b) +com.palantir.conjure.java.runtime:conjure-java-annotations:7.52.0 (1 constraints: 4005633b) com.palantir.ri:resource-identifier:2.5.0 (1 constraints: ef0f7999) com.palantir.safe-logging:logger:3.3.0 (2 constraints: db12a836) com.palantir.safe-logging:logger-slf4j:3.3.0 (1 constraints: 010e5c42) diff --git a/versions.props b/versions.props index 42e9aa84b..5d42f71c1 100644 --- a/versions.props +++ b/versions.props @@ -22,7 +22,7 @@ com.github.stefanbirkner:system-rules = 1.19.0 com.netflix.nebula:nebula-test = 10.2.0 com.palantir.conjure.java:* = 6.77.0 com.palantir.conjure.java.api:* = 2.34.0 -com.palantir.conjure.java.runtime:* = 7.51.0 +com.palantir.conjure.java.runtime:* = 7.52.0 com.palantir.tokens:auth-tokens = 3.17.0 com.palantir.tritium:* = 0.67.0 commons-io:* = 2.11.0 From 595135525336e61564af967e03a27abe04b66538 Mon Sep 17 00:00:00 2001 From: rzpt <51346452+rzpt@users.noreply.github.com> Date: Wed, 19 Apr 2023 10:24:20 -0700 Subject: [PATCH 042/129] fix eclipse classpath generation (#2563) Fix eclipse classpath generation by deleting the existing classpath, which makes the classpath correct when it changes. --- .gitignore | 3 +++ changelog/@unreleased/pr-2563.v2.yml | 6 ++++++ .../com/palantir/baseline/plugins/BaselineEclipse.groovy | 2 ++ 3 files changed, 11 insertions(+) create mode 100644 changelog/@unreleased/pr-2563.v2.yml diff --git a/.gitignore b/.gitignore index 74d2ac9d6..4ef0a1d3b 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,9 @@ .java-version .project .settings +.factorypath +.apt_generated_tests/ +bin/ build out/ docs/node_modules/ diff --git a/changelog/@unreleased/pr-2563.v2.yml b/changelog/@unreleased/pr-2563.v2.yml new file mode 100644 index 000000000..aac001310 --- /dev/null +++ b/changelog/@unreleased/pr-2563.v2.yml @@ -0,0 +1,6 @@ +type: improvement +improvement: + description: |- + Fix eclipse classpath generation by deleting the existing classpath, which makes the classpath correct when it changes. + links: + - https://github.com/palantir/gradle-baseline/pull/2563 diff --git a/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineEclipse.groovy b/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineEclipse.groovy index 8e0522a68..fae827772 100644 --- a/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineEclipse.groovy +++ b/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineEclipse.groovy @@ -140,6 +140,8 @@ class BaselineEclipse extends AbstractBaselinePlugin { containers.add(eclipseClassPath) } } + // Delete classpath instead of merging with existing classpath + dependsOn "cleanEclipseClasspath" } } }) From 7433f164d9a78423d71b9587e52118cc7686c672 Mon Sep 17 00:00:00 2001 From: svc-autorelease Date: Wed, 19 Apr 2023 17:24:27 +0000 Subject: [PATCH 043/129] Autorelease 5.7.0 [skip ci] --- changelog/{@unreleased => 5.7.0}/pr-2563.v2.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename changelog/{@unreleased => 5.7.0}/pr-2563.v2.yml (100%) diff --git a/changelog/@unreleased/pr-2563.v2.yml b/changelog/5.7.0/pr-2563.v2.yml similarity index 100% rename from changelog/@unreleased/pr-2563.v2.yml rename to changelog/5.7.0/pr-2563.v2.yml From 210d49b2c42ee5c7b2bf051c85cb942dc571ad56 Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Fri, 21 Apr 2023 00:08:23 +0100 Subject: [PATCH 044/129] Excavator: Upgrade dependencies (#2566) --- versions.lock | 2 +- versions.props | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/versions.lock b/versions.lock index ba6a9086e..9797864b8 100644 --- a/versions.lock +++ b/versions.lock @@ -91,7 +91,7 @@ com.netflix.nebula:nebula-test:10.2.0 (1 constraints: 35052d3b) com.palantir.conjure.java:conjure-lib:6.77.0 (1 constraints: 4605743b) com.palantir.conjure.java.api:errors:2.34.0 (2 constraints: 6d21c6b0) com.palantir.conjure.java.api:test-utils:2.34.0 (1 constraints: 3b05433b) -com.palantir.conjure.java.runtime:conjure-java-annotations:7.52.0 (1 constraints: 4005633b) +com.palantir.conjure.java.runtime:conjure-java-annotations:7.53.0 (1 constraints: 4105663b) com.palantir.ri:resource-identifier:2.5.0 (1 constraints: ef0f7999) com.palantir.safe-logging:logger:3.3.0 (2 constraints: db12a836) com.palantir.safe-logging:logger-slf4j:3.3.0 (1 constraints: 010e5c42) diff --git a/versions.props b/versions.props index 5d42f71c1..3fed6eda4 100644 --- a/versions.props +++ b/versions.props @@ -22,7 +22,7 @@ com.github.stefanbirkner:system-rules = 1.19.0 com.netflix.nebula:nebula-test = 10.2.0 com.palantir.conjure.java:* = 6.77.0 com.palantir.conjure.java.api:* = 2.34.0 -com.palantir.conjure.java.runtime:* = 7.52.0 +com.palantir.conjure.java.runtime:* = 7.53.0 com.palantir.tokens:auth-tokens = 3.17.0 com.palantir.tritium:* = 0.67.0 commons-io:* = 2.11.0 From b33f802feb94e62147a66884f28c2151140e7fb1 Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Fri, 21 Apr 2023 18:30:42 +0100 Subject: [PATCH 045/129] Excavator: Upgrade dependencies (#2567) --- versions.lock | 12 ++++++------ versions.props | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/versions.lock b/versions.lock index 9797864b8..585800eca 100644 --- a/versions.lock +++ b/versions.lock @@ -93,12 +93,12 @@ com.palantir.conjure.java.api:errors:2.34.0 (2 constraints: 6d21c6b0) com.palantir.conjure.java.api:test-utils:2.34.0 (1 constraints: 3b05433b) com.palantir.conjure.java.runtime:conjure-java-annotations:7.53.0 (1 constraints: 4105663b) com.palantir.ri:resource-identifier:2.5.0 (1 constraints: ef0f7999) -com.palantir.safe-logging:logger:3.3.0 (2 constraints: db12a836) -com.palantir.safe-logging:logger-slf4j:3.3.0 (1 constraints: 010e5c42) -com.palantir.safe-logging:logger-spi:3.3.0 (2 constraints: 111ece7a) -com.palantir.safe-logging:preconditions:3.3.0 (6 constraints: 175704b7) -com.palantir.safe-logging:preconditions-assertj:3.3.0 (1 constraints: 08050336) -com.palantir.safe-logging:safe-logging:3.3.0 (8 constraints: 6577ebda) +com.palantir.safe-logging:logger:3.4.0 (2 constraints: dc12d336) +com.palantir.safe-logging:logger-slf4j:3.4.0 (1 constraints: 020e5f42) +com.palantir.safe-logging:logger-spi:3.4.0 (2 constraints: 131e037b) +com.palantir.safe-logging:preconditions:3.4.0 (6 constraints: 195749b8) +com.palantir.safe-logging:preconditions-assertj:3.4.0 (1 constraints: 09050636) +com.palantir.safe-logging:safe-logging:3.4.0 (8 constraints: 6a772dde) com.palantir.tokens:auth-tokens:3.17.0 (2 constraints: 5f1502db) com.palantir.tritium:tritium-registry:0.67.0 (1 constraints: 3f054c3b) io.dropwizard.metrics:metrics-core:4.2.18 (1 constraints: c91054b6) diff --git a/versions.props b/versions.props index 3fed6eda4..9888dd100 100644 --- a/versions.props +++ b/versions.props @@ -1,7 +1,7 @@ com.fasterxml.jackson.core:jackson-databind = 2.14.2 com.google.auto.service:auto-service = 1.0.1 com.google.guava:guava = 31.1-jre -com.palantir.safe-logging:* = 3.3.0 +com.palantir.safe-logging:* = 3.4.0 commons-lang:commons-lang = 2.6 org.apache.maven.shared:maven-dependency-analyzer = 1.13.1 org.apache.maven:maven-core = 3.8.5 From a192b76256d9cd6fb2808449fc3b06355c862360 Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Sat, 22 Apr 2023 02:42:22 +0100 Subject: [PATCH 046/129] Excavator: Upgrade dependencies (#2568) --- versions.lock | 20 ++++++++++---------- versions.props | 6 +++--- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/versions.lock b/versions.lock index 585800eca..0e15bd81e 100644 --- a/versions.lock +++ b/versions.lock @@ -36,7 +36,7 @@ commons-lang:commons-lang:2.6 (1 constraints: ac04232c) io.github.java-diff-utils:java-diff-utils:4.0 (1 constraints: 811205f6) javax.annotation:javax.annotation-api:1.3.2 (2 constraints: cd204f35) javax.inject:javax.inject:1 (9 constraints: e5867a2e) -net.ltgt.gradle:gradle-errorprone-plugin:3.0.1 (1 constraints: 0605fb35) +net.ltgt.gradle:gradle-errorprone-plugin:3.1.0 (1 constraints: 0605fd35) org.apache.commons:commons-lang3:3.12.0 (4 constraints: da318b7f) org.apache.maven:maven-artifact:3.8.5 (4 constraints: 1e3ed043) org.apache.maven:maven-builder-support:3.8.5 (3 constraints: 1a2c0e66) @@ -78,7 +78,7 @@ org.slf4j:slf4j-api:1.7.36 (9 constraints: 6c869d94) cglib:cglib-nodep:3.2.2 (1 constraints: 490ded24) com.fasterxml.jackson.core:jackson-annotations:2.14.2 (4 constraints: 5c35b0b9) com.fasterxml.jackson.core:jackson-core:2.14.2 (2 constraints: 0a2a8e13) -com.fasterxml.jackson.core:jackson-databind:2.14.2 (5 constraints: ac4ad65f) +com.fasterxml.jackson.core:jackson-databind:2.14.2 (5 constraints: ad4a0060) com.fasterxml.jackson.module:jackson-module-afterburner:2.14.2 (1 constraints: 3b053d3b) com.github.stefanbirkner:system-rules:1.19.0 (1 constraints: 3d05443b) com.google.auto.value:auto-value:1.7.4 (1 constraints: 1f1221fb) @@ -89,16 +89,16 @@ com.google.testing.compile:compile-testing:0.19 (1 constraints: 3214b94c) com.google.truth:truth:1.1.3 (2 constraints: 1126a31d) com.netflix.nebula:nebula-test:10.2.0 (1 constraints: 35052d3b) com.palantir.conjure.java:conjure-lib:6.77.0 (1 constraints: 4605743b) -com.palantir.conjure.java.api:errors:2.34.0 (2 constraints: 6d21c6b0) -com.palantir.conjure.java.api:test-utils:2.34.0 (1 constraints: 3b05433b) +com.palantir.conjure.java.api:errors:2.35.0 (2 constraints: 6e21c9b0) +com.palantir.conjure.java.api:test-utils:2.35.0 (1 constraints: 3c05463b) com.palantir.conjure.java.runtime:conjure-java-annotations:7.53.0 (1 constraints: 4105663b) com.palantir.ri:resource-identifier:2.5.0 (1 constraints: ef0f7999) com.palantir.safe-logging:logger:3.4.0 (2 constraints: dc12d336) com.palantir.safe-logging:logger-slf4j:3.4.0 (1 constraints: 020e5f42) com.palantir.safe-logging:logger-spi:3.4.0 (2 constraints: 131e037b) -com.palantir.safe-logging:preconditions:3.4.0 (6 constraints: 195749b8) +com.palantir.safe-logging:preconditions:3.4.0 (6 constraints: 1b576bb9) com.palantir.safe-logging:preconditions-assertj:3.4.0 (1 constraints: 09050636) -com.palantir.safe-logging:safe-logging:3.4.0 (8 constraints: 6a772dde) +com.palantir.safe-logging:safe-logging:3.4.0 (8 constraints: 6c7765e0) com.palantir.tokens:auth-tokens:3.17.0 (2 constraints: 5f1502db) com.palantir.tritium:tritium-registry:0.67.0 (1 constraints: 3f054c3b) io.dropwizard.metrics:metrics-core:4.2.18 (1 constraints: c91054b6) @@ -111,11 +111,11 @@ net.bytebuddy:byte-buddy-agent:1.14.4 (1 constraints: 440b42de) net.lingala.zip4j:zip4j:1.3.2 (1 constraints: 0805fb35) one.util:streamex:0.8.1 (1 constraints: 0b050436) org.apiguardian:apiguardian-api:1.1.2 (7 constraints: 9d791b5f) -org.assertj:assertj-core:3.24.2 (3 constraints: e82ad29f) +org.assertj:assertj-core:3.24.2 (3 constraints: ea2a48a0) org.hamcrest:hamcrest:2.2 (2 constraints: 43187376) org.hamcrest:hamcrest-core:2.2 (4 constraints: 2b2b359e) org.hamcrest:hamcrest-library:2.2 (1 constraints: fc138e38) -org.jetbrains:annotations:24.0.1 (2 constraints: fa20546d) +org.jetbrains:annotations:24.0.1 (2 constraints: fc20bc6d) org.jooq:jooq:3.18.3 (1 constraints: 4105503b) org.junit.jupiter:junit-jupiter:5.9.2 (1 constraints: 12052136) org.junit.jupiter:junit-jupiter-api:5.9.2 (5 constraints: 6353b5bf) @@ -125,8 +125,8 @@ org.junit.jupiter:junit-jupiter-params:5.9.2 (1 constraints: 0d0ee23b) org.junit.platform:junit-platform-commons:1.9.2 (2 constraints: df20424b) org.junit.platform:junit-platform-engine:1.9.2 (3 constraints: 622ef47f) org.junit.vintage:junit-vintage-engine:5.9.2 (1 constraints: 12052136) -org.mockito:mockito-core:5.3.0 (3 constraints: 1425a317) -org.mockito:mockito-junit-jupiter:5.3.0 (1 constraints: 0a050d36) +org.mockito:mockito-core:5.3.1 (3 constraints: e92446fa) +org.mockito:mockito-junit-jupiter:5.3.1 (1 constraints: 0b050e36) org.objenesis:objenesis:3.3 (2 constraints: 9b17f557) org.opentest4j:opentest4j:1.2.0 (2 constraints: cd205b49) org.reactivestreams:reactive-streams:1.0.3 (1 constraints: ef07e77b) diff --git a/versions.props b/versions.props index 9888dd100..2852c9bdf 100644 --- a/versions.props +++ b/versions.props @@ -21,14 +21,14 @@ com.fasterxml.jackson.*:* = 2.14.2 com.github.stefanbirkner:system-rules = 1.19.0 com.netflix.nebula:nebula-test = 10.2.0 com.palantir.conjure.java:* = 6.77.0 -com.palantir.conjure.java.api:* = 2.34.0 +com.palantir.conjure.java.api:* = 2.35.0 com.palantir.conjure.java.runtime:* = 7.53.0 com.palantir.tokens:auth-tokens = 3.17.0 com.palantir.tritium:* = 0.67.0 commons-io:* = 2.11.0 junit:junit = 4.13.2 net.lingala.zip4j:zip4j = 1.3.2 -net.ltgt.gradle:gradle-errorprone-plugin = 3.0.1 +net.ltgt.gradle:gradle-errorprone-plugin = 3.1.0 one.util:streamex = 0.8.1 org.apache.commons:commons-lang3 = 3.12.0 org.assertj:assertj-core = 3.24.2 @@ -37,7 +37,7 @@ org.hamcrest:hamcrest-core = 2.2 org.junit.jupiter:* = 5.9.2 org.junit.vintage:* = 5.9.2 org.junit.platform:* = 1.9.2 -org.mockito:* = 5.3.0 +org.mockito:* = 5.3.1 # dependency-upgrader:OFF # Don't upgrade, we will remove this in a future release. From 65823a660413ccf9297134d55e04a29988e6b92c Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Mon, 24 Apr 2023 21:36:21 +0100 Subject: [PATCH 047/129] Excavator: Upgrade dependencies (#2569) --- versions.lock | 2 +- versions.props | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/versions.lock b/versions.lock index 0e15bd81e..0347d08a3 100644 --- a/versions.lock +++ b/versions.lock @@ -91,7 +91,7 @@ com.netflix.nebula:nebula-test:10.2.0 (1 constraints: 35052d3b) com.palantir.conjure.java:conjure-lib:6.77.0 (1 constraints: 4605743b) com.palantir.conjure.java.api:errors:2.35.0 (2 constraints: 6e21c9b0) com.palantir.conjure.java.api:test-utils:2.35.0 (1 constraints: 3c05463b) -com.palantir.conjure.java.runtime:conjure-java-annotations:7.53.0 (1 constraints: 4105663b) +com.palantir.conjure.java.runtime:conjure-java-annotations:7.54.0 (1 constraints: 4205693b) com.palantir.ri:resource-identifier:2.5.0 (1 constraints: ef0f7999) com.palantir.safe-logging:logger:3.4.0 (2 constraints: dc12d336) com.palantir.safe-logging:logger-slf4j:3.4.0 (1 constraints: 020e5f42) diff --git a/versions.props b/versions.props index 2852c9bdf..2d77f8910 100644 --- a/versions.props +++ b/versions.props @@ -22,7 +22,7 @@ com.github.stefanbirkner:system-rules = 1.19.0 com.netflix.nebula:nebula-test = 10.2.0 com.palantir.conjure.java:* = 6.77.0 com.palantir.conjure.java.api:* = 2.35.0 -com.palantir.conjure.java.runtime:* = 7.53.0 +com.palantir.conjure.java.runtime:* = 7.54.0 com.palantir.tokens:auth-tokens = 3.17.0 com.palantir.tritium:* = 0.67.0 commons-io:* = 2.11.0 From 6a78e2e5895302ce739ebc102ef9d48d4a5ab3b5 Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Tue, 25 Apr 2023 21:45:15 +0100 Subject: [PATCH 048/129] Excavator: Upgrade dependencies (#2570) --- versions.lock | 2 +- versions.props | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/versions.lock b/versions.lock index 0347d08a3..ba71c99a2 100644 --- a/versions.lock +++ b/versions.lock @@ -91,7 +91,7 @@ com.netflix.nebula:nebula-test:10.2.0 (1 constraints: 35052d3b) com.palantir.conjure.java:conjure-lib:6.77.0 (1 constraints: 4605743b) com.palantir.conjure.java.api:errors:2.35.0 (2 constraints: 6e21c9b0) com.palantir.conjure.java.api:test-utils:2.35.0 (1 constraints: 3c05463b) -com.palantir.conjure.java.runtime:conjure-java-annotations:7.54.0 (1 constraints: 4205693b) +com.palantir.conjure.java.runtime:conjure-java-annotations:7.55.0 (1 constraints: 43056c3b) com.palantir.ri:resource-identifier:2.5.0 (1 constraints: ef0f7999) com.palantir.safe-logging:logger:3.4.0 (2 constraints: dc12d336) com.palantir.safe-logging:logger-slf4j:3.4.0 (1 constraints: 020e5f42) diff --git a/versions.props b/versions.props index 2d77f8910..a01faf4eb 100644 --- a/versions.props +++ b/versions.props @@ -22,7 +22,7 @@ com.github.stefanbirkner:system-rules = 1.19.0 com.netflix.nebula:nebula-test = 10.2.0 com.palantir.conjure.java:* = 6.77.0 com.palantir.conjure.java.api:* = 2.35.0 -com.palantir.conjure.java.runtime:* = 7.54.0 +com.palantir.conjure.java.runtime:* = 7.55.0 com.palantir.tokens:auth-tokens = 3.17.0 com.palantir.tritium:* = 0.67.0 commons-io:* = 2.11.0 From e26cd9e63947dab68f96cc9ee485e394db516ad2 Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Wed, 26 Apr 2023 00:49:07 +0100 Subject: [PATCH 049/129] Excavator: Format Java files (#2571) --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 0cf981813..c60ccc051 100644 --- a/build.gradle +++ b/build.gradle @@ -15,7 +15,7 @@ buildscript { classpath 'com.palantir.gradle.consistentversions:gradle-consistent-versions:2.12.0' classpath 'com.gradle.publish:plugin-publish-plugin:1.2.0' classpath 'com.palantir.baseline:gradle-baseline-java:5.6.0' - classpath 'com.palantir.javaformat:gradle-palantir-java-format:2.29.0' + classpath 'com.palantir.javaformat:gradle-palantir-java-format:2.30.0' } } From 370f4a66ac1693d9ef1adaee2e3f14b1a977a284 Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Wed, 26 Apr 2023 02:21:40 +0100 Subject: [PATCH 050/129] Excavator: Upgrades Baseline to the latest version (#2565) --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index c60ccc051..92267327a 100644 --- a/build.gradle +++ b/build.gradle @@ -14,7 +14,7 @@ buildscript { classpath 'com.palantir.gradle.externalpublish:gradle-external-publish-plugin:1.12.0' classpath 'com.palantir.gradle.consistentversions:gradle-consistent-versions:2.12.0' classpath 'com.gradle.publish:plugin-publish-plugin:1.2.0' - classpath 'com.palantir.baseline:gradle-baseline-java:5.6.0' + classpath 'com.palantir.baseline:gradle-baseline-java:5.7.0' classpath 'com.palantir.javaformat:gradle-palantir-java-format:2.30.0' } } From 72d0b0a8218b1b86e49951c9df216dab2d9340f6 Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Wed, 26 Apr 2023 15:00:23 +0100 Subject: [PATCH 051/129] Excavator: Upgrade dependencies (#2572) --- .../src/main/resources/checkstyle.version | 2 +- versions.lock | 16 ++++++++-------- versions.props | 8 ++++---- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/gradle-baseline-java/src/main/resources/checkstyle.version b/gradle-baseline-java/src/main/resources/checkstyle.version index ef848858d..4843a6d66 100644 --- a/gradle-baseline-java/src/main/resources/checkstyle.version +++ b/gradle-baseline-java/src/main/resources/checkstyle.version @@ -1 +1 @@ -10.9.3 \ No newline at end of file +10.10.0 \ No newline at end of file diff --git a/versions.lock b/versions.lock index ba71c99a2..4b197a88a 100644 --- a/versions.lock +++ b/versions.lock @@ -117,14 +117,14 @@ org.hamcrest:hamcrest-core:2.2 (4 constraints: 2b2b359e) org.hamcrest:hamcrest-library:2.2 (1 constraints: fc138e38) org.jetbrains:annotations:24.0.1 (2 constraints: fc20bc6d) org.jooq:jooq:3.18.3 (1 constraints: 4105503b) -org.junit.jupiter:junit-jupiter:5.9.2 (1 constraints: 12052136) -org.junit.jupiter:junit-jupiter-api:5.9.2 (5 constraints: 6353b5bf) -org.junit.jupiter:junit-jupiter-engine:5.9.2 (1 constraints: 0d0ee23b) -org.junit.jupiter:junit-jupiter-migrationsupport:5.9.2 (1 constraints: 12052136) -org.junit.jupiter:junit-jupiter-params:5.9.2 (1 constraints: 0d0ee23b) -org.junit.platform:junit-platform-commons:1.9.2 (2 constraints: df20424b) -org.junit.platform:junit-platform-engine:1.9.2 (3 constraints: 622ef47f) -org.junit.vintage:junit-vintage-engine:5.9.2 (1 constraints: 12052136) +org.junit.jupiter:junit-jupiter:5.9.3 (1 constraints: 13052236) +org.junit.jupiter:junit-jupiter-api:5.9.3 (5 constraints: 67538fc1) +org.junit.jupiter:junit-jupiter-engine:5.9.3 (1 constraints: 0e0ee33b) +org.junit.jupiter:junit-jupiter-migrationsupport:5.9.3 (1 constraints: 13052236) +org.junit.jupiter:junit-jupiter-params:5.9.3 (1 constraints: 0e0ee33b) +org.junit.platform:junit-platform-commons:1.9.3 (2 constraints: e120754b) +org.junit.platform:junit-platform-engine:1.9.3 (3 constraints: 642e7180) +org.junit.vintage:junit-vintage-engine:5.9.3 (1 constraints: 13052236) org.mockito:mockito-core:5.3.1 (3 constraints: e92446fa) org.mockito:mockito-junit-jupiter:5.3.1 (1 constraints: 0b050e36) org.objenesis:objenesis:3.3 (2 constraints: 9b17f557) diff --git a/versions.props b/versions.props index a01faf4eb..743471c72 100644 --- a/versions.props +++ b/versions.props @@ -12,7 +12,7 @@ org.immutables:* = 2.9.3 org.ow2.asm:asm = 9.5 com.google.errorprone:error_prone_* = 2.18.0 com.googlecode.java-diff-utils:diffutils = 1.3.0 -com.puppycrawl.tools:checkstyle = 10.9.3 +com.puppycrawl.tools:checkstyle = 10.10.0 com.palantir.gradle.utils:* = 0.1.0 com.uber.nullaway:nullaway = 0.10.10 @@ -34,9 +34,9 @@ org.apache.commons:commons-lang3 = 3.12.0 org.assertj:assertj-core = 3.24.2 org.checkerframework:* = 3.33.0 org.hamcrest:hamcrest-core = 2.2 -org.junit.jupiter:* = 5.9.2 -org.junit.vintage:* = 5.9.2 -org.junit.platform:* = 1.9.2 +org.junit.jupiter:* = 5.9.3 +org.junit.vintage:* = 5.9.3 +org.junit.platform:* = 1.9.3 org.mockito:* = 5.3.1 # dependency-upgrader:OFF From d18a14ff394328af9e81650496973a6be6510dc9 Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Wed, 3 May 2023 18:20:33 +0100 Subject: [PATCH 052/129] Excavator: Update policy-bot config (#2574) --- .policy.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.policy.yml b/.policy.yml index b9dc830bb..d8f732c36 100644 --- a/.policy.yml +++ b/.policy.yml @@ -20,21 +20,21 @@ approval_rules: allow_contributor: false requires: count: 1 - admins: true + permissions: ["admin", "maintain"] - name: two admins have approved options: allow_contributor: true requires: count: 2 - admins: true + permissions: ["admin", "maintain"] - name: changelog only and contributor approval options: allow_contributor: true requires: count: 1 - admins: true + permissions: ["admin", "maintain"] if: only_changed_files: paths: @@ -45,7 +45,7 @@ approval_rules: allow_contributor: true requires: count: 1 - admins: true + permissions: ["admin", "maintain"] if: has_author_in: users: [ "svc-excavator-bot" ] From 2f65d9d84c315fbe4ccac8b095d5a27a239f1969 Mon Sep 17 00:00:00 2001 From: athabet812 <133794337+athabet812@users.noreply.github.com> Date: Wed, 17 May 2023 16:23:11 +0100 Subject: [PATCH 053/129] Only pass posix file attributes if not on Windows (#2577) Only pass posix file attributes if not on Windows --- changelog/@unreleased/pr-2577.v2.yml | 6 ++++++ .../baseline/plugins/BaselineCircleCi.java | 18 ++++++++++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 changelog/@unreleased/pr-2577.v2.yml diff --git a/changelog/@unreleased/pr-2577.v2.yml b/changelog/@unreleased/pr-2577.v2.yml new file mode 100644 index 000000000..d3de644e7 --- /dev/null +++ b/changelog/@unreleased/pr-2577.v2.yml @@ -0,0 +1,6 @@ +type: fix +improvement: + description: |- + Only pass posix file attributes if not on Windows + links: + - https://github.com/palantir/gradle-baseline/pull/2577 diff --git a/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineCircleCi.java b/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineCircleCi.java index 2c496732d..8983ae0f4 100644 --- a/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineCircleCi.java +++ b/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineCircleCi.java @@ -27,20 +27,20 @@ import java.nio.file.attribute.FileAttribute; import java.nio.file.attribute.PosixFilePermission; import java.nio.file.attribute.PosixFilePermissions; +import java.util.Locale; import java.util.Set; import org.gradle.api.Plugin; import org.gradle.api.Project; import org.gradle.api.tasks.testing.Test; public final class BaselineCircleCi implements Plugin { - private static final FileAttribute> PERMS_ATTRIBUTE = + private static final FileAttribute> POSIX_PERMS_ATTRIBUTE = PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString("rwxr-xr-x")); @Override public void apply(Project project) { configurePluginsForReports(project); configurePluginsForArtifacts(project); - Preconditions.checkState( !project.getName().equals("project"), "Please specify rootProject.name in your settings.gradle, otherwise CircleCI's" @@ -55,7 +55,7 @@ private void configurePluginsForArtifacts(Project project) { } try { - Files.createDirectories(Paths.get(circleArtifactsDir), PERMS_ATTRIBUTE); + createDirectories(Paths.get(circleArtifactsDir)); } catch (IOException e) { throw new RuntimeException("failed to create CIRCLE_ARTIFACTS directory", e); } @@ -74,7 +74,7 @@ private void configurePluginsForReports(Project project) { } try { - Files.createDirectories(Paths.get(circleReportsDir), PERMS_ATTRIBUTE); + createDirectories(Paths.get(circleReportsDir)); } catch (IOException e) { throw new RuntimeException("failed to create CIRCLE_TEST_REPORTS directory", e); } @@ -102,4 +102,14 @@ private static File junitPath(String basePath, String testPath) { } return junitReportsDir.toFile(); } + + private static void createDirectories(Path directoryPath) throws IOException { + boolean isWindows = + System.getProperty("os.name").toLowerCase(Locale.ROOT).contains("windows"); + if (isWindows) { + Files.createDirectories(directoryPath); + } else { + Files.createDirectories(directoryPath, POSIX_PERMS_ATTRIBUTE); + } + } } From 9bf2f07d519fe45b88fceac6fc4d2777821a715d Mon Sep 17 00:00:00 2001 From: athabet812 <133794337+athabet812@users.noreply.github.com> Date: Wed, 17 May 2023 16:45:00 +0100 Subject: [PATCH 054/129] Fix changelog (#2579) Fix changelog --- changelog/@unreleased/pr-2577.v2.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/changelog/@unreleased/pr-2577.v2.yml b/changelog/@unreleased/pr-2577.v2.yml index d3de644e7..791385f28 100644 --- a/changelog/@unreleased/pr-2577.v2.yml +++ b/changelog/@unreleased/pr-2577.v2.yml @@ -1,6 +1,5 @@ type: fix -improvement: - description: |- - Only pass posix file attributes if not on Windows +fix: + description: Only pass posix file attributes if not on Windows links: - https://github.com/palantir/gradle-baseline/pull/2577 From b659af11a563ca641fd37c99e80a1954d551fc81 Mon Sep 17 00:00:00 2001 From: svc-autorelease Date: Wed, 17 May 2023 15:45:09 +0000 Subject: [PATCH 055/129] Autorelease 5.8.0 [skip ci] --- changelog/{@unreleased => 5.8.0}/pr-2577.v2.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename changelog/{@unreleased => 5.8.0}/pr-2577.v2.yml (100%) diff --git a/changelog/@unreleased/pr-2577.v2.yml b/changelog/5.8.0/pr-2577.v2.yml similarity index 100% rename from changelog/@unreleased/pr-2577.v2.yml rename to changelog/5.8.0/pr-2577.v2.yml From d72c1c2bcac794c4e9d1dc76aae95d8f68b9b24a Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Wed, 17 May 2023 19:49:43 +0100 Subject: [PATCH 056/129] Excavator: Upgrades Baseline to the latest version (#2580) --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 92267327a..e2bededd2 100644 --- a/build.gradle +++ b/build.gradle @@ -14,7 +14,7 @@ buildscript { classpath 'com.palantir.gradle.externalpublish:gradle-external-publish-plugin:1.12.0' classpath 'com.palantir.gradle.consistentversions:gradle-consistent-versions:2.12.0' classpath 'com.gradle.publish:plugin-publish-plugin:1.2.0' - classpath 'com.palantir.baseline:gradle-baseline-java:5.7.0' + classpath 'com.palantir.baseline:gradle-baseline-java:5.8.0' classpath 'com.palantir.javaformat:gradle-palantir-java-format:2.30.0' } } From e5a61393bb56c6a8d5bc17e3912d7938bb92aa8b Mon Sep 17 00:00:00 2001 From: Alexander Hill Date: Wed, 17 May 2023 15:19:41 -0400 Subject: [PATCH 057/129] Don't ignore all directories named build/ (#2578) Don't ignore all directories named build/ --- changelog/@unreleased/pr-2578.v2.yml | 5 +++++ .../com/palantir/baseline/plugins/BaselineErrorProne.java | 2 +- .../palantir/baseline/plugins/BaselineErrorProneTest.groovy | 5 ++++- 3 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 changelog/@unreleased/pr-2578.v2.yml diff --git a/changelog/@unreleased/pr-2578.v2.yml b/changelog/@unreleased/pr-2578.v2.yml new file mode 100644 index 000000000..c62d72da1 --- /dev/null +++ b/changelog/@unreleased/pr-2578.v2.yml @@ -0,0 +1,5 @@ +type: fix +fix: + description: Don't ignore all directories named build/ + links: + - https://github.com/palantir/gradle-baseline/pull/2578 diff --git a/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineErrorProne.java b/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineErrorProne.java index 8f7ff541a..4084e00cd 100644 --- a/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineErrorProne.java +++ b/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineErrorProne.java @@ -186,7 +186,7 @@ static String excludedPathsRegex() { // Error-prone normalizes filenames to use '/' path separator: // https://github.com/google/error-prone/blob/c601758e81723a8efc4671726b8363be7a306dce // /check_api/src/main/java/com/google/errorprone/util/ASTHelpers.java#L1277-L1285 - return ".*/(build|generated_.*[sS]rc|src/generated.*)/.*"; + return ".*/(build/generated.*|src/generated.*|generated_[^/]*[sS]rc)/.*"; } private static Optional> getSpecificErrorProneChecks(Project project) { diff --git a/gradle-baseline-java/src/test/groovy/com/palantir/baseline/plugins/BaselineErrorProneTest.groovy b/gradle-baseline-java/src/test/groovy/com/palantir/baseline/plugins/BaselineErrorProneTest.groovy index 72e14e4e4..9486c0c1a 100644 --- a/gradle-baseline-java/src/test/groovy/com/palantir/baseline/plugins/BaselineErrorProneTest.groovy +++ b/gradle-baseline-java/src/test/groovy/com/palantir/baseline/plugins/BaselineErrorProneTest.groovy @@ -26,7 +26,10 @@ class BaselineErrorProneTest extends Specification { def predicate = Pattern.compile(excludedPaths).asPredicate() then: - predicate.test 'tritium-core/build/metricSchema/generated_src' + predicate.negate().test 'service/src/main/java/com/palantir/service/build/output/ServiceOutputManager.java' + predicate.negate().test 'service/src/main/java/com/palantir/service/build/output/generated/' + predicate.test 'tritium-core/build/generated/' + predicate.test 'tritium-core/build/metricSchema/generated_src/' predicate.test 'tritium-registry/generated_src/com/palantir/tritium/metrics/registry/ImmutableMetricName.java' predicate.test 'tritium-metrics/build/metricSchema/generated_src/com/palantir/tritium/metrics/TlsMetrics.java' predicate.test 'tritium-jmh/generated_testSrc/com/palantir/tritium/microbenchmarks/generated/ProxyBenchmark_jmhType.java' From f7daf092708a3eb430ec9851a90a14c2bb5c7747 Mon Sep 17 00:00:00 2001 From: svc-autorelease Date: Wed, 17 May 2023 19:19:48 +0000 Subject: [PATCH 058/129] Autorelease 5.9.0 [skip ci] --- changelog/{@unreleased => 5.9.0}/pr-2578.v2.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename changelog/{@unreleased => 5.9.0}/pr-2578.v2.yml (100%) diff --git a/changelog/@unreleased/pr-2578.v2.yml b/changelog/5.9.0/pr-2578.v2.yml similarity index 100% rename from changelog/@unreleased/pr-2578.v2.yml rename to changelog/5.9.0/pr-2578.v2.yml From 0f379f2370f69ddfb8da778aec0bdce785960045 Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Thu, 18 May 2023 02:20:33 +0100 Subject: [PATCH 059/129] Excavator: Upgrades Baseline to the latest version (#2581) --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index e2bededd2..1e5b1a67d 100644 --- a/build.gradle +++ b/build.gradle @@ -14,7 +14,7 @@ buildscript { classpath 'com.palantir.gradle.externalpublish:gradle-external-publish-plugin:1.12.0' classpath 'com.palantir.gradle.consistentversions:gradle-consistent-versions:2.12.0' classpath 'com.gradle.publish:plugin-publish-plugin:1.2.0' - classpath 'com.palantir.baseline:gradle-baseline-java:5.8.0' + classpath 'com.palantir.baseline:gradle-baseline-java:5.9.0' classpath 'com.palantir.javaformat:gradle-palantir-java-format:2.30.0' } } From d9bab71d909d5b497176bafac691b01b81522f84 Mon Sep 17 00:00:00 2001 From: Carter Kozak Date: Thu, 18 May 2023 10:18:39 -0400 Subject: [PATCH 060/129] Revert "Don't ignore all directories named build/ (#2578)" (#2582) Revert "Don't ignore all directories named build/ (#2578)" which failed to ignore some generated files within the build directory --- changelog/@unreleased/pr-2582.v2.yml | 6 ++++++ .../com/palantir/baseline/plugins/BaselineErrorProne.java | 2 +- .../palantir/baseline/plugins/BaselineErrorProneTest.groovy | 5 +---- 3 files changed, 8 insertions(+), 5 deletions(-) create mode 100644 changelog/@unreleased/pr-2582.v2.yml diff --git a/changelog/@unreleased/pr-2582.v2.yml b/changelog/@unreleased/pr-2582.v2.yml new file mode 100644 index 000000000..945388a98 --- /dev/null +++ b/changelog/@unreleased/pr-2582.v2.yml @@ -0,0 +1,6 @@ +type: fix +fix: + description: Revert "Don't ignore all directories named build/ (#2578)" which failed + to ignore some generated files within the build directory + links: + - https://github.com/palantir/gradle-baseline/pull/2582 diff --git a/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineErrorProne.java b/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineErrorProne.java index 4084e00cd..8f7ff541a 100644 --- a/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineErrorProne.java +++ b/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineErrorProne.java @@ -186,7 +186,7 @@ static String excludedPathsRegex() { // Error-prone normalizes filenames to use '/' path separator: // https://github.com/google/error-prone/blob/c601758e81723a8efc4671726b8363be7a306dce // /check_api/src/main/java/com/google/errorprone/util/ASTHelpers.java#L1277-L1285 - return ".*/(build/generated.*|src/generated.*|generated_[^/]*[sS]rc)/.*"; + return ".*/(build|generated_.*[sS]rc|src/generated.*)/.*"; } private static Optional> getSpecificErrorProneChecks(Project project) { diff --git a/gradle-baseline-java/src/test/groovy/com/palantir/baseline/plugins/BaselineErrorProneTest.groovy b/gradle-baseline-java/src/test/groovy/com/palantir/baseline/plugins/BaselineErrorProneTest.groovy index 9486c0c1a..72e14e4e4 100644 --- a/gradle-baseline-java/src/test/groovy/com/palantir/baseline/plugins/BaselineErrorProneTest.groovy +++ b/gradle-baseline-java/src/test/groovy/com/palantir/baseline/plugins/BaselineErrorProneTest.groovy @@ -26,10 +26,7 @@ class BaselineErrorProneTest extends Specification { def predicate = Pattern.compile(excludedPaths).asPredicate() then: - predicate.negate().test 'service/src/main/java/com/palantir/service/build/output/ServiceOutputManager.java' - predicate.negate().test 'service/src/main/java/com/palantir/service/build/output/generated/' - predicate.test 'tritium-core/build/generated/' - predicate.test 'tritium-core/build/metricSchema/generated_src/' + predicate.test 'tritium-core/build/metricSchema/generated_src' predicate.test 'tritium-registry/generated_src/com/palantir/tritium/metrics/registry/ImmutableMetricName.java' predicate.test 'tritium-metrics/build/metricSchema/generated_src/com/palantir/tritium/metrics/TlsMetrics.java' predicate.test 'tritium-jmh/generated_testSrc/com/palantir/tritium/microbenchmarks/generated/ProxyBenchmark_jmhType.java' From 34d3e3b3474d8ec674d3e17834dc61412ec7ce67 Mon Sep 17 00:00:00 2001 From: svc-autorelease Date: Thu, 18 May 2023 14:18:47 +0000 Subject: [PATCH 061/129] Autorelease 5.10.0 [skip ci] --- changelog/{@unreleased => 5.10.0}/pr-2582.v2.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename changelog/{@unreleased => 5.10.0}/pr-2582.v2.yml (100%) diff --git a/changelog/@unreleased/pr-2582.v2.yml b/changelog/5.10.0/pr-2582.v2.yml similarity index 100% rename from changelog/@unreleased/pr-2582.v2.yml rename to changelog/5.10.0/pr-2582.v2.yml From 18f8c5a27f78410ed9e83abf70d2ed58f954e33b Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Thu, 18 May 2023 16:49:42 +0100 Subject: [PATCH 062/129] Excavator: Upgrades Baseline to the latest version (#2583) --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 1e5b1a67d..0028460a7 100644 --- a/build.gradle +++ b/build.gradle @@ -14,7 +14,7 @@ buildscript { classpath 'com.palantir.gradle.externalpublish:gradle-external-publish-plugin:1.12.0' classpath 'com.palantir.gradle.consistentversions:gradle-consistent-versions:2.12.0' classpath 'com.gradle.publish:plugin-publish-plugin:1.2.0' - classpath 'com.palantir.baseline:gradle-baseline-java:5.9.0' + classpath 'com.palantir.baseline:gradle-baseline-java:5.10.0' classpath 'com.palantir.javaformat:gradle-palantir-java-format:2.30.0' } } From b8a4f4903fe146a702633e9009ed0c5957eebc54 Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Mon, 22 May 2023 19:11:12 +0100 Subject: [PATCH 063/129] Excavator: Format Java files (#2584) --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 0028460a7..2fc2bfee9 100644 --- a/build.gradle +++ b/build.gradle @@ -15,7 +15,7 @@ buildscript { classpath 'com.palantir.gradle.consistentversions:gradle-consistent-versions:2.12.0' classpath 'com.gradle.publish:plugin-publish-plugin:1.2.0' classpath 'com.palantir.baseline:gradle-baseline-java:5.10.0' - classpath 'com.palantir.javaformat:gradle-palantir-java-format:2.30.0' + classpath 'com.palantir.javaformat:gradle-palantir-java-format:2.31.0' } } From b619dab75f6d138be63036e48c96aa579335ffc6 Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Tue, 23 May 2023 01:27:27 +0100 Subject: [PATCH 064/129] Excavator: Format Java files (#2585) --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 2fc2bfee9..66d99fa1f 100644 --- a/build.gradle +++ b/build.gradle @@ -15,7 +15,7 @@ buildscript { classpath 'com.palantir.gradle.consistentversions:gradle-consistent-versions:2.12.0' classpath 'com.gradle.publish:plugin-publish-plugin:1.2.0' classpath 'com.palantir.baseline:gradle-baseline-java:5.10.0' - classpath 'com.palantir.javaformat:gradle-palantir-java-format:2.31.0' + classpath 'com.palantir.javaformat:gradle-palantir-java-format:2.32.0' } } From 905734b1ea6b3e704413355ca079e613f9f065d5 Mon Sep 17 00:00:00 2001 From: Pritham Marupaka Date: Thu, 1 Jun 2023 14:48:41 -0400 Subject: [PATCH 065/129] Add check replacing `stream.sorted().findFirst()` with `stream.min()` (#2555) Add check replacing `stream.sorted().findFirst()` with `stream.min()` --- .../errorprone/SortedStreamFirstElement.java | 115 +++++++++++++++ .../SortedStreamFirstElementTest.java | 133 ++++++++++++++++++ changelog/@unreleased/pr-2555.v2.yml | 5 + 3 files changed, 253 insertions(+) create mode 100644 baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/SortedStreamFirstElement.java create mode 100644 baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/SortedStreamFirstElementTest.java create mode 100644 changelog/@unreleased/pr-2555.v2.yml diff --git a/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/SortedStreamFirstElement.java b/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/SortedStreamFirstElement.java new file mode 100644 index 000000000..059b6cac7 --- /dev/null +++ b/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/SortedStreamFirstElement.java @@ -0,0 +1,115 @@ +/* + * (c) Copyright 2023 Palantir Technologies Inc. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.palantir.baseline.errorprone; + +import com.google.auto.service.AutoService; +import com.google.errorprone.BugPattern; +import com.google.errorprone.BugPattern.SeverityLevel; +import com.google.errorprone.VisitorState; +import com.google.errorprone.bugpatterns.BugChecker; +import com.google.errorprone.fixes.SuggestedFix; +import com.google.errorprone.matchers.Description; +import com.google.errorprone.matchers.Matcher; +import com.google.errorprone.matchers.Matchers; +import com.google.errorprone.matchers.method.MethodMatchers; +import com.google.errorprone.util.ASTHelpers; +import com.sun.source.tree.ExpressionTree; +import com.sun.source.tree.MethodInvocationTree; +import com.sun.source.tree.Tree; +import com.sun.tools.javac.tree.JCTree.JCMethodInvocation; +import java.util.Comparator; +import java.util.stream.Stream; + +@AutoService(BugChecker.class) +@BugPattern( + link = "https://github.com/palantir/gradle-baseline#baseline-error-prone-checks", + linkType = BugPattern.LinkType.CUSTOM, + severity = SeverityLevel.SUGGESTION, + summary = "Using Stream::min is more efficient than finding the first element of the sorted stream. " + + "Stream::min performs a linear scan through the stream to find the smallest element.") +public final class SortedStreamFirstElement extends BugChecker implements BugChecker.MethodInvocationTreeMatcher { + + private static final Matcher STREAM_FIND_FIRST_MATCHER = MethodMatchers.instanceMethod() + .onDescendantOf(Stream.class.getName()) + .named("findFirst") + .withNoParameters(); + + private static final Matcher RECEIVER_OF_STREAM_SORTED_NO_PARAMS_MATCHER = + Matchers.receiverOfInvocation(MethodMatchers.instanceMethod() + .onDescendantOf(Stream.class.getName()) + .named("sorted") + .withNoParameters()); + + private static final Matcher RECEIVER_OF_STREAM_SORTED_WITH_COMPARATOR_MATCHER = + Matchers.receiverOfInvocation(MethodMatchers.instanceMethod() + .onDescendantOf(Stream.class.getName()) + .named("sorted") + .withParameters(Comparator.class.getName())); + + private static final Matcher MATCHER = Matchers.allOf( + STREAM_FIND_FIRST_MATCHER, + Matchers.anyOf( + RECEIVER_OF_STREAM_SORTED_NO_PARAMS_MATCHER, RECEIVER_OF_STREAM_SORTED_WITH_COMPARATOR_MATCHER)); + + @Override + public Description matchMethodInvocation(MethodInvocationTree tree, VisitorState state) { + if (!MATCHER.matches(tree, state)) { + return Description.NO_MATCH; + } + + ExpressionTree sorted = ASTHelpers.getReceiver(tree); + if (sorted == null) { + // Not expected. + return Description.NO_MATCH; + } + MethodInvocationTree sortedTree = (MethodInvocationTree) sorted; + ExpressionTree stream = ASTHelpers.getReceiver(sorted); + if (stream == null) { + // Not expected. + return Description.NO_MATCH; + } + + if (RECEIVER_OF_STREAM_SORTED_NO_PARAMS_MATCHER.matches(tree, state)) { + return describeMatch( + tree, + SuggestedFix.builder() + .replace( + getStartPosition(tree), + state.getEndPosition(tree), + state.getSourceForNode(stream) + ".min(Comparator.naturalOrder())") + .addImport(Comparator.class.getCanonicalName()) + .build()); + } else if (RECEIVER_OF_STREAM_SORTED_WITH_COMPARATOR_MATCHER.matches(tree, state)) { + return describeMatch( + tree, + SuggestedFix.builder() + .replace( + getStartPosition(tree), + state.getEndPosition(tree), + state.getSourceForNode(stream) + ".min(" + + state.getSourceForNode( + sortedTree.getArguments().get(0)) + ")") + .build()); + } + + return Description.NO_MATCH; + } + + private static int getStartPosition(Tree tree) { + return ((JCMethodInvocation) tree).getStartPosition(); + } +} diff --git a/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/SortedStreamFirstElementTest.java b/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/SortedStreamFirstElementTest.java new file mode 100644 index 000000000..1c0755363 --- /dev/null +++ b/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/SortedStreamFirstElementTest.java @@ -0,0 +1,133 @@ +/* + * (c) Copyright 2023 Palantir Technologies Inc. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.palantir.baseline.errorprone; + +import java.util.Comparator; +import java.util.Optional; +import java.util.stream.Stream; +import org.junit.jupiter.api.Test; + +public class SortedStreamFirstElementTest { + + @Test + public void test_basic() { + fix().addInputLines( + "TestBasic.java", + "import " + Optional.class.getCanonicalName() + ";", + "import " + Stream.class.getCanonicalName() + ";", + "class TestBasic {", + " public Optional basic(Stream s) {", + " return s.sorted().findFirst();", + " }", + "}") + .addOutputLines( + "TestBasic.java", + "import " + Comparator.class.getCanonicalName() + ";", + "import " + Optional.class.getCanonicalName() + ";", + "import " + Stream.class.getCanonicalName() + ";", + "class TestBasic {", + " public Optional basic(Stream s) {", + " return s.min(Comparator.naturalOrder());", + " }", + "}") + .doTest(); + } + + @Test + public void test_comparator_already_imported() { + fix().addInputLines( + "TestComparatorAlreadyImported.java", + "import " + Comparator.class.getCanonicalName() + ";", + "import " + Optional.class.getCanonicalName() + ";", + "import " + Stream.class.getCanonicalName() + ";", + "class TestComparatorAlreadyImported {", + " public Optional f(Stream s) {", + " return s.sorted().findFirst();", + " }", + " public Optional g(Stream s) {", + " return s.min(Comparator.naturalOrder());", + " }", + "}") + .addOutputLines( + "TestComparatorAlreadyImported.java", + "import " + Comparator.class.getCanonicalName() + ";", + "import " + Optional.class.getCanonicalName() + ";", + "import " + Stream.class.getCanonicalName() + ";", + "class TestComparatorAlreadyImported {", + " public Optional f(Stream s) {", + " return s.min(Comparator.naturalOrder());", + " }", + " public Optional g(Stream s) {", + " return s.min(Comparator.naturalOrder());", + " }", + "}") + .doTest(); + } + + @Test + public void test_templated() { + fix().addInputLines( + "TestBasic.java", + "import " + Optional.class.getCanonicalName() + ";", + "import " + Stream.class.getCanonicalName() + ";", + "class TestBasic> {", + " public Optional basic(Stream s) {", + " return s.sorted().findFirst();", + " }", + "}") + .addOutputLines( + "TestBasic.java", + "import " + Comparator.class.getCanonicalName() + ";", + "import " + Optional.class.getCanonicalName() + ";", + "import " + Stream.class.getCanonicalName() + ";", + "class TestBasic> {", + " public Optional basic(Stream s) {", + " return s.min(Comparator.naturalOrder());", + " }", + "}") + .doTest(); + } + + @Test + public void test_comparator() { + fix().addInputLines( + "TestComparator.java", + "import " + Comparator.class.getCanonicalName() + ";", + "import " + Optional.class.getCanonicalName() + ";", + "import " + Stream.class.getCanonicalName() + ";", + "class TestComparator {", + " public Optional f(Stream s, Comparator c) {", + " return s.sorted(c).findFirst();", + " }", + "}") + .addOutputLines( + "TestComparator.java", + "import " + Comparator.class.getCanonicalName() + ";", + "import " + Optional.class.getCanonicalName() + ";", + "import " + Stream.class.getCanonicalName() + ";", + "class TestComparator {", + " public Optional f(Stream s, Comparator c) {", + " return s.min(c);", + " }", + "}") + .doTest(); + } + + private RefactoringValidator fix() { + return RefactoringValidator.of(SortedStreamFirstElement.class, getClass()); + } +} diff --git a/changelog/@unreleased/pr-2555.v2.yml b/changelog/@unreleased/pr-2555.v2.yml new file mode 100644 index 000000000..73e99a44b --- /dev/null +++ b/changelog/@unreleased/pr-2555.v2.yml @@ -0,0 +1,5 @@ +type: feature +feature: + description: Add check replacing `stream.sorted().findFirst()` with `stream.min()` + links: + - https://github.com/palantir/gradle-baseline/pull/2555 From 7822daaad83da53367739974591c6ff70fb67731 Mon Sep 17 00:00:00 2001 From: svc-autorelease Date: Thu, 1 Jun 2023 18:48:49 +0000 Subject: [PATCH 066/129] Autorelease 5.11.0 [skip ci] --- changelog/{@unreleased => 5.11.0}/pr-2555.v2.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename changelog/{@unreleased => 5.11.0}/pr-2555.v2.yml (100%) diff --git a/changelog/@unreleased/pr-2555.v2.yml b/changelog/5.11.0/pr-2555.v2.yml similarity index 100% rename from changelog/@unreleased/pr-2555.v2.yml rename to changelog/5.11.0/pr-2555.v2.yml From 96ccf265a7afffd2ec35349dbe6a808518fdbce2 Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Thu, 1 Jun 2023 21:35:07 +0100 Subject: [PATCH 067/129] Excavator: Upgrades Baseline to the latest version (#2587) --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 66d99fa1f..6f3a382d6 100644 --- a/build.gradle +++ b/build.gradle @@ -14,7 +14,7 @@ buildscript { classpath 'com.palantir.gradle.externalpublish:gradle-external-publish-plugin:1.12.0' classpath 'com.palantir.gradle.consistentversions:gradle-consistent-versions:2.12.0' classpath 'com.gradle.publish:plugin-publish-plugin:1.2.0' - classpath 'com.palantir.baseline:gradle-baseline-java:5.10.0' + classpath 'com.palantir.baseline:gradle-baseline-java:5.11.0' classpath 'com.palantir.javaformat:gradle-palantir-java-format:2.32.0' } } From cea3491eda238764f554bd0cd054b8aabc0856e6 Mon Sep 17 00:00:00 2001 From: Andrew Ash Date: Mon, 5 Jun 2023 06:41:54 -0700 Subject: [PATCH 068/129] Add instructions for turning error-prone's warnings into errors (#2575) Add instructions for turning error-prone's warnings into errors --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index c6b550611..7a43f7cfc 100644 --- a/README.md +++ b/README.md @@ -134,6 +134,16 @@ tasks.withType(JavaCompile).configureEach(new Action() { }) ``` +To turn all of error-prone's warnings into errors: + +```gradle +allprojects { + tasks.withType(JavaCompile) { + options.compilerArgs += ['-Werror'] + } +} +``` + More information on error-prone severity handling can be found at [errorprone.info/docs/flags](http://errorprone.info/docs/flags). #### Baseline error-prone checks From 8355aa7df8736985cd70007ddb9dcadbef7233ed Mon Sep 17 00:00:00 2001 From: Alex Landau Date: Mon, 5 Jun 2023 07:46:11 -0700 Subject: [PATCH 069/129] Upgrade errorprone to 2.19.1 (#2576) Upgrade Error Prone to 2.19.1 (from 2.18.0) --- ...imeConstantViolatesLiskovSubstitution.java | 6 +- .../errorprone/StrictUnusedVariable.java | 22 +------- changelog/@unreleased/pr-2576.v2.yml | 5 ++ .../baseline/plugins/BaselineErrorProne.java | 37 ++++++++++--- .../gradle/junit/BuildFailureListener.java | 1 + .../gradle/junit/CheckstyleReportHandler.java | 3 +- versions.lock | 55 ++++++++++--------- versions.props | 4 +- 8 files changed, 70 insertions(+), 63 deletions(-) create mode 100644 changelog/@unreleased/pr-2576.v2.yml diff --git a/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/CompileTimeConstantViolatesLiskovSubstitution.java b/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/CompileTimeConstantViolatesLiskovSubstitution.java index b3e89258e..ba586be1b 100644 --- a/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/CompileTimeConstantViolatesLiskovSubstitution.java +++ b/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/CompileTimeConstantViolatesLiskovSubstitution.java @@ -66,7 +66,7 @@ public Description matchMethod(MethodTree tree, VisitorState state) { for (VarSymbol parameter : methodSymbol.getParameters()) { ++parameterIndex; - if (ASTHelpers.hasAnnotation(parameter, CompileTimeConstant.class, state)) { + if (ASTHelpers.hasAnnotation(parameter, CompileTimeConstant.class.getName(), state)) { if (anySuperMethodsMissingParameterAnnotation(superMethods, parameterIndex, state)) { state.reportMatch(buildDescription(tree.getParameters().get(parameterIndex)) .setMessage("@CompileTimeConstant annotations on method parameters " @@ -98,7 +98,7 @@ private boolean anySuperMethodsMissingParameterAnnotation( Set superMethods, int parameterIndex, VisitorState state) { for (MethodSymbol superMethod : superMethods) { VarSymbol parameter = superMethod.getParameters().get(parameterIndex); - if (!ASTHelpers.hasAnnotation(parameter, CompileTimeConstant.class, state)) { + if (!ASTHelpers.hasAnnotation(parameter, CompileTimeConstant.class.getName(), state)) { return true; } } @@ -109,7 +109,7 @@ private boolean anySuperMethodsHaveParameterAnnotation( Set superMethods, int parameterIndex, VisitorState state) { for (MethodSymbol superMethod : superMethods) { VarSymbol parameter = superMethod.getParameters().get(parameterIndex); - if (ASTHelpers.hasAnnotation(parameter, CompileTimeConstant.class, state)) { + if (ASTHelpers.hasAnnotation(parameter, CompileTimeConstant.class.getName(), state)) { return true; } } diff --git a/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/StrictUnusedVariable.java b/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/StrictUnusedVariable.java index 875bfd46a..47e094108 100644 --- a/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/StrictUnusedVariable.java +++ b/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/StrictUnusedVariable.java @@ -67,10 +67,7 @@ import com.google.errorprone.bugpatterns.UnusedVariable; import com.google.errorprone.fixes.SuggestedFix; import com.google.errorprone.fixes.SuggestedFixes; -import com.google.errorprone.matchers.ChildMultiMatcher.MatchType; import com.google.errorprone.matchers.Description; -import com.google.errorprone.matchers.Matcher; -import com.google.errorprone.matchers.Matchers; import com.google.errorprone.suppliers.Suppliers; import com.google.errorprone.util.ASTHelpers; import com.sun.source.tree.AnnotationTree; @@ -95,7 +92,6 @@ import com.sun.source.tree.ReturnTree; import com.sun.source.tree.StatementTree; import com.sun.source.tree.Tree; -import com.sun.source.tree.Tree.Kind; import com.sun.source.tree.TryTree; import com.sun.source.tree.UnaryTree; import com.sun.source.tree.VariableTree; @@ -128,7 +124,7 @@ */ @AutoService(BugChecker.class) @BugPattern( - altNames = "unused", + altNames = {"unused", "UnusedVariable"}, link = "https://github.com/palantir/gradle-baseline#baseline-error-prone-checks", linkType = BugPattern.LinkType.CUSTOM, summary = "Unused.", @@ -164,17 +160,6 @@ public final class StrictUnusedVariable extends BugChecker implements BugChecker "TAG"); private static final String UNUSED = "unused"; - private static final Matcher ALTERNATIVE_SUPPRESSED = Matchers.allOf( - // Matchers.annotations will throw given a tree that doesn't support annotations, so we must enumerate - // supported types. - Matchers.kindAnyOf(Set.of( - Kind.CLASS, Kind.VARIABLE, Kind.METHOD, Kind.ANNOTATED_TYPE, Kind.PACKAGE, Kind.COMPILATION_UNIT)), - Matchers.annotations( - MatchType.AT_LEAST_ONE, - Matchers.allOf( - Matchers.isType("java.lang.SuppressWarnings"), - Matchers.hasArgumentWithValue("value", Matchers.stringLiteral("UnusedVariable"))))); - @Override public Description matchCompilationUnit(CompilationUnitTree tree, VisitorState state) { // We will skip reporting on the whole compilation if there are any native methods found. @@ -292,11 +277,6 @@ private void checkUsedVariables(VisitorState state, VariableFinder variableFinde }); } - @Override - public boolean isSuppressed(Tree tree, VisitorState state) { - return super.isSuppressed(tree, state) || ALTERNATIVE_SUPPRESSED.matches(tree, state); - } - private static SuggestedFix constructUsedVariableSuggestedFix(List usagePaths, VisitorState state) { SuggestedFix.Builder fix = SuggestedFix.builder(); for (TreePath usagePath : usagePaths) { diff --git a/changelog/@unreleased/pr-2576.v2.yml b/changelog/@unreleased/pr-2576.v2.yml new file mode 100644 index 000000000..cb0602fa9 --- /dev/null +++ b/changelog/@unreleased/pr-2576.v2.yml @@ -0,0 +1,5 @@ +type: improvement +improvement: + description: Upgrade Error Prone to 2.19.1 (from 2.18.0) + links: + - https://github.com/palantir/gradle-baseline/pull/2576 diff --git a/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineErrorProne.java b/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineErrorProne.java index 8f7ff541a..ec383590f 100644 --- a/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineErrorProne.java +++ b/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineErrorProne.java @@ -23,6 +23,7 @@ import com.google.common.collect.Iterables; import com.google.common.collect.MoreCollectors; import com.palantir.baseline.extensions.BaselineErrorProneExtension; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -132,6 +133,10 @@ private static void configureErrorProneOptions( "CanIgnoreReturnValueSuggester", "InlineMeSuggester", "PreferImmutableStreamExCollections", + // StringCaseLocaleUsage duplicates our existing DefaultLocale check which is already + // enforced in some places. + "StringCaseLocaleUsage", + "UnnecessaryTestMethodPrefix", "UnusedVariable", // See VarUsage: The var keyword results in illegible code in most cases and should not be used. "Varifier", @@ -170,13 +175,27 @@ private static void configureErrorProneOptions( // intentionally not using a lambda to reduce gradle warnings @Override public Iterable asArguments() { - // Don't apply checks that have been explicitly disabled - Stream errorProneChecks = getSpecificErrorProneChecks(project) - .orElseGet(() -> getNotDisabledErrorproneChecks( - project, errorProneExtension, javaCompile, maybeSourceSet, errorProneOptions)); - return ImmutableList.of( - "-XepPatchChecks:" + Joiner.on(',').join(errorProneChecks.iterator()), - "-XepPatchLocation:IN_PLACE"); + Optional> specificChecks = getSpecificErrorProneChecks(project); + if (specificChecks.isPresent()) { + List errorProneChecks = specificChecks.get(); + // Work around https://github.com/google/error-prone/issues/3908 by explicitly enabling any + // check we want to use patch checks for (ensuring it is not disabled); if this is fixed, the + // -Xep:*:ERROR arguments could be removed + return Iterables.concat( + errorProneChecks.stream() + .map(checkName -> "-Xep:" + checkName + ":ERROR") + .collect(Collectors.toList()), + ImmutableList.of( + "-XepPatchChecks:" + Joiner.on(',').join(errorProneChecks), + "-XepPatchLocation:IN_PLACE")); + } else { + // Don't apply checks that have been explicitly disabled + Stream errorProneChecks = getNotDisabledErrorproneChecks( + project, errorProneExtension, javaCompile, maybeSourceSet, errorProneOptions); + return ImmutableList.of( + "-XepPatchChecks:" + Joiner.on(',').join(errorProneChecks.iterator()), + "-XepPatchLocation:IN_PLACE"); + } } }); } @@ -189,12 +208,12 @@ static String excludedPathsRegex() { return ".*/(build|generated_.*[sS]rc|src/generated.*)/.*"; } - private static Optional> getSpecificErrorProneChecks(Project project) { + private static Optional> getSpecificErrorProneChecks(Project project) { return Optional.ofNullable(project.findProperty(PROP_ERROR_PRONE_APPLY)) .map(Objects::toString) .flatMap(value -> Optional.ofNullable(Strings.emptyToNull(value))) .map(value -> Splitter.on(',').trimResults().omitEmptyStrings().splitToList(value)) - .flatMap(list -> list.isEmpty() ? Optional.empty() : Optional.of(list.stream())); + .flatMap(list -> list.isEmpty() ? Optional.empty() : Optional.of(list)); } private static Stream getNotDisabledErrorproneChecks( diff --git a/gradle-junit-reports/src/main/java/com/palantir/gradle/junit/BuildFailureListener.java b/gradle-junit-reports/src/main/java/com/palantir/gradle/junit/BuildFailureListener.java index 166370a46..83c69d2ec 100644 --- a/gradle-junit-reports/src/main/java/com/palantir/gradle/junit/BuildFailureListener.java +++ b/gradle-junit-reports/src/main/java/com/palantir/gradle/junit/BuildFailureListener.java @@ -65,6 +65,7 @@ public List getTestCases() { return testCases; } + @SuppressWarnings("SafeLoggingPropagation") private static String getMessage(Throwable throwable) { if (throwable.getMessage() == null) { return throwable.getClass().getSimpleName(); diff --git a/gradle-junit-reports/src/main/java/com/palantir/gradle/junit/CheckstyleReportHandler.java b/gradle-junit-reports/src/main/java/com/palantir/gradle/junit/CheckstyleReportHandler.java index 7978aa7c9..00ff473a6 100644 --- a/gradle-junit-reports/src/main/java/com/palantir/gradle/junit/CheckstyleReportHandler.java +++ b/gradle-junit-reports/src/main/java/com/palantir/gradle/junit/CheckstyleReportHandler.java @@ -18,6 +18,7 @@ import java.io.File; import java.util.ArrayList; import java.util.List; +import java.util.Locale; import org.gradle.api.plugins.quality.Checkstyle; import org.xml.sax.Attributes; @@ -43,7 +44,7 @@ public void startElement(String uri, String localName, String qName, Attributes case "error": failures.add(Failure.builder() .source(attributes.getValue("source")) - .severity(attributes.getValue("severity").toUpperCase()) + .severity(attributes.getValue("severity").toUpperCase(Locale.ROOT)) .file(file) .line(Integer.parseInt(attributes.getValue("line"))) .message(attributes.getValue("message")) diff --git a/versions.lock b/versions.lock index 4b197a88a..98500b011 100644 --- a/versions.lock +++ b/versions.lock @@ -13,15 +13,15 @@ com.google.auto.service:auto-service:1.0.1 (1 constraints: 0405f135) com.google.auto.service:auto-service-annotations:1.0.1 (2 constraints: 8920021c) com.google.auto.value:auto-value-annotations:1.9 (3 constraints: 802d5ac8) com.google.code.findbugs:jsr305:3.0.2 (6 constraints: 66626968) -com.google.errorprone:error_prone_annotation:2.18.0 (3 constraints: cd3893ef) -com.google.errorprone:error_prone_annotations:2.18.0 (12 constraints: 92bdac9f) -com.google.errorprone:error_prone_check_api:2.18.0 (2 constraints: b825d0ff) -com.google.errorprone:error_prone_core:2.18.0 (1 constraints: 3d05473b) -com.google.errorprone:error_prone_type_annotations:2.18.0 (1 constraints: 28115ac9) -com.google.guava:failureaccess:1.0.1 (1 constraints: 140ae1b4) -com.google.guava:guava:31.1-jre (14 constraints: d6e9749b) +com.google.errorprone:error_prone_annotation:2.19.1 (3 constraints: d338dff0) +com.google.errorprone:error_prone_annotations:2.19.1 (12 constraints: 98bdf6a8) +com.google.errorprone:error_prone_check_api:2.19.1 (2 constraints: bc255700) +com.google.errorprone:error_prone_core:2.19.1 (1 constraints: 3f054b3b) +com.google.errorprone:error_prone_type_annotations:2.19.1 (1 constraints: 2a115ec9) +com.google.guava:failureaccess:1.0.1 (2 constraints: f1150513) +com.google.guava:guava:31.1-jre (15 constraints: 95f432a0) com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava (1 constraints: bd17c918) -com.google.inject:guice:4.2.2 (1 constraints: e40b61f3) +com.google.inject:guice:5.1.0 (2 constraints: c21eb8b6) com.google.j2objc:j2objc-annotations:1.3 (1 constraints: b809eda0) com.google.protobuf:protobuf-java:3.19.2 (1 constraints: 2c1165c9) com.googlecode.concurrent-trees:concurrent-trees:2.6.1 (1 constraints: 761166da) @@ -31,27 +31,28 @@ com.palantir.gradle.utils:lazily-configured-mapping:0.1.0 (1 constraints: 0305ee com.palantir.javaformat:gradle-palantir-java-format:1.1.0 (1 constraints: 0405f335) com.palantir.javaformat:palantir-java-format-spi:1.1.0 (1 constraints: 711560be) com.uber.nullaway:nullaway:0.10.10 (1 constraints: 64058840) -commons-io:commons-io:2.11.0 (2 constraints: 1426005d) +commons-io:commons-io:2.11.0 (1 constraints: be14ed98) commons-lang:commons-lang:2.6 (1 constraints: ac04232c) io.github.java-diff-utils:java-diff-utils:4.0 (1 constraints: 811205f6) javax.annotation:javax.annotation-api:1.3.2 (2 constraints: cd204f35) javax.inject:javax.inject:1 (9 constraints: e5867a2e) net.ltgt.gradle:gradle-errorprone-plugin:3.1.0 (1 constraints: 0605fd35) -org.apache.commons:commons-lang3:3.12.0 (4 constraints: da318b7f) -org.apache.maven:maven-artifact:3.8.5 (4 constraints: 1e3ed043) -org.apache.maven:maven-builder-support:3.8.5 (3 constraints: 1a2c0e66) -org.apache.maven:maven-core:3.8.5 (2 constraints: a51938e0) -org.apache.maven:maven-model:3.8.5 (4 constraints: d73a0919) -org.apache.maven:maven-model-builder:3.8.5 (2 constraints: 381d020b) -org.apache.maven:maven-plugin-api:3.8.5 (1 constraints: ec0b71f3) -org.apache.maven:maven-repository-metadata:3.8.5 (2 constraints: 381d020b) -org.apache.maven:maven-resolver-provider:3.8.5 (1 constraints: ec0b71f3) -org.apache.maven:maven-settings:3.8.5 (2 constraints: b31c1fea) -org.apache.maven:maven-settings-builder:3.8.5 (1 constraints: ec0b71f3) -org.apache.maven.resolver:maven-resolver-api:1.6.3 (5 constraints: 595676e7) -org.apache.maven.resolver:maven-resolver-impl:1.6.3 (2 constraints: 2c1db809) -org.apache.maven.resolver:maven-resolver-spi:1.6.3 (3 constraints: 5930fd65) -org.apache.maven.resolver:maven-resolver-util:1.6.3 (3 constraints: 5930fd65) +org.apache.commons:commons-lang3:3.12.0 (4 constraints: 04327fb1) +org.apache.maven:maven-artifact:3.9.1 (4 constraints: 153e4040) +org.apache.maven:maven-builder-support:3.9.1 (3 constraints: 112c6464) +org.apache.maven:maven-core:3.9.1 (2 constraints: a21989df) +org.apache.maven:maven-model:3.9.1 (4 constraints: cb3ac915) +org.apache.maven:maven-model-builder:3.9.1 (2 constraints: 321d6d0a) +org.apache.maven:maven-plugin-api:3.9.1 (1 constraints: e90b70f3) +org.apache.maven:maven-repository-metadata:3.9.1 (2 constraints: 321d6d0a) +org.apache.maven:maven-resolver-provider:3.9.1 (1 constraints: e90b70f3) +org.apache.maven:maven-settings:3.9.1 (2 constraints: ad1c8de9) +org.apache.maven:maven-settings-builder:3.9.1 (1 constraints: e90b70f3) +org.apache.maven.resolver:maven-resolver-api:1.9.7 (5 constraints: 7c5643f6) +org.apache.maven.resolver:maven-resolver-impl:1.9.7 (2 constraints: 3a1d290b) +org.apache.maven.resolver:maven-resolver-named-locks:1.9.7 (1 constraints: 3513e634) +org.apache.maven.resolver:maven-resolver-spi:1.9.7 (3 constraints: 6e306f6a) +org.apache.maven.resolver:maven-resolver-util:1.9.7 (3 constraints: 6e306f6a) org.apache.maven.shared:maven-dependency-analyzer:1.13.1 (1 constraints: 3805333b) org.apache.maven.shared:maven-shared-utils:3.3.4 (1 constraints: e60b61f3) org.checkerframework:checker-qual:3.33.0 (3 constraints: 08256088) @@ -64,7 +65,7 @@ org.codehaus.plexus:plexus-classworlds:2.6.0 (3 constraints: 572b5104) org.codehaus.plexus:plexus-component-annotations:2.1.0 (2 constraints: 241d860a) org.codehaus.plexus:plexus-interpolation:1.26 (3 constraints: 7b2bf0f5) org.codehaus.plexus:plexus-sec-dispatcher:2.0 (1 constraints: 5c100b99) -org.codehaus.plexus:plexus-utils:3.4.1 (11 constraints: 24a8c048) +org.codehaus.plexus:plexus-utils:3.5.1 (11 constraints: 3fa89966) org.eclipse.jgit:org.eclipse.jgit:5.13.0.202109080827-r (3 constraints: a43f6e15) org.eclipse.sisu:org.eclipse.sisu.inject:0.3.5 (3 constraints: 852caa93) org.eclipse.sisu:org.eclipse.sisu.plexus:0.3.5 (2 constraints: 141abc34) @@ -72,7 +73,7 @@ org.immutables:value:2.9.3 (1 constraints: 10051336) org.inferred:freebuilder:1.14.6 (1 constraints: 3e053b3b) org.ow2.asm:asm:9.5 (3 constraints: ee22e1eb) org.pcollections:pcollections:3.1.4 (1 constraints: f51029b8) -org.slf4j:slf4j-api:1.7.36 (9 constraints: 6c869d94) +org.slf4j:slf4j-api:1.7.36 (10 constraints: 769c0f4c) [Test dependencies] cglib:cglib-nodep:3.2.2 (1 constraints: 490ded24) @@ -82,7 +83,7 @@ com.fasterxml.jackson.core:jackson-databind:2.14.2 (5 constraints: ad4a0060) com.fasterxml.jackson.module:jackson-module-afterburner:2.14.2 (1 constraints: 3b053d3b) com.github.stefanbirkner:system-rules:1.19.0 (1 constraints: 3d05443b) com.google.auto.value:auto-value:1.7.4 (1 constraints: 1f1221fb) -com.google.errorprone:error_prone_test_helpers:2.18.0 (1 constraints: 3d05473b) +com.google.errorprone:error_prone_test_helpers:2.19.1 (1 constraints: 3f054b3b) com.google.googlejavaformat:google-java-format:1.13.0 (1 constraints: 8b149d75) com.google.jimfs:jimfs:1.2 (1 constraints: fb138b38) com.google.testing.compile:compile-testing:0.19 (1 constraints: 3214b94c) diff --git a/versions.props b/versions.props index 743471c72..22be4b83e 100644 --- a/versions.props +++ b/versions.props @@ -4,13 +4,13 @@ com.google.guava:guava = 31.1-jre com.palantir.safe-logging:* = 3.4.0 commons-lang:commons-lang = 2.6 org.apache.maven.shared:maven-dependency-analyzer = 1.13.1 -org.apache.maven:maven-core = 3.8.5 +org.apache.maven:maven-core = 3.9.1 org.inferred:freebuilder = 1.14.6 org.jooq:jooq = 3.18.3 org.slf4j:* = 1.7.36 org.immutables:* = 2.9.3 org.ow2.asm:asm = 9.5 -com.google.errorprone:error_prone_* = 2.18.0 +com.google.errorprone:error_prone_* = 2.19.1 com.googlecode.java-diff-utils:diffutils = 1.3.0 com.puppycrawl.tools:checkstyle = 10.10.0 com.palantir.gradle.utils:* = 0.1.0 From c141f28e81adcea5f46ba298dc47e8d64b32fc66 Mon Sep 17 00:00:00 2001 From: svc-autorelease Date: Mon, 5 Jun 2023 14:46:19 +0000 Subject: [PATCH 070/129] Autorelease 5.12.0 [skip ci] --- changelog/{@unreleased => 5.12.0}/pr-2576.v2.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename changelog/{@unreleased => 5.12.0}/pr-2576.v2.yml (100%) diff --git a/changelog/@unreleased/pr-2576.v2.yml b/changelog/5.12.0/pr-2576.v2.yml similarity index 100% rename from changelog/@unreleased/pr-2576.v2.yml rename to changelog/5.12.0/pr-2576.v2.yml From 1d55ad70628ad05aad996f5243167d028e1969bd Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Mon, 5 Jun 2023 18:49:45 +0100 Subject: [PATCH 071/129] Excavator: Upgrades Baseline to the latest version (#2588) --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 6f3a382d6..54bfc347b 100644 --- a/build.gradle +++ b/build.gradle @@ -14,7 +14,7 @@ buildscript { classpath 'com.palantir.gradle.externalpublish:gradle-external-publish-plugin:1.12.0' classpath 'com.palantir.gradle.consistentversions:gradle-consistent-versions:2.12.0' classpath 'com.gradle.publish:plugin-publish-plugin:1.2.0' - classpath 'com.palantir.baseline:gradle-baseline-java:5.11.0' + classpath 'com.palantir.baseline:gradle-baseline-java:5.12.0' classpath 'com.palantir.javaformat:gradle-palantir-java-format:2.32.0' } } From 99524c329e33c8661807c437521ad1eb792fac15 Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Sat, 10 Jun 2023 12:10:59 +0100 Subject: [PATCH 072/129] Excavator: Update gradle-jdks infrastructure plugins (#2590) --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 54bfc347b..230c01f47 100644 --- a/build.gradle +++ b/build.gradle @@ -9,7 +9,7 @@ buildscript { dependencies { classpath 'com.palantir.jakartapackagealignment:jakarta-package-alignment:0.5.0' classpath 'com.palantir.gradle.jdks:gradle-jdks:0.32.0' - classpath 'com.palantir.gradle.jdkslatest:gradle-jdks-latest:0.7.0' + classpath 'com.palantir.gradle.jdkslatest:gradle-jdks-latest:0.8.0' classpath 'com.diffplug.gradle:goomph:3.32.1' classpath 'com.palantir.gradle.externalpublish:gradle-external-publish-plugin:1.12.0' classpath 'com.palantir.gradle.consistentversions:gradle-consistent-versions:2.12.0' From d1cf1d2c1c0093fee77b0af721f43ab1da9bb049 Mon Sep 17 00:00:00 2001 From: Carter Kozak Date: Mon, 12 Jun 2023 16:36:16 -0400 Subject: [PATCH 073/129] Opt out of the 'NotJavadoc' errorprone check (#2591) Opt out of the 'NotJavadoc' errorprone check --- changelog/@unreleased/pr-2591.v2.yml | 5 +++++ .../com/palantir/baseline/plugins/BaselineErrorProne.java | 2 ++ 2 files changed, 7 insertions(+) create mode 100644 changelog/@unreleased/pr-2591.v2.yml diff --git a/changelog/@unreleased/pr-2591.v2.yml b/changelog/@unreleased/pr-2591.v2.yml new file mode 100644 index 000000000..42b37433c --- /dev/null +++ b/changelog/@unreleased/pr-2591.v2.yml @@ -0,0 +1,5 @@ +type: improvement +improvement: + description: Opt out of the 'NotJavadoc' errorprone check + links: + - https://github.com/palantir/gradle-baseline/pull/2591 diff --git a/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineErrorProne.java b/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineErrorProne.java index ec383590f..be54e4e02 100644 --- a/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineErrorProne.java +++ b/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineErrorProne.java @@ -132,6 +132,8 @@ private static void configureErrorProneOptions( "CatchSpecificity", "CanIgnoreReturnValueSuggester", "InlineMeSuggester", + // We often use javadoc comments without javadoc parameter information. + "NotJavadoc", "PreferImmutableStreamExCollections", // StringCaseLocaleUsage duplicates our existing DefaultLocale check which is already // enforced in some places. From 8a9c39f908dcf6b1cf7403881b4a602ccced98d1 Mon Sep 17 00:00:00 2001 From: svc-autorelease Date: Mon, 12 Jun 2023 20:36:23 +0000 Subject: [PATCH 074/129] Autorelease 5.13.0 [skip ci] --- changelog/{@unreleased => 5.13.0}/pr-2591.v2.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename changelog/{@unreleased => 5.13.0}/pr-2591.v2.yml (100%) diff --git a/changelog/@unreleased/pr-2591.v2.yml b/changelog/5.13.0/pr-2591.v2.yml similarity index 100% rename from changelog/@unreleased/pr-2591.v2.yml rename to changelog/5.13.0/pr-2591.v2.yml From 982f35e1e67867ca3cfbd2af119b168c64b8651c Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Tue, 13 Jun 2023 02:03:05 +0100 Subject: [PATCH 075/129] Excavator: Upgrades Baseline to the latest version (#2592) --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 230c01f47..6ff85645a 100644 --- a/build.gradle +++ b/build.gradle @@ -14,7 +14,7 @@ buildscript { classpath 'com.palantir.gradle.externalpublish:gradle-external-publish-plugin:1.12.0' classpath 'com.palantir.gradle.consistentversions:gradle-consistent-versions:2.12.0' classpath 'com.gradle.publish:plugin-publish-plugin:1.2.0' - classpath 'com.palantir.baseline:gradle-baseline-java:5.12.0' + classpath 'com.palantir.baseline:gradle-baseline-java:5.13.0' classpath 'com.palantir.javaformat:gradle-palantir-java-format:2.32.0' } } From 1c48a0e6154227e1d33295cefc9216532b789777 Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Tue, 20 Jun 2023 18:18:31 +0100 Subject: [PATCH 076/129] Excavator: Format Java files (#2594) --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 6ff85645a..3c4682dd6 100644 --- a/build.gradle +++ b/build.gradle @@ -15,7 +15,7 @@ buildscript { classpath 'com.palantir.gradle.consistentversions:gradle-consistent-versions:2.12.0' classpath 'com.gradle.publish:plugin-publish-plugin:1.2.0' classpath 'com.palantir.baseline:gradle-baseline-java:5.13.0' - classpath 'com.palantir.javaformat:gradle-palantir-java-format:2.32.0' + classpath 'com.palantir.javaformat:gradle-palantir-java-format:2.33.0' } } From b28b49ce7d6c6acd658779b84352b847e6f2092c Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Wed, 21 Jun 2023 06:02:00 +0100 Subject: [PATCH 077/129] Excavator: Upgrade Jackson to the latest stable release (#2595) --- versions.lock | 8 ++++---- versions.props | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/versions.lock b/versions.lock index 98500b011..f314dde5c 100644 --- a/versions.lock +++ b/versions.lock @@ -77,10 +77,10 @@ org.slf4j:slf4j-api:1.7.36 (10 constraints: 769c0f4c) [Test dependencies] cglib:cglib-nodep:3.2.2 (1 constraints: 490ded24) -com.fasterxml.jackson.core:jackson-annotations:2.14.2 (4 constraints: 5c35b0b9) -com.fasterxml.jackson.core:jackson-core:2.14.2 (2 constraints: 0a2a8e13) -com.fasterxml.jackson.core:jackson-databind:2.14.2 (5 constraints: ad4a0060) -com.fasterxml.jackson.module:jackson-module-afterburner:2.14.2 (1 constraints: 3b053d3b) +com.fasterxml.jackson.core:jackson-annotations:2.15.2 (4 constraints: 5e3597ba) +com.fasterxml.jackson.core:jackson-core:2.15.2 (2 constraints: 0c2ad513) +com.fasterxml.jackson.core:jackson-databind:2.15.2 (5 constraints: af4a5361) +com.fasterxml.jackson.module:jackson-module-afterburner:2.15.2 (1 constraints: 3c05403b) com.github.stefanbirkner:system-rules:1.19.0 (1 constraints: 3d05443b) com.google.auto.value:auto-value:1.7.4 (1 constraints: 1f1221fb) com.google.errorprone:error_prone_test_helpers:2.19.1 (1 constraints: 3f054b3b) diff --git a/versions.props b/versions.props index 22be4b83e..0d27a0bd9 100644 --- a/versions.props +++ b/versions.props @@ -1,4 +1,4 @@ -com.fasterxml.jackson.core:jackson-databind = 2.14.2 +com.fasterxml.jackson.core:jackson-databind = 2.15.2 com.google.auto.service:auto-service = 1.0.1 com.google.guava:guava = 31.1-jre com.palantir.safe-logging:* = 3.4.0 @@ -17,7 +17,7 @@ com.palantir.gradle.utils:* = 0.1.0 com.uber.nullaway:nullaway = 0.10.10 # test deps -com.fasterxml.jackson.*:* = 2.14.2 +com.fasterxml.jackson.*:* = 2.15.2 com.github.stefanbirkner:system-rules = 1.19.0 com.netflix.nebula:nebula-test = 10.2.0 com.palantir.conjure.java:* = 6.77.0 From d18d97050f4bef7491cc1f71cc1e09d588e0b55f Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Mon, 26 Jun 2023 06:39:11 +0100 Subject: [PATCH 078/129] Excavator: Upgrade buildscript dependencies (#2598) --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 3c4682dd6..a27b8cfba 100644 --- a/build.gradle +++ b/build.gradle @@ -12,7 +12,7 @@ buildscript { classpath 'com.palantir.gradle.jdkslatest:gradle-jdks-latest:0.8.0' classpath 'com.diffplug.gradle:goomph:3.32.1' classpath 'com.palantir.gradle.externalpublish:gradle-external-publish-plugin:1.12.0' - classpath 'com.palantir.gradle.consistentversions:gradle-consistent-versions:2.12.0' + classpath 'com.palantir.gradle.consistentversions:gradle-consistent-versions:2.13.0' classpath 'com.gradle.publish:plugin-publish-plugin:1.2.0' classpath 'com.palantir.baseline:gradle-baseline-java:5.13.0' classpath 'com.palantir.javaformat:gradle-palantir-java-format:2.33.0' From a377360a36a99c6b7aab86f9769087f2522bcdd0 Mon Sep 17 00:00:00 2001 From: Carter Kozak Date: Mon, 26 Jun 2023 12:45:10 -0400 Subject: [PATCH 079/129] Fix unintentional suppression of StrictUnusedVariable (#2599) Fix unintentional suppression of StrictUnusedVariable --- .../errorprone/StrictUnusedVariable.java | 25 ++++++++++++++++++- changelog/@unreleased/pr-2599.v2.yml | 5 ++++ .../BaselineErrorProneIntegrationTest.groovy | 18 +++++++++++++ 3 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 changelog/@unreleased/pr-2599.v2.yml diff --git a/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/StrictUnusedVariable.java b/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/StrictUnusedVariable.java index 47e094108..91d9eeb44 100644 --- a/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/StrictUnusedVariable.java +++ b/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/StrictUnusedVariable.java @@ -67,7 +67,10 @@ import com.google.errorprone.bugpatterns.UnusedVariable; import com.google.errorprone.fixes.SuggestedFix; import com.google.errorprone.fixes.SuggestedFixes; +import com.google.errorprone.matchers.ChildMultiMatcher.MatchType; import com.google.errorprone.matchers.Description; +import com.google.errorprone.matchers.Matcher; +import com.google.errorprone.matchers.Matchers; import com.google.errorprone.suppliers.Suppliers; import com.google.errorprone.util.ASTHelpers; import com.sun.source.tree.AnnotationTree; @@ -92,6 +95,7 @@ import com.sun.source.tree.ReturnTree; import com.sun.source.tree.StatementTree; import com.sun.source.tree.Tree; +import com.sun.source.tree.Tree.Kind; import com.sun.source.tree.TryTree; import com.sun.source.tree.UnaryTree; import com.sun.source.tree.VariableTree; @@ -124,7 +128,6 @@ */ @AutoService(BugChecker.class) @BugPattern( - altNames = {"unused", "UnusedVariable"}, link = "https://github.com/palantir/gradle-baseline#baseline-error-prone-checks", linkType = BugPattern.LinkType.CUSTOM, summary = "Unused.", @@ -160,6 +163,21 @@ public final class StrictUnusedVariable extends BugChecker implements BugChecker "TAG"); private static final String UNUSED = "unused"; + private static final Matcher ALTERNATIVE_SUPPRESSED = Matchers.allOf( + // Matchers.annotations will throw given a tree that doesn't support annotations, so we must enumerate + // supported types. + Matchers.kindAnyOf(Set.of( + Kind.CLASS, Kind.VARIABLE, Kind.METHOD, Kind.ANNOTATED_TYPE, Kind.PACKAGE, Kind.COMPILATION_UNIT)), + Matchers.annotations( + MatchType.AT_LEAST_ONE, + Matchers.allOf( + Matchers.isType("java.lang.SuppressWarnings"), + Matchers.hasArgumentWithValue( + "value", + Matchers.anyOf( + Matchers.stringLiteral("UnusedVariable"), + Matchers.stringLiteral(UNUSED)))))); + @Override public Description matchCompilationUnit(CompilationUnitTree tree, VisitorState state) { // We will skip reporting on the whole compilation if there are any native methods found. @@ -277,6 +295,11 @@ private void checkUsedVariables(VisitorState state, VariableFinder variableFinde }); } + @Override + public boolean isSuppressed(Tree tree, VisitorState state) { + return super.isSuppressed(tree, state) || ALTERNATIVE_SUPPRESSED.matches(tree, state); + } + private static SuggestedFix constructUsedVariableSuggestedFix(List usagePaths, VisitorState state) { SuggestedFix.Builder fix = SuggestedFix.builder(); for (TreePath usagePath : usagePaths) { diff --git a/changelog/@unreleased/pr-2599.v2.yml b/changelog/@unreleased/pr-2599.v2.yml new file mode 100644 index 000000000..16c7afc9c --- /dev/null +++ b/changelog/@unreleased/pr-2599.v2.yml @@ -0,0 +1,5 @@ +type: fix +fix: + description: Fix unintentional suppression of StrictUnusedVariable + links: + - https://github.com/palantir/gradle-baseline/pull/2599 diff --git a/gradle-baseline-java/src/test/groovy/com/palantir/baseline/BaselineErrorProneIntegrationTest.groovy b/gradle-baseline-java/src/test/groovy/com/palantir/baseline/BaselineErrorProneIntegrationTest.groovy index b4b3e0639..974be1c8b 100644 --- a/gradle-baseline-java/src/test/groovy/com/palantir/baseline/BaselineErrorProneIntegrationTest.groovy +++ b/gradle-baseline-java/src/test/groovy/com/palantir/baseline/BaselineErrorProneIntegrationTest.groovy @@ -96,6 +96,24 @@ class BaselineErrorProneIntegrationTest extends AbstractPluginTest { result.output.contains("[ArrayEquals] Reference equality used to compare arrays") } + def 'compileJava fails when StrictUnusedVariable finds errors'() { + when: + buildFile << standardBuildFile + file('src/main/java/test/Test.java') << ''' + package test; + public class Test { + void test() { + int a = 5; + } + } + '''.stripIndent() + + then: + BuildResult result = with('compileJava').buildAndFail() + result.task(":compileJava").outcome == TaskOutcome.FAILED + result.output.contains("[StrictUnusedVariable]") + } + def 'error-prone can be disabled using property'() { when: buildFile << standardBuildFile From 4716923664ae2e2689998b87c0874270f33884e3 Mon Sep 17 00:00:00 2001 From: svc-autorelease Date: Mon, 26 Jun 2023 16:45:17 +0000 Subject: [PATCH 080/129] Autorelease 5.14.0 [skip ci] --- changelog/{@unreleased => 5.14.0}/pr-2599.v2.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename changelog/{@unreleased => 5.14.0}/pr-2599.v2.yml (100%) diff --git a/changelog/@unreleased/pr-2599.v2.yml b/changelog/5.14.0/pr-2599.v2.yml similarity index 100% rename from changelog/@unreleased/pr-2599.v2.yml rename to changelog/5.14.0/pr-2599.v2.yml From 6dc57678fc7c450fdad5213ef28ab75e8b77660e Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Mon, 26 Jun 2023 23:20:46 +0100 Subject: [PATCH 081/129] Excavator: Upgrade dependencies (#2573) --- .../baseline-class-uniqueness.lock | 1 + .../baseline-class-uniqueness.lock | 1 + .../src/main/resources/checkstyle.version | 2 +- versions.lock | 62 +++++++++---------- versions.props | 26 ++++---- 5 files changed, 47 insertions(+), 45 deletions(-) diff --git a/baseline-error-prone/baseline-class-uniqueness.lock b/baseline-error-prone/baseline-class-uniqueness.lock index ee641fc71..fdebd72fb 100644 --- a/baseline-error-prone/baseline-class-uniqueness.lock +++ b/baseline-error-prone/baseline-class-uniqueness.lock @@ -4,6 +4,7 @@ ## runtimeClasspath [org.checkerframework:checker-qual, org.checkerframework:dataflow-errorprone] - org.checkerframework.dataflow.qual.Deterministic + - org.checkerframework.dataflow.qual.Impure - org.checkerframework.dataflow.qual.Pure - org.checkerframework.dataflow.qual.Pure$Kind - org.checkerframework.dataflow.qual.SideEffectFree diff --git a/baseline-null-away/baseline-class-uniqueness.lock b/baseline-null-away/baseline-class-uniqueness.lock index 0992dbcd0..d7809bd81 100644 --- a/baseline-null-away/baseline-class-uniqueness.lock +++ b/baseline-null-away/baseline-class-uniqueness.lock @@ -4,6 +4,7 @@ ## runtimeClasspath [org.checkerframework:checker-qual, org.checkerframework:dataflow-nullaway] - org.checkerframework.dataflow.qual.Deterministic + - org.checkerframework.dataflow.qual.Impure - org.checkerframework.dataflow.qual.Pure - org.checkerframework.dataflow.qual.Pure$Kind - org.checkerframework.dataflow.qual.SideEffectFree diff --git a/gradle-baseline-java/src/main/resources/checkstyle.version b/gradle-baseline-java/src/main/resources/checkstyle.version index 4843a6d66..56a0ac3a2 100644 --- a/gradle-baseline-java/src/main/resources/checkstyle.version +++ b/gradle-baseline-java/src/main/resources/checkstyle.version @@ -1 +1 @@ -10.10.0 \ No newline at end of file +10.12.1 \ No newline at end of file diff --git a/versions.lock b/versions.lock index f314dde5c..0bd6e42c3 100644 --- a/versions.lock +++ b/versions.lock @@ -8,21 +8,21 @@ com.diffplug.spotless:spotless-lib-extra:2.25.3 (1 constraints: 4c132341) com.diffplug.spotless:spotless-plugin-gradle:6.6.0 (1 constraints: 0e051b36) com.github.ben-manes.caffeine:caffeine:3.0.5 (1 constraints: e312a21b) com.github.kevinstern:software-and-algorithms:1.0 (1 constraints: 7e12fcf5) -com.google.auto:auto-common:1.2.1 (3 constraints: 14321a1e) -com.google.auto.service:auto-service:1.0.1 (1 constraints: 0405f135) -com.google.auto.service:auto-service-annotations:1.0.1 (2 constraints: 8920021c) +com.google.auto:auto-common:1.2.1 (3 constraints: 73322261) +com.google.auto.service:auto-service:1.1.1 (1 constraints: 0505f435) +com.google.auto.service:auto-service-annotations:1.1.1 (2 constraints: 8a20341c) com.google.auto.value:auto-value-annotations:1.9 (3 constraints: 802d5ac8) com.google.code.findbugs:jsr305:3.0.2 (6 constraints: 66626968) com.google.errorprone:error_prone_annotation:2.19.1 (3 constraints: d338dff0) -com.google.errorprone:error_prone_annotations:2.19.1 (12 constraints: 98bdf6a8) +com.google.errorprone:error_prone_annotations:2.19.1 (12 constraints: bbbdcfbe) com.google.errorprone:error_prone_check_api:2.19.1 (2 constraints: bc255700) com.google.errorprone:error_prone_core:2.19.1 (1 constraints: 3f054b3b) com.google.errorprone:error_prone_type_annotations:2.19.1 (1 constraints: 2a115ec9) com.google.guava:failureaccess:1.0.1 (2 constraints: f1150513) -com.google.guava:guava:31.1-jre (15 constraints: 95f432a0) +com.google.guava:guava:32.0.1-jre (15 constraints: 54f5627b) com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava (1 constraints: bd17c918) com.google.inject:guice:5.1.0 (2 constraints: c21eb8b6) -com.google.j2objc:j2objc-annotations:1.3 (1 constraints: b809eda0) +com.google.j2objc:j2objc-annotations:2.8 (1 constraints: be09f5a0) com.google.protobuf:protobuf-java:3.19.2 (1 constraints: 2c1165c9) com.googlecode.concurrent-trees:concurrent-trees:2.6.1 (1 constraints: 761166da) com.googlecode.java-diff-utils:diffutils:1.3.0 (1 constraints: 0605f935) @@ -30,8 +30,8 @@ com.googlecode.javaewah:JavaEWAH:1.1.12 (1 constraints: 750eee5e) com.palantir.gradle.utils:lazily-configured-mapping:0.1.0 (1 constraints: 0305ee35) com.palantir.javaformat:gradle-palantir-java-format:1.1.0 (1 constraints: 0405f335) com.palantir.javaformat:palantir-java-format-spi:1.1.0 (1 constraints: 711560be) -com.uber.nullaway:nullaway:0.10.10 (1 constraints: 64058840) -commons-io:commons-io:2.11.0 (1 constraints: be14ed98) +com.uber.nullaway:nullaway:0.10.11 (1 constraints: 65058940) +commons-io:commons-io:2.13.0 (1 constraints: be14ed98) commons-lang:commons-lang:2.6 (1 constraints: ac04232c) io.github.java-diff-utils:java-diff-utils:4.0 (1 constraints: 811205f6) javax.annotation:javax.annotation-api:1.3.2 (2 constraints: cd204f35) @@ -41,7 +41,7 @@ org.apache.commons:commons-lang3:3.12.0 (4 constraints: 04327fb1) org.apache.maven:maven-artifact:3.9.1 (4 constraints: 153e4040) org.apache.maven:maven-builder-support:3.9.1 (3 constraints: 112c6464) org.apache.maven:maven-core:3.9.1 (2 constraints: a21989df) -org.apache.maven:maven-model:3.9.1 (4 constraints: cb3ac915) +org.apache.maven:maven-model:3.9.1 (5 constraints: 5e4f88ec) org.apache.maven:maven-model-builder:3.9.1 (2 constraints: 321d6d0a) org.apache.maven:maven-plugin-api:3.9.1 (1 constraints: e90b70f3) org.apache.maven:maven-repository-metadata:3.9.1 (2 constraints: 321d6d0a) @@ -53,11 +53,11 @@ org.apache.maven.resolver:maven-resolver-impl:1.9.7 (2 constraints: 3a1d290b) org.apache.maven.resolver:maven-resolver-named-locks:1.9.7 (1 constraints: 3513e634) org.apache.maven.resolver:maven-resolver-spi:1.9.7 (3 constraints: 6e306f6a) org.apache.maven.resolver:maven-resolver-util:1.9.7 (3 constraints: 6e306f6a) -org.apache.maven.shared:maven-dependency-analyzer:1.13.1 (1 constraints: 3805333b) +org.apache.maven.shared:maven-dependency-analyzer:1.13.2 (1 constraints: 3905343b) org.apache.maven.shared:maven-shared-utils:3.3.4 (1 constraints: e60b61f3) -org.checkerframework:checker-qual:3.33.0 (3 constraints: 08256088) -org.checkerframework:dataflow-errorprone:3.33.0 (4 constraints: 0a3e5c60) -org.checkerframework:dataflow-nullaway:3.33.0 (2 constraints: 6a1198f1) +org.checkerframework:checker-qual:3.35.0 (3 constraints: 0b25cb88) +org.checkerframework:dataflow-errorprone:3.35.0 (4 constraints: 0c3e9c61) +org.checkerframework:dataflow-nullaway:3.35.0 (2 constraints: 6c11e6f1) org.codehaus.groovy:groovy:3.0.10 (3 constraints: e32879d6) org.codehaus.groovy:groovy-xml:3.0.10 (1 constraints: 791161da) org.codehaus.plexus:plexus-cipher:2.0 (1 constraints: 641174c7) @@ -77,9 +77,9 @@ org.slf4j:slf4j-api:1.7.36 (10 constraints: 769c0f4c) [Test dependencies] cglib:cglib-nodep:3.2.2 (1 constraints: 490ded24) -com.fasterxml.jackson.core:jackson-annotations:2.15.2 (4 constraints: 5e3597ba) +com.fasterxml.jackson.core:jackson-annotations:2.15.2 (4 constraints: 5f3598ba) com.fasterxml.jackson.core:jackson-core:2.15.2 (2 constraints: 0c2ad513) -com.fasterxml.jackson.core:jackson-databind:2.15.2 (5 constraints: af4a5361) +com.fasterxml.jackson.core:jackson-databind:2.15.2 (5 constraints: b04a5461) com.fasterxml.jackson.module:jackson-module-afterburner:2.15.2 (1 constraints: 3c05403b) com.github.stefanbirkner:system-rules:1.19.0 (1 constraints: 3d05443b) com.google.auto.value:auto-value:1.7.4 (1 constraints: 1f1221fb) @@ -92,23 +92,23 @@ com.netflix.nebula:nebula-test:10.2.0 (1 constraints: 35052d3b) com.palantir.conjure.java:conjure-lib:6.77.0 (1 constraints: 4605743b) com.palantir.conjure.java.api:errors:2.35.0 (2 constraints: 6e21c9b0) com.palantir.conjure.java.api:test-utils:2.35.0 (1 constraints: 3c05463b) -com.palantir.conjure.java.runtime:conjure-java-annotations:7.55.0 (1 constraints: 43056c3b) +com.palantir.conjure.java.runtime:conjure-java-annotations:7.58.0 (1 constraints: 4605753b) com.palantir.ri:resource-identifier:2.5.0 (1 constraints: ef0f7999) -com.palantir.safe-logging:logger:3.4.0 (2 constraints: dc12d336) -com.palantir.safe-logging:logger-slf4j:3.4.0 (1 constraints: 020e5f42) -com.palantir.safe-logging:logger-spi:3.4.0 (2 constraints: 131e037b) -com.palantir.safe-logging:preconditions:3.4.0 (6 constraints: 1b576bb9) -com.palantir.safe-logging:preconditions-assertj:3.4.0 (1 constraints: 09050636) -com.palantir.safe-logging:safe-logging:3.4.0 (8 constraints: 6c7765e0) -com.palantir.tokens:auth-tokens:3.17.0 (2 constraints: 5f1502db) -com.palantir.tritium:tritium-registry:0.67.0 (1 constraints: 3f054c3b) -io.dropwizard.metrics:metrics-core:4.2.18 (1 constraints: c91054b6) +com.palantir.safe-logging:logger:3.5.0 (2 constraints: df120437) +com.palantir.safe-logging:logger-slf4j:3.5.0 (1 constraints: 030e6242) +com.palantir.safe-logging:logger-spi:3.5.0 (2 constraints: 151e387b) +com.palantir.safe-logging:preconditions:3.5.0 (6 constraints: 215718bb) +com.palantir.safe-logging:preconditions-assertj:3.5.0 (1 constraints: 0a050936) +com.palantir.safe-logging:safe-logging:3.5.0 (8 constraints: 7377ade3) +com.palantir.tokens:auth-tokens:3.18.0 (2 constraints: 601534db) +com.palantir.tritium:tritium-registry:0.69.0 (1 constraints: 4105523b) +io.dropwizard.metrics:metrics-core:4.2.19 (1 constraints: ca1055b6) io.r2dbc:r2dbc-spi:1.0.0.RELEASE (1 constraints: ea08e898) javax.ws.rs:javax.ws.rs-api:2.1.1 (1 constraints: ec0f6e99) junit:junit:4.13.2 (8 constraints: 1d727319) junit:junit-dep:4.11 (1 constraints: ba1063b3) -net.bytebuddy:byte-buddy:1.14.4 (2 constraints: c016a64f) -net.bytebuddy:byte-buddy-agent:1.14.4 (1 constraints: 440b42de) +net.bytebuddy:byte-buddy:1.14.5 (2 constraints: c116a74f) +net.bytebuddy:byte-buddy-agent:1.14.5 (1 constraints: 450b43de) net.lingala.zip4j:zip4j:1.3.2 (1 constraints: 0805fb35) one.util:streamex:0.8.1 (1 constraints: 0b050436) org.apiguardian:apiguardian-api:1.1.2 (7 constraints: 9d791b5f) @@ -117,17 +117,17 @@ org.hamcrest:hamcrest:2.2 (2 constraints: 43187376) org.hamcrest:hamcrest-core:2.2 (4 constraints: 2b2b359e) org.hamcrest:hamcrest-library:2.2 (1 constraints: fc138e38) org.jetbrains:annotations:24.0.1 (2 constraints: fc20bc6d) -org.jooq:jooq:3.18.3 (1 constraints: 4105503b) +org.jooq:jooq:3.18.5 (1 constraints: 4305523b) org.junit.jupiter:junit-jupiter:5.9.3 (1 constraints: 13052236) -org.junit.jupiter:junit-jupiter-api:5.9.3 (5 constraints: 67538fc1) +org.junit.jupiter:junit-jupiter-api:5.9.3 (5 constraints: 685390c1) org.junit.jupiter:junit-jupiter-engine:5.9.3 (1 constraints: 0e0ee33b) org.junit.jupiter:junit-jupiter-migrationsupport:5.9.3 (1 constraints: 13052236) org.junit.jupiter:junit-jupiter-params:5.9.3 (1 constraints: 0e0ee33b) org.junit.platform:junit-platform-commons:1.9.3 (2 constraints: e120754b) org.junit.platform:junit-platform-engine:1.9.3 (3 constraints: 642e7180) org.junit.vintage:junit-vintage-engine:5.9.3 (1 constraints: 13052236) -org.mockito:mockito-core:5.3.1 (3 constraints: e92446fa) -org.mockito:mockito-junit-jupiter:5.3.1 (1 constraints: 0b050e36) +org.mockito:mockito-core:5.4.0 (3 constraints: e9244afa) +org.mockito:mockito-junit-jupiter:5.4.0 (1 constraints: 0b051036) org.objenesis:objenesis:3.3 (2 constraints: 9b17f557) org.opentest4j:opentest4j:1.2.0 (2 constraints: cd205b49) org.reactivestreams:reactive-streams:1.0.3 (1 constraints: ef07e77b) diff --git a/versions.props b/versions.props index 0d27a0bd9..293d76b7b 100644 --- a/versions.props +++ b/versions.props @@ -1,20 +1,20 @@ com.fasterxml.jackson.core:jackson-databind = 2.15.2 -com.google.auto.service:auto-service = 1.0.1 -com.google.guava:guava = 31.1-jre -com.palantir.safe-logging:* = 3.4.0 +com.google.auto.service:auto-service = 1.1.1 +com.google.guava:guava = 32.0.1-jre +com.palantir.safe-logging:* = 3.5.0 commons-lang:commons-lang = 2.6 -org.apache.maven.shared:maven-dependency-analyzer = 1.13.1 +org.apache.maven.shared:maven-dependency-analyzer = 1.13.2 org.apache.maven:maven-core = 3.9.1 org.inferred:freebuilder = 1.14.6 -org.jooq:jooq = 3.18.3 +org.jooq:jooq = 3.18.5 org.slf4j:* = 1.7.36 org.immutables:* = 2.9.3 org.ow2.asm:asm = 9.5 com.google.errorprone:error_prone_* = 2.19.1 com.googlecode.java-diff-utils:diffutils = 1.3.0 -com.puppycrawl.tools:checkstyle = 10.10.0 +com.puppycrawl.tools:checkstyle = 10.12.1 com.palantir.gradle.utils:* = 0.1.0 -com.uber.nullaway:nullaway = 0.10.10 +com.uber.nullaway:nullaway = 0.10.11 # test deps com.fasterxml.jackson.*:* = 2.15.2 @@ -22,22 +22,22 @@ com.github.stefanbirkner:system-rules = 1.19.0 com.netflix.nebula:nebula-test = 10.2.0 com.palantir.conjure.java:* = 6.77.0 com.palantir.conjure.java.api:* = 2.35.0 -com.palantir.conjure.java.runtime:* = 7.55.0 -com.palantir.tokens:auth-tokens = 3.17.0 -com.palantir.tritium:* = 0.67.0 -commons-io:* = 2.11.0 +com.palantir.conjure.java.runtime:* = 7.58.0 +com.palantir.tokens:auth-tokens = 3.18.0 +com.palantir.tritium:* = 0.69.0 +commons-io:* = 2.13.0 junit:junit = 4.13.2 net.lingala.zip4j:zip4j = 1.3.2 net.ltgt.gradle:gradle-errorprone-plugin = 3.1.0 one.util:streamex = 0.8.1 org.apache.commons:commons-lang3 = 3.12.0 org.assertj:assertj-core = 3.24.2 -org.checkerframework:* = 3.33.0 +org.checkerframework:* = 3.35.0 org.hamcrest:hamcrest-core = 2.2 org.junit.jupiter:* = 5.9.3 org.junit.vintage:* = 5.9.3 org.junit.platform:* = 1.9.3 -org.mockito:* = 5.3.1 +org.mockito:* = 5.4.0 # dependency-upgrader:OFF # Don't upgrade, we will remove this in a future release. From 72cff0d52cc6b443bdbd3bffe44f089ae6aa8afd Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Mon, 26 Jun 2023 23:23:18 +0100 Subject: [PATCH 082/129] Excavator: Upgrades Baseline to the latest version (#2600) --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index a27b8cfba..5672ecf70 100644 --- a/build.gradle +++ b/build.gradle @@ -14,7 +14,7 @@ buildscript { classpath 'com.palantir.gradle.externalpublish:gradle-external-publish-plugin:1.12.0' classpath 'com.palantir.gradle.consistentversions:gradle-consistent-versions:2.13.0' classpath 'com.gradle.publish:plugin-publish-plugin:1.2.0' - classpath 'com.palantir.baseline:gradle-baseline-java:5.13.0' + classpath 'com.palantir.baseline:gradle-baseline-java:5.14.0' classpath 'com.palantir.javaformat:gradle-palantir-java-format:2.33.0' } } From c8e0babd6c7eb28314e6fe65e6f9a1f63e27fada Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Tue, 27 Jun 2023 03:22:26 +0100 Subject: [PATCH 083/129] Excavator: Upgrades Baseline to the latest version (#2601) --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 5672ecf70..b3a3dd2e3 100644 --- a/build.gradle +++ b/build.gradle @@ -14,7 +14,7 @@ buildscript { classpath 'com.palantir.gradle.externalpublish:gradle-external-publish-plugin:1.12.0' classpath 'com.palantir.gradle.consistentversions:gradle-consistent-versions:2.13.0' classpath 'com.gradle.publish:plugin-publish-plugin:1.2.0' - classpath 'com.palantir.baseline:gradle-baseline-java:5.14.0' + classpath 'com.palantir.baseline:gradle-baseline-java:5.15.0' classpath 'com.palantir.javaformat:gradle-palantir-java-format:2.33.0' } } From cafa70ea792c79778d8fb7577323545c85c88b44 Mon Sep 17 00:00:00 2001 From: Carter Kozak Date: Tue, 27 Jun 2023 10:03:36 -0400 Subject: [PATCH 084/129] Fix nullaway checkerframework dependency (#2602) Fix nullaway checkerframework dependency --- baseline-error-prone/baseline-class-uniqueness.lock | 1 - baseline-null-away/baseline-class-uniqueness.lock | 1 - changelog/@unreleased/pr-2602.v2.yml | 5 +++++ versions.lock | 6 +++--- versions.props | 4 +++- 5 files changed, 11 insertions(+), 6 deletions(-) create mode 100644 changelog/@unreleased/pr-2602.v2.yml diff --git a/baseline-error-prone/baseline-class-uniqueness.lock b/baseline-error-prone/baseline-class-uniqueness.lock index fdebd72fb..ee641fc71 100644 --- a/baseline-error-prone/baseline-class-uniqueness.lock +++ b/baseline-error-prone/baseline-class-uniqueness.lock @@ -4,7 +4,6 @@ ## runtimeClasspath [org.checkerframework:checker-qual, org.checkerframework:dataflow-errorprone] - org.checkerframework.dataflow.qual.Deterministic - - org.checkerframework.dataflow.qual.Impure - org.checkerframework.dataflow.qual.Pure - org.checkerframework.dataflow.qual.Pure$Kind - org.checkerframework.dataflow.qual.SideEffectFree diff --git a/baseline-null-away/baseline-class-uniqueness.lock b/baseline-null-away/baseline-class-uniqueness.lock index d7809bd81..0992dbcd0 100644 --- a/baseline-null-away/baseline-class-uniqueness.lock +++ b/baseline-null-away/baseline-class-uniqueness.lock @@ -4,7 +4,6 @@ ## runtimeClasspath [org.checkerframework:checker-qual, org.checkerframework:dataflow-nullaway] - org.checkerframework.dataflow.qual.Deterministic - - org.checkerframework.dataflow.qual.Impure - org.checkerframework.dataflow.qual.Pure - org.checkerframework.dataflow.qual.Pure$Kind - org.checkerframework.dataflow.qual.SideEffectFree diff --git a/changelog/@unreleased/pr-2602.v2.yml b/changelog/@unreleased/pr-2602.v2.yml new file mode 100644 index 000000000..621c0f900 --- /dev/null +++ b/changelog/@unreleased/pr-2602.v2.yml @@ -0,0 +1,5 @@ +type: fix +fix: + description: Fix nullaway checkerframework dependency + links: + - https://github.com/palantir/gradle-baseline/pull/2602 diff --git a/versions.lock b/versions.lock index 0bd6e42c3..5139f60b5 100644 --- a/versions.lock +++ b/versions.lock @@ -55,9 +55,9 @@ org.apache.maven.resolver:maven-resolver-spi:1.9.7 (3 constraints: 6e306f6a) org.apache.maven.resolver:maven-resolver-util:1.9.7 (3 constraints: 6e306f6a) org.apache.maven.shared:maven-dependency-analyzer:1.13.2 (1 constraints: 3905343b) org.apache.maven.shared:maven-shared-utils:3.3.4 (1 constraints: e60b61f3) -org.checkerframework:checker-qual:3.35.0 (3 constraints: 0b25cb88) -org.checkerframework:dataflow-errorprone:3.35.0 (4 constraints: 0c3e9c61) -org.checkerframework:dataflow-nullaway:3.35.0 (2 constraints: 6c11e6f1) +org.checkerframework:checker-qual:3.33.0 (3 constraints: 0b25cb88) +org.checkerframework:dataflow-errorprone:3.33.0 (4 constraints: 0a3e5c60) +org.checkerframework:dataflow-nullaway:3.33.0 (2 constraints: 6a1198f1) org.codehaus.groovy:groovy:3.0.10 (3 constraints: e32879d6) org.codehaus.groovy:groovy-xml:3.0.10 (1 constraints: 791161da) org.codehaus.plexus:plexus-cipher:2.0 (1 constraints: 641174c7) diff --git a/versions.props b/versions.props index 293d76b7b..ee677d6ea 100644 --- a/versions.props +++ b/versions.props @@ -32,7 +32,6 @@ net.ltgt.gradle:gradle-errorprone-plugin = 3.1.0 one.util:streamex = 0.8.1 org.apache.commons:commons-lang3 = 3.12.0 org.assertj:assertj-core = 3.24.2 -org.checkerframework:* = 3.35.0 org.hamcrest:hamcrest-core = 2.2 org.junit.jupiter:* = 5.9.3 org.junit.vintage:* = 5.9.3 @@ -47,4 +46,7 @@ com.palantir.javaformat:gradle-palantir-java-format = 1.1.0 com.diffplug.spotless:spotless-plugin-gradle = 6.6.0 # Groovy versions must be compatible with gradle org.codehaus.groovy:* = 3.0.10 +# checkerframework dependencies should be limited to errorpropne and nullaway +# requirements, upgrading prior to those often causes compilation failures. +org.checkerframework:* = 3.33.0 # dependency-upgrader:ON From 572905e5a3523dcb7d766ecd31960df6b14cd62b Mon Sep 17 00:00:00 2001 From: svc-autorelease Date: Tue, 27 Jun 2023 14:03:46 +0000 Subject: [PATCH 085/129] Autorelease 5.16.0 [skip ci] --- changelog/{@unreleased => 5.16.0}/pr-2602.v2.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename changelog/{@unreleased => 5.16.0}/pr-2602.v2.yml (100%) diff --git a/changelog/@unreleased/pr-2602.v2.yml b/changelog/5.16.0/pr-2602.v2.yml similarity index 100% rename from changelog/@unreleased/pr-2602.v2.yml rename to changelog/5.16.0/pr-2602.v2.yml From b9e5c7c8ed1e00277b0d8f5e533402ec496b41b4 Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Tue, 27 Jun 2023 16:45:57 +0100 Subject: [PATCH 086/129] Excavator: Upgrades Baseline to the latest version (#2603) --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index b3a3dd2e3..105745433 100644 --- a/build.gradle +++ b/build.gradle @@ -14,7 +14,7 @@ buildscript { classpath 'com.palantir.gradle.externalpublish:gradle-external-publish-plugin:1.12.0' classpath 'com.palantir.gradle.consistentversions:gradle-consistent-versions:2.13.0' classpath 'com.gradle.publish:plugin-publish-plugin:1.2.0' - classpath 'com.palantir.baseline:gradle-baseline-java:5.15.0' + classpath 'com.palantir.baseline:gradle-baseline-java:5.16.0' classpath 'com.palantir.javaformat:gradle-palantir-java-format:2.33.0' } } From 7d340b82fce1652d04342ee06f70969a7ecb5b70 Mon Sep 17 00:00:00 2001 From: Patrick Koenig Date: Tue, 27 Jun 2023 09:17:07 -0700 Subject: [PATCH 087/129] Add error-prone check to prefer ZoneId constants (#2596) --- README.md | 1 + .../baseline/errorprone/ZoneIdConstant.java | 62 ++++++++++++ .../errorprone/ZoneIdConstantTest.java | 94 +++++++++++++++++++ changelog/@unreleased/pr-2596.v2.yml | 5 + .../BaselineErrorProneExtension.java | 1 + 5 files changed, 163 insertions(+) create mode 100644 baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/ZoneIdConstant.java create mode 100644 baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/ZoneIdConstantTest.java create mode 100644 changelog/@unreleased/pr-2596.v2.yml diff --git a/README.md b/README.md index 7a43f7cfc..272513f6c 100644 --- a/README.md +++ b/README.md @@ -215,6 +215,7 @@ Safe Logging can be found at [github.com/palantir/safe-logging](https://github.c - `UnnecessarilyQualified`: Types should not be qualified if they are also imported. - `DeprecatedGuavaObjects`: `com.google.common.base.Objects` has been obviated by `java.util.Objects`. - `JavaTimeSystemDefaultTimeZone`: Avoid using the system default time zone. +- `ZoneIdConstant`: Prefer `ZoneId` constants. - `IncubatingMethod`: Prevents calling Conjure incubating APIs unless you explicitly opt-out of the check on a per-use or per-project basis. - `CompileTimeConstantViolatesLiskovSubstitution`: Requires consistent application of the `@CompileTimeConstant` annotation to resolve inconsistent validation based on the reference type on which the met is invoked. - `ClassInitializationDeadlock`: Detect type structures which can cause deadlocks initializing classes. diff --git a/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/ZoneIdConstant.java b/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/ZoneIdConstant.java new file mode 100644 index 000000000..8d0be6c4b --- /dev/null +++ b/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/ZoneIdConstant.java @@ -0,0 +1,62 @@ +/* + * (c) Copyright 2023 Palantir Technologies Inc. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.palantir.baseline.errorprone; + +import com.google.auto.service.AutoService; +import com.google.errorprone.BugPattern; +import com.google.errorprone.VisitorState; +import com.google.errorprone.bugpatterns.BugChecker; +import com.google.errorprone.fixes.SuggestedFix; +import com.google.errorprone.fixes.SuggestedFixes; +import com.google.errorprone.matchers.Description; +import com.google.errorprone.matchers.Matcher; +import com.google.errorprone.matchers.Matchers; +import com.google.errorprone.util.ASTHelpers; +import com.sun.source.tree.ExpressionTree; +import com.sun.source.tree.MethodInvocationTree; +import java.time.ZoneId; +import java.time.ZoneOffset; + +@AutoService(BugChecker.class) +@BugPattern( + link = "https://github.com/palantir/gradle-baseline#baseline-error-prone-checks", + linkType = BugPattern.LinkType.CUSTOM, + severity = BugPattern.SeverityLevel.WARNING, + summary = "Prefer ZoneId constants.") +public final class ZoneIdConstant extends BugChecker implements BugChecker.MethodInvocationTreeMatcher { + + private static final Matcher ZONE_ID_OF = + Matchers.staticMethod().onClass(ZoneId.class.getName()).named("of").withParameters(String.class.getName()); + + @Override + public Description matchMethodInvocation(MethodInvocationTree tree, VisitorState state) { + if (ZONE_ID_OF.matches(tree, state)) { + String zone = ASTHelpers.constValue(tree.getArguments().get(0), String.class); + if (zone != null && (zone.equals("Z") || zone.equals("UTC"))) { + SuggestedFix.Builder fix = SuggestedFix.builder(); + return buildDescription(tree) + .addFix(fix.replace( + tree, + SuggestedFixes.qualifyType(state, fix, ZoneOffset.class.getName()) + ".UTC") + .build()) + .build(); + } + } + + return Description.NO_MATCH; + } +} diff --git a/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/ZoneIdConstantTest.java b/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/ZoneIdConstantTest.java new file mode 100644 index 000000000..df2718082 --- /dev/null +++ b/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/ZoneIdConstantTest.java @@ -0,0 +1,94 @@ +/* + * (c) Copyright 2023 Palantir Technologies Inc. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.palantir.baseline.errorprone; + +import org.junit.jupiter.api.Test; + +final class ZoneIdConstantTest { + + @Test + void zoneIdZ() { + fix().addInputLines( + "Test.java", + "import java.time.ZoneId;", + "class Test {", + " static void f() {", + " ZoneId zoneId = ZoneId.of(\"Z\");", + " }", + "}") + .addOutputLines( + "Test.java", + "import java.time.ZoneId;", + "import java.time.ZoneOffset;", + "class Test {", + " static void f() {", + " ZoneId zoneId = ZoneOffset.UTC;", + " }", + "}") + .doTest(); + } + + @Test + void zoneIdUtc() { + fix().addInputLines( + "Test.java", + "import java.time.ZoneId;", + "class Test {", + " static void f() {", + " ZoneId zoneId = ZoneId.of(\"UTC\");", + " }", + "}") + .addOutputLines( + "Test.java", + "import java.time.ZoneId;", + "import java.time.ZoneOffset;", + "class Test {", + " static void f() {", + " ZoneId zoneId = ZoneOffset.UTC;", + " }", + "}") + .doTest(); + } + + @Test + void zoneIdConstant() { + fix().addInputLines( + "Test.java", + "import java.time.ZoneId;", + "class Test {", + " static final String Z = \"Z\";", + " static void f() {", + " ZoneId zoneId = ZoneId.of(Z);", + " }", + "}") + .addOutputLines( + "Test.java", + "import java.time.ZoneId;", + "import java.time.ZoneOffset;", + "class Test {", + " static final String Z = \"Z\";", + " static void f() {", + " ZoneId zoneId = ZoneOffset.UTC;", + " }", + "}") + .doTest(); + } + + private RefactoringValidator fix() { + return RefactoringValidator.of(ZoneIdConstant.class, getClass()); + } +} diff --git a/changelog/@unreleased/pr-2596.v2.yml b/changelog/@unreleased/pr-2596.v2.yml new file mode 100644 index 000000000..1acccb333 --- /dev/null +++ b/changelog/@unreleased/pr-2596.v2.yml @@ -0,0 +1,5 @@ +type: feature +feature: + description: Add error-prone check to prefer ZoneId constants + links: + - https://github.com/palantir/gradle-baseline/pull/2596 diff --git a/gradle-baseline-java/src/main/groovy/com/palantir/baseline/extensions/BaselineErrorProneExtension.java b/gradle-baseline-java/src/main/groovy/com/palantir/baseline/extensions/BaselineErrorProneExtension.java index 6d14f8dc7..db0b0cbb5 100644 --- a/gradle-baseline-java/src/main/groovy/com/palantir/baseline/extensions/BaselineErrorProneExtension.java +++ b/gradle-baseline-java/src/main/groovy/com/palantir/baseline/extensions/BaselineErrorProneExtension.java @@ -80,6 +80,7 @@ public class BaselineErrorProneExtension { "UnsafeGaugeRegistration", "VarUsage", "ZeroWarmupRateLimiter", + "ZoneIdConstant", // Built-in checks "ArrayEquals", From 8577f4da5608cf9f85076cde10380e9648f1f53a Mon Sep 17 00:00:00 2001 From: svc-autorelease Date: Tue, 27 Jun 2023 16:17:14 +0000 Subject: [PATCH 088/129] Autorelease 5.17.0 [skip ci] --- changelog/{@unreleased => 5.17.0}/pr-2596.v2.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename changelog/{@unreleased => 5.17.0}/pr-2596.v2.yml (100%) diff --git a/changelog/@unreleased/pr-2596.v2.yml b/changelog/5.17.0/pr-2596.v2.yml similarity index 100% rename from changelog/@unreleased/pr-2596.v2.yml rename to changelog/5.17.0/pr-2596.v2.yml From 0621df9e60e854551490517dab6e250ebbfbb7e9 Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Tue, 27 Jun 2023 23:13:33 +0100 Subject: [PATCH 089/129] Excavator: Upgrades Baseline to the latest version (#2604) --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 105745433..ad7d20b38 100644 --- a/build.gradle +++ b/build.gradle @@ -14,7 +14,7 @@ buildscript { classpath 'com.palantir.gradle.externalpublish:gradle-external-publish-plugin:1.12.0' classpath 'com.palantir.gradle.consistentversions:gradle-consistent-versions:2.13.0' classpath 'com.gradle.publish:plugin-publish-plugin:1.2.0' - classpath 'com.palantir.baseline:gradle-baseline-java:5.16.0' + classpath 'com.palantir.baseline:gradle-baseline-java:5.17.0' classpath 'com.palantir.javaformat:gradle-palantir-java-format:2.33.0' } } From 62e31617e56e81449b42bf48ea50614c4af046af Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Thu, 29 Jun 2023 15:03:47 -0700 Subject: [PATCH 090/129] Excavator: Upgrade dependencies (#2606) --- versions.lock | 2 +- versions.props | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/versions.lock b/versions.lock index 5139f60b5..66f569a49 100644 --- a/versions.lock +++ b/versions.lock @@ -19,7 +19,7 @@ com.google.errorprone:error_prone_check_api:2.19.1 (2 constraints: bc255700) com.google.errorprone:error_prone_core:2.19.1 (1 constraints: 3f054b3b) com.google.errorprone:error_prone_type_annotations:2.19.1 (1 constraints: 2a115ec9) com.google.guava:failureaccess:1.0.1 (2 constraints: f1150513) -com.google.guava:guava:32.0.1-jre (15 constraints: 54f5627b) +com.google.guava:guava:32.1.0-jre (15 constraints: 54f5647b) com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava (1 constraints: bd17c918) com.google.inject:guice:5.1.0 (2 constraints: c21eb8b6) com.google.j2objc:j2objc-annotations:2.8 (1 constraints: be09f5a0) diff --git a/versions.props b/versions.props index ee677d6ea..5b79f5a4f 100644 --- a/versions.props +++ b/versions.props @@ -1,6 +1,6 @@ com.fasterxml.jackson.core:jackson-databind = 2.15.2 com.google.auto.service:auto-service = 1.1.1 -com.google.guava:guava = 32.0.1-jre +com.google.guava:guava = 32.1.0-jre com.palantir.safe-logging:* = 3.5.0 commons-lang:commons-lang = 2.6 org.apache.maven.shared:maven-dependency-analyzer = 1.13.2 From 1f34a77917dc3c12374bdbfda9284a51ac7180b2 Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Fri, 30 Jun 2023 10:48:27 -0700 Subject: [PATCH 091/129] Excavator: Upgrade dependencies (#2607) --- versions.lock | 2 +- versions.props | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/versions.lock b/versions.lock index 66f569a49..616ebb0e9 100644 --- a/versions.lock +++ b/versions.lock @@ -19,7 +19,7 @@ com.google.errorprone:error_prone_check_api:2.19.1 (2 constraints: bc255700) com.google.errorprone:error_prone_core:2.19.1 (1 constraints: 3f054b3b) com.google.errorprone:error_prone_type_annotations:2.19.1 (1 constraints: 2a115ec9) com.google.guava:failureaccess:1.0.1 (2 constraints: f1150513) -com.google.guava:guava:32.1.0-jre (15 constraints: 54f5647b) +com.google.guava:guava:32.1.1-jre (15 constraints: 55f5127e) com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava (1 constraints: bd17c918) com.google.inject:guice:5.1.0 (2 constraints: c21eb8b6) com.google.j2objc:j2objc-annotations:2.8 (1 constraints: be09f5a0) diff --git a/versions.props b/versions.props index 5b79f5a4f..6a5dbc1de 100644 --- a/versions.props +++ b/versions.props @@ -1,6 +1,6 @@ com.fasterxml.jackson.core:jackson-databind = 2.15.2 com.google.auto.service:auto-service = 1.1.1 -com.google.guava:guava = 32.1.0-jre +com.google.guava:guava = 32.1.1-jre com.palantir.safe-logging:* = 3.5.0 commons-lang:commons-lang = 2.6 org.apache.maven.shared:maven-dependency-analyzer = 1.13.2 From 80a8000570f84b2c6dbfea2a3b179792d9bb8953 Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Thu, 13 Jul 2023 01:43:22 -0700 Subject: [PATCH 092/129] Excavator: Update policy-bot config (#2609) --- .policy.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.policy.yml b/.policy.yml index d8f732c36..95c0afd59 100644 --- a/.policy.yml +++ b/.policy.yml @@ -48,20 +48,22 @@ approval_rules: permissions: ["admin", "maintain"] if: has_author_in: - users: [ "svc-excavator-bot" ] + users: [ "svc-excavator-bot", "dependabot[bot]" ] - name: excavator only touched baseline, circle, gradle files, godel files, generated code, go dependencies, docker-compose-rule config or versions.props requires: count: 0 if: has_author_in: - users: [ "svc-excavator-bot" ] + users: [ "svc-excavator-bot", "dependabot[bot]" ] only_changed_files: # product-dependencies.lock should never go here, to force review of all product (SLS) dependency changes # this way excavator cannot change the deployability of a service or product via auto-merge paths: - "changelog/@unreleased/.*\\.yml" - "^\\.baseline/.*$" + - "^(.+/)?Cargo.toml$" + - "^Cargo.lock$" - "^\\.circleci/.*$" - "^\\.docker-compose-rule\\.yml$" - "^.*gradle$" @@ -83,7 +85,7 @@ approval_rules: - "^internal/generated_src/.*" - "^gradle-baseline-java/src/main/resources/checkstyle.version$" has_valid_signatures_by_keys: - key_ids: ["C9AF124A484882E0"] + key_ids: ["C9AF124A484882E0", "4AEE18F83AFDEB23"] - name: excavator only touched config files requires: From ead7d6b653182db29c7c45c7baffc3115ccb55ec Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Mon, 17 Jul 2023 21:26:42 -0700 Subject: [PATCH 093/129] Excavator: Upgrade dependencies (#2610) --- versions.lock | 12 ++++++------ versions.props | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/versions.lock b/versions.lock index 616ebb0e9..51d7c6a78 100644 --- a/versions.lock +++ b/versions.lock @@ -94,12 +94,12 @@ com.palantir.conjure.java.api:errors:2.35.0 (2 constraints: 6e21c9b0) com.palantir.conjure.java.api:test-utils:2.35.0 (1 constraints: 3c05463b) com.palantir.conjure.java.runtime:conjure-java-annotations:7.58.0 (1 constraints: 4605753b) com.palantir.ri:resource-identifier:2.5.0 (1 constraints: ef0f7999) -com.palantir.safe-logging:logger:3.5.0 (2 constraints: df120437) -com.palantir.safe-logging:logger-slf4j:3.5.0 (1 constraints: 030e6242) -com.palantir.safe-logging:logger-spi:3.5.0 (2 constraints: 151e387b) -com.palantir.safe-logging:preconditions:3.5.0 (6 constraints: 215718bb) -com.palantir.safe-logging:preconditions-assertj:3.5.0 (1 constraints: 0a050936) -com.palantir.safe-logging:safe-logging:3.5.0 (8 constraints: 7377ade3) +com.palantir.safe-logging:logger:3.6.0 (2 constraints: e0122f37) +com.palantir.safe-logging:logger-slf4j:3.6.0 (1 constraints: 040e6542) +com.palantir.safe-logging:logger-spi:3.6.0 (2 constraints: 171e6d7b) +com.palantir.safe-logging:preconditions:3.6.0 (6 constraints: 23575dbc) +com.palantir.safe-logging:preconditions-assertj:3.6.0 (1 constraints: 0b050c36) +com.palantir.safe-logging:safe-logging:3.6.0 (8 constraints: 7877efe6) com.palantir.tokens:auth-tokens:3.18.0 (2 constraints: 601534db) com.palantir.tritium:tritium-registry:0.69.0 (1 constraints: 4105523b) io.dropwizard.metrics:metrics-core:4.2.19 (1 constraints: ca1055b6) diff --git a/versions.props b/versions.props index 6a5dbc1de..a9fefd119 100644 --- a/versions.props +++ b/versions.props @@ -1,7 +1,7 @@ com.fasterxml.jackson.core:jackson-databind = 2.15.2 com.google.auto.service:auto-service = 1.1.1 com.google.guava:guava = 32.1.1-jre -com.palantir.safe-logging:* = 3.5.0 +com.palantir.safe-logging:* = 3.6.0 commons-lang:commons-lang = 2.6 org.apache.maven.shared:maven-dependency-analyzer = 1.13.2 org.apache.maven:maven-core = 3.9.1 From 823192d1fe3021d23f3442827f4866f2c30afbba Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Fri, 21 Jul 2023 13:03:37 -0700 Subject: [PATCH 094/129] Excavator: Upgrade dependencies (#2611) --- versions.lock | 8 ++++---- versions.props | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/versions.lock b/versions.lock index 51d7c6a78..dfdd12ed3 100644 --- a/versions.lock +++ b/versions.lock @@ -19,7 +19,7 @@ com.google.errorprone:error_prone_check_api:2.19.1 (2 constraints: bc255700) com.google.errorprone:error_prone_core:2.19.1 (1 constraints: 3f054b3b) com.google.errorprone:error_prone_type_annotations:2.19.1 (1 constraints: 2a115ec9) com.google.guava:failureaccess:1.0.1 (2 constraints: f1150513) -com.google.guava:guava:32.1.1-jre (15 constraints: 55f5127e) +com.google.guava:guava:32.1.1-jre (15 constraints: 56f5687e) com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava (1 constraints: bd17c918) com.google.inject:guice:5.1.0 (2 constraints: c21eb8b6) com.google.j2objc:j2objc-annotations:2.8 (1 constraints: be09f5a0) @@ -97,11 +97,11 @@ com.palantir.ri:resource-identifier:2.5.0 (1 constraints: ef0f7999) com.palantir.safe-logging:logger:3.6.0 (2 constraints: e0122f37) com.palantir.safe-logging:logger-slf4j:3.6.0 (1 constraints: 040e6542) com.palantir.safe-logging:logger-spi:3.6.0 (2 constraints: 171e6d7b) -com.palantir.safe-logging:preconditions:3.6.0 (6 constraints: 23575dbc) +com.palantir.safe-logging:preconditions:3.6.0 (6 constraints: 245760bc) com.palantir.safe-logging:preconditions-assertj:3.6.0 (1 constraints: 0b050c36) -com.palantir.safe-logging:safe-logging:3.6.0 (8 constraints: 7877efe6) +com.palantir.safe-logging:safe-logging:3.6.0 (8 constraints: 7977f2e6) com.palantir.tokens:auth-tokens:3.18.0 (2 constraints: 601534db) -com.palantir.tritium:tritium-registry:0.69.0 (1 constraints: 4105523b) +com.palantir.tritium:tritium-registry:0.71.0 (1 constraints: 3a053e3b) io.dropwizard.metrics:metrics-core:4.2.19 (1 constraints: ca1055b6) io.r2dbc:r2dbc-spi:1.0.0.RELEASE (1 constraints: ea08e898) javax.ws.rs:javax.ws.rs-api:2.1.1 (1 constraints: ec0f6e99) diff --git a/versions.props b/versions.props index a9fefd119..e4e1bef58 100644 --- a/versions.props +++ b/versions.props @@ -24,7 +24,7 @@ com.palantir.conjure.java:* = 6.77.0 com.palantir.conjure.java.api:* = 2.35.0 com.palantir.conjure.java.runtime:* = 7.58.0 com.palantir.tokens:auth-tokens = 3.18.0 -com.palantir.tritium:* = 0.69.0 +com.palantir.tritium:* = 0.71.0 commons-io:* = 2.13.0 junit:junit = 4.13.2 net.lingala.zip4j:zip4j = 1.3.2 From c1a525c1775fd6a671a28745b3beec09736f7b19 Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Sun, 23 Jul 2023 08:34:48 -0700 Subject: [PATCH 095/129] Excavator: Upgrade dependencies (#2612) --- versions.lock | 18 +++++++++--------- versions.props | 6 +++--- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/versions.lock b/versions.lock index dfdd12ed3..6da5c18a7 100644 --- a/versions.lock +++ b/versions.lock @@ -118,18 +118,18 @@ org.hamcrest:hamcrest-core:2.2 (4 constraints: 2b2b359e) org.hamcrest:hamcrest-library:2.2 (1 constraints: fc138e38) org.jetbrains:annotations:24.0.1 (2 constraints: fc20bc6d) org.jooq:jooq:3.18.5 (1 constraints: 4305523b) -org.junit.jupiter:junit-jupiter:5.9.3 (1 constraints: 13052236) -org.junit.jupiter:junit-jupiter-api:5.9.3 (5 constraints: 685390c1) -org.junit.jupiter:junit-jupiter-engine:5.9.3 (1 constraints: 0e0ee33b) -org.junit.jupiter:junit-jupiter-migrationsupport:5.9.3 (1 constraints: 13052236) -org.junit.jupiter:junit-jupiter-params:5.9.3 (1 constraints: 0e0ee33b) -org.junit.platform:junit-platform-commons:1.9.3 (2 constraints: e120754b) -org.junit.platform:junit-platform-engine:1.9.3 (3 constraints: 642e7180) -org.junit.vintage:junit-vintage-engine:5.9.3 (1 constraints: 13052236) +org.junit.jupiter:junit-jupiter:5.10.0 (1 constraints: 3805413b) +org.junit.jupiter:junit-jupiter-api:5.10.0 (5 constraints: fc53e3ab) +org.junit.jupiter:junit-jupiter-engine:5.10.0 (1 constraints: 330efd49) +org.junit.jupiter:junit-jupiter-migrationsupport:5.10.0 (1 constraints: 3805413b) +org.junit.jupiter:junit-jupiter-params:5.10.0 (1 constraints: 330efd49) +org.junit.platform:junit-platform-commons:1.10.0 (2 constraints: 2b211983) +org.junit.platform:junit-platform-engine:1.10.0 (3 constraints: ae2e51c4) +org.junit.vintage:junit-vintage-engine:5.10.0 (1 constraints: 3805413b) org.mockito:mockito-core:5.4.0 (3 constraints: e9244afa) org.mockito:mockito-junit-jupiter:5.4.0 (1 constraints: 0b051036) org.objenesis:objenesis:3.3 (2 constraints: 9b17f557) -org.opentest4j:opentest4j:1.2.0 (2 constraints: cd205b49) +org.opentest4j:opentest4j:1.3.0 (2 constraints: cf209249) org.reactivestreams:reactive-streams:1.0.3 (1 constraints: ef07e77b) org.spockframework:spock-core:2.1-M2-groovy-3.0 (2 constraints: e622905a) org.spockframework:spock-junit4:2.1-M2-groovy-3.0 (1 constraints: 241154df) diff --git a/versions.props b/versions.props index e4e1bef58..2b4141031 100644 --- a/versions.props +++ b/versions.props @@ -33,9 +33,9 @@ one.util:streamex = 0.8.1 org.apache.commons:commons-lang3 = 3.12.0 org.assertj:assertj-core = 3.24.2 org.hamcrest:hamcrest-core = 2.2 -org.junit.jupiter:* = 5.9.3 -org.junit.vintage:* = 5.9.3 -org.junit.platform:* = 1.9.3 +org.junit.jupiter:* = 5.10.0 +org.junit.vintage:* = 5.10.0 +org.junit.platform:* = 1.10.0 org.mockito:* = 5.4.0 # dependency-upgrader:OFF From aae5041989536271d0df6eb510806645c3a22e73 Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Thu, 27 Jul 2023 07:24:34 -0700 Subject: [PATCH 096/129] Excavator: Update gradle-jdks infrastructure plugins (#2613) --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index ad7d20b38..9cb679b34 100644 --- a/build.gradle +++ b/build.gradle @@ -9,7 +9,7 @@ buildscript { dependencies { classpath 'com.palantir.jakartapackagealignment:jakarta-package-alignment:0.5.0' classpath 'com.palantir.gradle.jdks:gradle-jdks:0.32.0' - classpath 'com.palantir.gradle.jdkslatest:gradle-jdks-latest:0.8.0' + classpath 'com.palantir.gradle.jdkslatest:gradle-jdks-latest:0.9.0' classpath 'com.diffplug.gradle:goomph:3.32.1' classpath 'com.palantir.gradle.externalpublish:gradle-external-publish-plugin:1.12.0' classpath 'com.palantir.gradle.consistentversions:gradle-consistent-versions:2.13.0' From 69a2a1cd5ca22e01b5e360f1278cfb1389852bbc Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Thu, 27 Jul 2023 22:01:22 -0700 Subject: [PATCH 097/129] Excavator: Upgrade dependencies (#2614) --- versions.lock | 2 +- versions.props | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/versions.lock b/versions.lock index 6da5c18a7..91f5f44ca 100644 --- a/versions.lock +++ b/versions.lock @@ -37,7 +37,7 @@ io.github.java-diff-utils:java-diff-utils:4.0 (1 constraints: 811205f6) javax.annotation:javax.annotation-api:1.3.2 (2 constraints: cd204f35) javax.inject:javax.inject:1 (9 constraints: e5867a2e) net.ltgt.gradle:gradle-errorprone-plugin:3.1.0 (1 constraints: 0605fd35) -org.apache.commons:commons-lang3:3.12.0 (4 constraints: 04327fb1) +org.apache.commons:commons-lang3:3.13.0 (4 constraints: 053205b2) org.apache.maven:maven-artifact:3.9.1 (4 constraints: 153e4040) org.apache.maven:maven-builder-support:3.9.1 (3 constraints: 112c6464) org.apache.maven:maven-core:3.9.1 (2 constraints: a21989df) diff --git a/versions.props b/versions.props index 2b4141031..94bfae0a7 100644 --- a/versions.props +++ b/versions.props @@ -30,7 +30,7 @@ junit:junit = 4.13.2 net.lingala.zip4j:zip4j = 1.3.2 net.ltgt.gradle:gradle-errorprone-plugin = 3.1.0 one.util:streamex = 0.8.1 -org.apache.commons:commons-lang3 = 3.12.0 +org.apache.commons:commons-lang3 = 3.13.0 org.assertj:assertj-core = 3.24.2 org.hamcrest:hamcrest-core = 2.2 org.junit.jupiter:* = 5.10.0 From 02124bd5c73e8cc75597360967b8bc4aad6e8860 Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Sun, 30 Jul 2023 16:09:00 -0700 Subject: [PATCH 098/129] Excavator: Upgrade dependencies (#2617) --- gradle-baseline-java/src/main/resources/checkstyle.version | 2 +- versions.props | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle-baseline-java/src/main/resources/checkstyle.version b/gradle-baseline-java/src/main/resources/checkstyle.version index 56a0ac3a2..f2b729ffc 100644 --- a/gradle-baseline-java/src/main/resources/checkstyle.version +++ b/gradle-baseline-java/src/main/resources/checkstyle.version @@ -1 +1 @@ -10.12.1 \ No newline at end of file +10.12.2 \ No newline at end of file diff --git a/versions.props b/versions.props index 94bfae0a7..ac6f32289 100644 --- a/versions.props +++ b/versions.props @@ -12,7 +12,7 @@ org.immutables:* = 2.9.3 org.ow2.asm:asm = 9.5 com.google.errorprone:error_prone_* = 2.19.1 com.googlecode.java-diff-utils:diffutils = 1.3.0 -com.puppycrawl.tools:checkstyle = 10.12.1 +com.puppycrawl.tools:checkstyle = 10.12.2 com.palantir.gradle.utils:* = 0.1.0 com.uber.nullaway:nullaway = 0.10.11 From 5230156af2649cf9b39a1c2ec490c96290d976ed Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Mon, 31 Jul 2023 16:14:06 -0700 Subject: [PATCH 099/129] Excavator: Upgrade dependencies (#2618) --- versions.lock | 2 +- versions.props | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/versions.lock b/versions.lock index 91f5f44ca..98edbec87 100644 --- a/versions.lock +++ b/versions.lock @@ -19,7 +19,7 @@ com.google.errorprone:error_prone_check_api:2.19.1 (2 constraints: bc255700) com.google.errorprone:error_prone_core:2.19.1 (1 constraints: 3f054b3b) com.google.errorprone:error_prone_type_annotations:2.19.1 (1 constraints: 2a115ec9) com.google.guava:failureaccess:1.0.1 (2 constraints: f1150513) -com.google.guava:guava:32.1.1-jre (15 constraints: 56f5687e) +com.google.guava:guava:32.1.2-jre (15 constraints: 57f51681) com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava (1 constraints: bd17c918) com.google.inject:guice:5.1.0 (2 constraints: c21eb8b6) com.google.j2objc:j2objc-annotations:2.8 (1 constraints: be09f5a0) diff --git a/versions.props b/versions.props index ac6f32289..ffab15d7c 100644 --- a/versions.props +++ b/versions.props @@ -1,6 +1,6 @@ com.fasterxml.jackson.core:jackson-databind = 2.15.2 com.google.auto.service:auto-service = 1.1.1 -com.google.guava:guava = 32.1.1-jre +com.google.guava:guava = 32.1.2-jre com.palantir.safe-logging:* = 3.6.0 commons-lang:commons-lang = 2.6 org.apache.maven.shared:maven-dependency-analyzer = 1.13.2 From 8c28a5e00fdc30b2cae2cafcdca2698a6c3eb729 Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Wed, 2 Aug 2023 15:53:49 -0700 Subject: [PATCH 100/129] Excavator: Upgrade dependencies (#2619) --- versions.lock | 2 +- versions.props | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/versions.lock b/versions.lock index 98edbec87..8dbd522d5 100644 --- a/versions.lock +++ b/versions.lock @@ -30,7 +30,7 @@ com.googlecode.javaewah:JavaEWAH:1.1.12 (1 constraints: 750eee5e) com.palantir.gradle.utils:lazily-configured-mapping:0.1.0 (1 constraints: 0305ee35) com.palantir.javaformat:gradle-palantir-java-format:1.1.0 (1 constraints: 0405f335) com.palantir.javaformat:palantir-java-format-spi:1.1.0 (1 constraints: 711560be) -com.uber.nullaway:nullaway:0.10.11 (1 constraints: 65058940) +com.uber.nullaway:nullaway:0.10.12 (1 constraints: 66058a40) commons-io:commons-io:2.13.0 (1 constraints: be14ed98) commons-lang:commons-lang:2.6 (1 constraints: ac04232c) io.github.java-diff-utils:java-diff-utils:4.0 (1 constraints: 811205f6) diff --git a/versions.props b/versions.props index ffab15d7c..f33a2d397 100644 --- a/versions.props +++ b/versions.props @@ -14,7 +14,7 @@ com.google.errorprone:error_prone_* = 2.19.1 com.googlecode.java-diff-utils:diffutils = 1.3.0 com.puppycrawl.tools:checkstyle = 10.12.2 com.palantir.gradle.utils:* = 0.1.0 -com.uber.nullaway:nullaway = 0.10.11 +com.uber.nullaway:nullaway = 0.10.12 # test deps com.fasterxml.jackson.*:* = 2.15.2 From 345dfd7b1bed8a80b9faf20110e5d905e4c162ac Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Mon, 7 Aug 2023 09:15:59 -0700 Subject: [PATCH 101/129] Excavator: Update Caffeine Cache (#2621) --- versions.lock | 6 +++--- versions.props | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/versions.lock b/versions.lock index 8dbd522d5..bab5e04cc 100644 --- a/versions.lock +++ b/versions.lock @@ -6,7 +6,7 @@ com.diffplug.durian:durian-io:1.2.0 (1 constraints: 1313c62d) com.diffplug.spotless:spotless-lib:2.25.3 (2 constraints: f424dde6) com.diffplug.spotless:spotless-lib-extra:2.25.3 (1 constraints: 4c132341) com.diffplug.spotless:spotless-plugin-gradle:6.6.0 (1 constraints: 0e051b36) -com.github.ben-manes.caffeine:caffeine:3.0.5 (1 constraints: e312a21b) +com.github.ben-manes.caffeine:caffeine:3.1.6 (2 constraints: ee17f057) com.github.kevinstern:software-and-algorithms:1.0 (1 constraints: 7e12fcf5) com.google.auto:auto-common:1.2.1 (3 constraints: 73322261) com.google.auto.service:auto-service:1.1.1 (1 constraints: 0505f435) @@ -14,7 +14,7 @@ com.google.auto.service:auto-service-annotations:1.1.1 (2 constraints: 8a20341c) com.google.auto.value:auto-value-annotations:1.9 (3 constraints: 802d5ac8) com.google.code.findbugs:jsr305:3.0.2 (6 constraints: 66626968) com.google.errorprone:error_prone_annotation:2.19.1 (3 constraints: d338dff0) -com.google.errorprone:error_prone_annotations:2.19.1 (12 constraints: bbbdcfbe) +com.google.errorprone:error_prone_annotations:2.19.1 (12 constraints: c3bd77ce) com.google.errorprone:error_prone_check_api:2.19.1 (2 constraints: bc255700) com.google.errorprone:error_prone_core:2.19.1 (1 constraints: 3f054b3b) com.google.errorprone:error_prone_type_annotations:2.19.1 (1 constraints: 2a115ec9) @@ -55,7 +55,7 @@ org.apache.maven.resolver:maven-resolver-spi:1.9.7 (3 constraints: 6e306f6a) org.apache.maven.resolver:maven-resolver-util:1.9.7 (3 constraints: 6e306f6a) org.apache.maven.shared:maven-dependency-analyzer:1.13.2 (1 constraints: 3905343b) org.apache.maven.shared:maven-shared-utils:3.3.4 (1 constraints: e60b61f3) -org.checkerframework:checker-qual:3.33.0 (3 constraints: 0b25cb88) +org.checkerframework:checker-qual:3.33.0 (3 constraints: 0725c187) org.checkerframework:dataflow-errorprone:3.33.0 (4 constraints: 0a3e5c60) org.checkerframework:dataflow-nullaway:3.33.0 (2 constraints: 6a1198f1) org.codehaus.groovy:groovy:3.0.10 (3 constraints: e32879d6) diff --git a/versions.props b/versions.props index f33a2d397..f2ee0834b 100644 --- a/versions.props +++ b/versions.props @@ -1,4 +1,5 @@ com.fasterxml.jackson.core:jackson-databind = 2.15.2 +com.github.ben-manes.caffeine:caffeine = 3.1.6 com.google.auto.service:auto-service = 1.1.1 com.google.guava:guava = 32.1.2-jre com.palantir.safe-logging:* = 3.6.0 From 1ece0a9d5afaf2872b387128087f96c9c43c8049 Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Mon, 7 Aug 2023 09:38:07 -0700 Subject: [PATCH 102/129] Excavator: Upgrade dependencies (#2620) --- versions.lock | 6 +++--- versions.props | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/versions.lock b/versions.lock index bab5e04cc..739fd774c 100644 --- a/versions.lock +++ b/versions.lock @@ -19,7 +19,7 @@ com.google.errorprone:error_prone_check_api:2.19.1 (2 constraints: bc255700) com.google.errorprone:error_prone_core:2.19.1 (1 constraints: 3f054b3b) com.google.errorprone:error_prone_type_annotations:2.19.1 (1 constraints: 2a115ec9) com.google.guava:failureaccess:1.0.1 (2 constraints: f1150513) -com.google.guava:guava:32.1.2-jre (15 constraints: 57f51681) +com.google.guava:guava:32.1.2-jre (15 constraints: 58f56a81) com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava (1 constraints: bd17c918) com.google.inject:guice:5.1.0 (2 constraints: c21eb8b6) com.google.j2objc:j2objc-annotations:2.8 (1 constraints: be09f5a0) @@ -92,7 +92,7 @@ com.netflix.nebula:nebula-test:10.2.0 (1 constraints: 35052d3b) com.palantir.conjure.java:conjure-lib:6.77.0 (1 constraints: 4605743b) com.palantir.conjure.java.api:errors:2.35.0 (2 constraints: 6e21c9b0) com.palantir.conjure.java.api:test-utils:2.35.0 (1 constraints: 3c05463b) -com.palantir.conjure.java.runtime:conjure-java-annotations:7.58.0 (1 constraints: 4605753b) +com.palantir.conjure.java.runtime:conjure-java-annotations:7.60.0 (1 constraints: 3f05613b) com.palantir.ri:resource-identifier:2.5.0 (1 constraints: ef0f7999) com.palantir.safe-logging:logger:3.6.0 (2 constraints: e0122f37) com.palantir.safe-logging:logger-slf4j:3.6.0 (1 constraints: 040e6542) @@ -101,7 +101,7 @@ com.palantir.safe-logging:preconditions:3.6.0 (6 constraints: 245760bc) com.palantir.safe-logging:preconditions-assertj:3.6.0 (1 constraints: 0b050c36) com.palantir.safe-logging:safe-logging:3.6.0 (8 constraints: 7977f2e6) com.palantir.tokens:auth-tokens:3.18.0 (2 constraints: 601534db) -com.palantir.tritium:tritium-registry:0.71.0 (1 constraints: 3a053e3b) +com.palantir.tritium:tritium-registry:0.73.0 (1 constraints: 3c05443b) io.dropwizard.metrics:metrics-core:4.2.19 (1 constraints: ca1055b6) io.r2dbc:r2dbc-spi:1.0.0.RELEASE (1 constraints: ea08e898) javax.ws.rs:javax.ws.rs-api:2.1.1 (1 constraints: ec0f6e99) diff --git a/versions.props b/versions.props index f2ee0834b..63b18d091 100644 --- a/versions.props +++ b/versions.props @@ -23,9 +23,9 @@ com.github.stefanbirkner:system-rules = 1.19.0 com.netflix.nebula:nebula-test = 10.2.0 com.palantir.conjure.java:* = 6.77.0 com.palantir.conjure.java.api:* = 2.35.0 -com.palantir.conjure.java.runtime:* = 7.58.0 +com.palantir.conjure.java.runtime:* = 7.60.0 com.palantir.tokens:auth-tokens = 3.18.0 -com.palantir.tritium:* = 0.71.0 +com.palantir.tritium:* = 0.73.0 commons-io:* = 2.13.0 junit:junit = 4.13.2 net.lingala.zip4j:zip4j = 1.3.2 From 206c106cc7d379c1717e9d6489d5ec1d28a5f2e3 Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Mon, 7 Aug 2023 10:53:53 -0700 Subject: [PATCH 103/129] Excavator: Update gradle-jdks infrastructure plugins (#2622) --- build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 9cb679b34..7df0fa19e 100644 --- a/build.gradle +++ b/build.gradle @@ -8,8 +8,8 @@ buildscript { dependencies { classpath 'com.palantir.jakartapackagealignment:jakarta-package-alignment:0.5.0' - classpath 'com.palantir.gradle.jdks:gradle-jdks:0.32.0' - classpath 'com.palantir.gradle.jdkslatest:gradle-jdks-latest:0.9.0' + classpath 'com.palantir.gradle.jdks:gradle-jdks:0.33.0' + classpath 'com.palantir.gradle.jdkslatest:gradle-jdks-latest:0.10.0' classpath 'com.diffplug.gradle:goomph:3.32.1' classpath 'com.palantir.gradle.externalpublish:gradle-external-publish-plugin:1.12.0' classpath 'com.palantir.gradle.consistentversions:gradle-consistent-versions:2.13.0' From 77a63c4f53edd91d150dfef4dc3468aab3043e9d Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Thu, 10 Aug 2023 07:05:53 -0700 Subject: [PATCH 104/129] Excavator: Upgrade dependencies (#2623) --- versions.lock | 2 +- versions.props | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/versions.lock b/versions.lock index 739fd774c..74821b657 100644 --- a/versions.lock +++ b/versions.lock @@ -117,7 +117,7 @@ org.hamcrest:hamcrest:2.2 (2 constraints: 43187376) org.hamcrest:hamcrest-core:2.2 (4 constraints: 2b2b359e) org.hamcrest:hamcrest-library:2.2 (1 constraints: fc138e38) org.jetbrains:annotations:24.0.1 (2 constraints: fc20bc6d) -org.jooq:jooq:3.18.5 (1 constraints: 4305523b) +org.jooq:jooq:3.18.6 (1 constraints: 4405533b) org.junit.jupiter:junit-jupiter:5.10.0 (1 constraints: 3805413b) org.junit.jupiter:junit-jupiter-api:5.10.0 (5 constraints: fc53e3ab) org.junit.jupiter:junit-jupiter-engine:5.10.0 (1 constraints: 330efd49) diff --git a/versions.props b/versions.props index 63b18d091..c76fc74f0 100644 --- a/versions.props +++ b/versions.props @@ -7,7 +7,7 @@ commons-lang:commons-lang = 2.6 org.apache.maven.shared:maven-dependency-analyzer = 1.13.2 org.apache.maven:maven-core = 3.9.1 org.inferred:freebuilder = 1.14.6 -org.jooq:jooq = 3.18.5 +org.jooq:jooq = 3.18.6 org.slf4j:* = 1.7.36 org.immutables:* = 2.9.3 org.ow2.asm:asm = 9.5 From 914691994ac0f26a15cb02ad4826907c833739c7 Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Sun, 13 Aug 2023 06:45:02 -0700 Subject: [PATCH 105/129] Excavator: Upgrades Baseline to the latest version (#2625) --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 7df0fa19e..6b798b1c4 100644 --- a/build.gradle +++ b/build.gradle @@ -14,7 +14,7 @@ buildscript { classpath 'com.palantir.gradle.externalpublish:gradle-external-publish-plugin:1.12.0' classpath 'com.palantir.gradle.consistentversions:gradle-consistent-versions:2.13.0' classpath 'com.gradle.publish:plugin-publish-plugin:1.2.0' - classpath 'com.palantir.baseline:gradle-baseline-java:5.17.0' + classpath 'com.palantir.baseline:gradle-baseline-java:5.18.0' classpath 'com.palantir.javaformat:gradle-palantir-java-format:2.33.0' } } From e471cdc7b65182e5a7061238c20b9758049923c7 Mon Sep 17 00:00:00 2001 From: David Schlosnagle Date: Fri, 18 Aug 2023 09:24:04 -0400 Subject: [PATCH 106/129] Prefer InputStream.transferTo(OutputStream) (#2616) Prefer InputStream.transferTo(OutputStream) Add error-prone check to automate migration to prefer `InputStream.transferTo(OutputStream)` instead of utility methods such as Guava's `com.google.common.io.ByteStreams.copy(InputStream, OutputStream)`. Allow for optimization when underlying input stream (such as `ByteArrayInputStream`, `ChannelInputStream`) overrides `transferTo(OutputStream)` to avoid extra array allocations and copy larger chunks at a time (e.g. allowing 16KiB chunks via `ApacheHttpClientBlockingChannel.ModulatingOutputStream` from #1790). When running on JDK 21+, this also enables 16KiB byte chunk copies via `InputStream.transferTo(OutputStream)` per [JDK-8299336](https://bugs.openjdk.org/browse/JDK-8299336), where as on JDK < 21 and when using Guava `ByteStreams.copy` 8KiB byte chunk copies are used. References: * https://github.com/palantir/hadoop-crypto/pull/586 * https://bugs.openjdk.org/browse/JDK-8299336 * https://bugs.openjdk.org/browse/JDK-8067661 * https://bugs.openjdk.org/browse/JDK-8265891 * https://bugs.openjdk.org/browse/JDK-8273038 * https://bugs.openjdk.org/browse/JDK-8279283 * https://bugs.openjdk.org/browse/JDK-8296431 Closes https://github.com/palantir/gradle-baseline/issues/2615 --- README.md | 1 + baseline-error-prone/build.gradle | 1 + .../PreferInputStreamTransferTo.java | 123 ++++++++ .../PreferInputStreamTransferToTests.java | 294 ++++++++++++++++++ changelog/@unreleased/pr-2616.v2.yml | 25 ++ .../BaselineErrorProneExtension.java | 1 + versions.lock | 2 +- 7 files changed, 446 insertions(+), 1 deletion(-) create mode 100644 baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/PreferInputStreamTransferTo.java create mode 100644 baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/PreferInputStreamTransferToTests.java create mode 100644 changelog/@unreleased/pr-2616.v2.yml diff --git a/README.md b/README.md index 272513f6c..73625119b 100644 --- a/README.md +++ b/README.md @@ -228,6 +228,7 @@ Safe Logging can be found at [github.com/palantir/safe-logging](https://github.c - `DangerousCollapseKeysUsage`: Disallow usage of `EntryStream#collapseKeys()`. - `JooqBatchWithoutBindArgs`: jOOQ batch methods that execute without bind args can cause performance problems. - `InvocationTargetExceptionGetTargetException`: InvocationTargetException.getTargetException() predates the general-purpose exception chaining facility. The Throwable.getCause() method is now the preferred means of obtaining this information. [(source)](https://docs.oracle.com/en/java/javase/17/docs/api//java.base/java/lang/reflect/InvocationTargetException.html#getTargetException()) +- `PreferInputStreamTransferTo`: Prefer JDK `InputStream.transferTo(OutputStream)` over utility methods such as `com.google.common.io.ByteStreams.copy(InputStream, OutputStream)`, `org.apache.commons.io.IOUtils.copy(InputStream, OutputStream)`, `org.apache.commons.io.IOUtils.copyLong(InputStream, OutputStream)`. ### Programmatic Application diff --git a/baseline-error-prone/build.gradle b/baseline-error-prone/build.gradle index b82fb9ec4..eed42bc27 100644 --- a/baseline-error-prone/build.gradle +++ b/baseline-error-prone/build.gradle @@ -23,6 +23,7 @@ dependencies { testImplementation 'com.palantir.safe-logging:logger' testImplementation 'org.slf4j:slf4j-api' testImplementation 'org.apache.commons:commons-lang3' + testImplementation 'commons-io:commons-io' testImplementation 'commons-lang:commons-lang' testImplementation 'org.assertj:assertj-core' testImplementation 'org.immutables:value::annotations' diff --git a/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/PreferInputStreamTransferTo.java b/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/PreferInputStreamTransferTo.java new file mode 100644 index 000000000..095eff9d5 --- /dev/null +++ b/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/PreferInputStreamTransferTo.java @@ -0,0 +1,123 @@ +/* + * (c) Copyright 2019 Palantir Technologies Inc. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.palantir.baseline.errorprone; + +import com.google.auto.service.AutoService; +import com.google.errorprone.BugPattern; +import com.google.errorprone.BugPattern.SeverityLevel; +import com.google.errorprone.VisitorState; +import com.google.errorprone.bugpatterns.BugChecker; +import com.google.errorprone.fixes.SuggestedFix; +import com.google.errorprone.matchers.Description; +import com.google.errorprone.matchers.Matcher; +import com.google.errorprone.matchers.Matchers; +import com.google.errorprone.matchers.method.MethodMatchers; +import com.sun.source.tree.ExpressionTree; +import com.sun.source.tree.IdentifierTree; +import com.sun.source.tree.MethodInvocationTree; +import com.sun.source.tree.Tree; +import java.util.List; + +@AutoService(BugChecker.class) +@BugPattern( + link = "https://github.com/palantir/gradle-baseline#baseline-error-prone-checks", + linkType = BugPattern.LinkType.CUSTOM, + severity = SeverityLevel.WARNING, + summary = "Prefer JDK `InputStream.transferTo(OutputStream)` over utility methods such as " + + "`com.google.common.io.ByteStreams.copy(InputStream, OutputStream)`, " + + "`org.apache.commons.io.IOUtils.copy(InputStream, OutputStream)`, " + + "`org.apache.commons.io.IOUtils.copyLong(InputStream, OutputStream)` " + + "see: https://github.com/palantir/gradle-baseline/issues/2615 ", + explanation = "Allow for optimization when underlying input stream (such as `ByteArrayInputStream`," + + " `ChannelInputStream`) overrides `long transferTo(OutputStream)` to avoid extra array allocations and" + + " copy larger chunks at a time (e.g. allowing 16KiB chunks via" + + " `ApacheHttpClientBlockingChannel.ModulatingOutputStream` from #1790).\n\n" + + "When running on JDK 21+, this also enables 16KiB byte chunk copies via" + + " `InputStream.transferTo(OutputStream)` per [JDK-8299336](https://bugs.openjdk.org/browse/JDK-8299336)," + + " where as on JDK < 21 and when using Guava `ByteStreams.copy` 8KiB byte chunk copies are used. \n\n" + + "References:\n\n" + + " * https://github.com/palantir/hadoop-crypto/pull/586\n" + + " * https://bugs.openjdk.org/browse/JDK-8299336\n" + + " * https://bugs.openjdk.org/browse/JDK-8067661\n" + + " * https://bugs.openjdk.org/browse/JDK-8265891\n" + + " * https://bugs.openjdk.org/browse/JDK-8273038\n" + + " * https://bugs.openjdk.org/browse/JDK-8279283\n" + + " * https://bugs.openjdk.org/browse/JDK-8296431\n") +public final class PreferInputStreamTransferTo extends BugChecker implements BugChecker.MethodInvocationTreeMatcher { + + private static final long serialVersionUID = 1L; + + private static final String ERROR_MESSAGE = "Prefer InputStream.transferTo(OutputStream)"; + + public static final String INPUT_STREAM = "java.io.InputStream"; + private static final Matcher INPUT_STREAM_MATCHER = MoreMatchers.isSubtypeOf(INPUT_STREAM); + public static final String OUTPUT_STREAM = "java.io.OutputStream"; + private static final Matcher OUTPUT_STREAM_MATCHER = MoreMatchers.isSubtypeOf(OUTPUT_STREAM); + + private static final Matcher GUAVA_BYTE_STREAM_COPY_MATCHER = MethodMatchers.staticMethod() + .onClass("com.google.common.io.ByteStreams") + .namedAnyOf("copy") + .withParameters(INPUT_STREAM, OUTPUT_STREAM); + private static final Matcher APACHE_COMMONS_BYTE_STREAM_COPY_MATCHER = MethodMatchers.staticMethod() + .onClass("org.apache.commons.io.IOUtils") + .namedAnyOf("copy", "copyLarge") + .withParameters(INPUT_STREAM, OUTPUT_STREAM); + private static final Matcher AWS_BYTE_STREAM_COPY_MATCHER = MethodMatchers.staticMethod() + .onClass("com.amazonaws.util.IOUtils") + .namedAnyOf("copy") + .withParameters(INPUT_STREAM, OUTPUT_STREAM); + + private static final Matcher METHOD_MATCHER = Matchers.anyOf( + GUAVA_BYTE_STREAM_COPY_MATCHER, APACHE_COMMONS_BYTE_STREAM_COPY_MATCHER, AWS_BYTE_STREAM_COPY_MATCHER); + + @Override + public Description matchMethodInvocation(MethodInvocationTree tree, VisitorState state) { + if (METHOD_MATCHER.matches(tree, state)) { + List args = tree.getArguments(); + if (args.size() != 2) { + return Description.NO_MATCH; + } + + ExpressionTree maybeInputStreamArg = args.get(0); + ExpressionTree maybeOutputStreamArg = args.get(1); + if (INPUT_STREAM_MATCHER.matches(maybeInputStreamArg, state) + && OUTPUT_STREAM_MATCHER.matches(maybeOutputStreamArg, state)) { + String inputStreamArg = state.getSourceForNode(maybeInputStreamArg); + String outputStreamArg = state.getSourceForNode(maybeOutputStreamArg); + if (inputStreamArg == null || outputStreamArg == null) { + return Description.NO_MATCH; + } + + // Avoid possible infinite recursion replacing with `this.transferTo(outputStream)` + if (maybeInputStreamArg instanceof IdentifierTree + && ((IdentifierTree) maybeInputStreamArg).getName().contentEquals("this")) { + inputStreamArg = "super"; + } + + String replacement = inputStreamArg + ".transferTo(" + outputStreamArg + ")"; + SuggestedFix fix = + SuggestedFix.builder().replace(tree, replacement).build(); + return buildDescription(tree) + .setMessage(ERROR_MESSAGE) + .addFix(fix) + .build(); + } + } + + return Description.NO_MATCH; + } +} diff --git a/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/PreferInputStreamTransferToTests.java b/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/PreferInputStreamTransferToTests.java new file mode 100644 index 000000000..e536d9e16 --- /dev/null +++ b/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/PreferInputStreamTransferToTests.java @@ -0,0 +1,294 @@ +/* + * (c) Copyright 2019 Palantir Technologies Inc. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.palantir.baseline.errorprone; + +import com.google.errorprone.BugCheckerRefactoringTestHelper; +import com.google.errorprone.CompilationTestHelper; +import org.junit.jupiter.api.Test; + +public final class PreferInputStreamTransferToTests { + + @Test + public void should_not_use_Guava_ByteStreams_copy() { + CompilationTestHelper.newInstance(PreferInputStreamTransferTo.class, getClass()) + .addSourceLines( + "Test.java", + "import java.io.InputStream;", + "import java.io.OutputStream;", + "class Test {", + " long f() throws java.io.IOException {", + " // BUG: Diagnostic contains: Prefer InputStream.transferTo(OutputStream)", + " return com.google.common.io.ByteStreams.copy" + + "(InputStream.nullInputStream(), OutputStream.nullOutputStream());", + " }", + "}") + .doTest(); + + CompilationTestHelper.newInstance(PreferInputStreamTransferTo.class, getClass()) + .addSourceLines( + "Test.java", + "import java.io.InputStream;", + "import java.io.OutputStream;", + "class Test extends InputStream {", + " @Override", + " public long transferTo(OutputStream output) throws java.io.IOException {", + " // BUG: Diagnostic contains: Prefer InputStream.transferTo(OutputStream)", + " return com.google.common.io.ByteStreams.copy(this, output);", + " }", + "", + " @Override", + " public int read() throws java.io.IOException {", + " return -1;", + " }", + "}") + .doTest(); + } + + @Test + public void may_use_InputStream_transferTo_OutputStream() { + CompilationTestHelper.newInstance(PreferInputStreamTransferTo.class, getClass()) + .addSourceLines( + "Test.java", + "import java.io.InputStream;", + "import java.io.OutputStream;", + "class Test {", + " long f() throws java.io.IOException {", + " return InputStream.nullInputStream().transferTo(OutputStream.nullOutputStream());", + " }", + "}") + .doTest(); + } + + @Test + public void auto_fix_Guava_ByteStreams_copy_input_vars() { + RefactoringValidator.of(PreferInputStreamTransferTo.class, getClass()) + .addInputLines( + "Test.java", + "import java.io.InputStream;", + "import java.io.OutputStream;", + "class Test {", + " long f() throws java.io.IOException {", + " InputStream in = InputStream.nullInputStream();", + " OutputStream out = OutputStream.nullOutputStream();", + " return com.google.common.io.ByteStreams.copy(in, out);", + " }", + "}") + .addOutputLines( + "Test.java", + "import java.io.InputStream;", + "import java.io.OutputStream;", + "class Test {", + " long f() throws java.io.IOException {", + " InputStream in = InputStream.nullInputStream();", + " OutputStream out = OutputStream.nullOutputStream();", + " return in.transferTo(out);", + " }", + "}") + .doTest(BugCheckerRefactoringTestHelper.TestMode.TEXT_MATCH); + } + + @Test + public void auto_fix_Guava_ByteStreams_copy_input_methods() { + RefactoringValidator.of(PreferInputStreamTransferTo.class, getClass()) + .addInputLines( + "Test.java", + "import java.io.InputStream;", + "import java.io.OutputStream;", + "class Test {", + " long f() throws java.io.IOException {", + " return com.google.common.io.ByteStreams.copy" + + "(InputStream.nullInputStream(), OutputStream.nullOutputStream());", + " }", + "}") + .addOutputLines( + "Test.java", + "import java.io.InputStream;", + "import java.io.OutputStream;", + "class Test {", + " long f() throws java.io.IOException {", + " return InputStream.nullInputStream().transferTo(OutputStream.nullOutputStream());", + " }", + "}") + .doTest(BugCheckerRefactoringTestHelper.TestMode.TEXT_MATCH); + } + + @Test + public void auto_fix_Guava_ByteStreams_copy_stream_implements_transferTo() { + RefactoringValidator.of(PreferInputStreamTransferTo.class, getClass()) + .addInputLines( + "Test.java", + "import java.io.InputStream;", + "import java.io.OutputStream;", + "class Test extends InputStream {", + " @Override", + " public long transferTo(OutputStream output) throws java.io.IOException {", + " return com.google.common.io.ByteStreams.copy(this, output);", + " }", + "", + " @Override", + " public int read() throws java.io.IOException {", + " return -1;", + " }", + "}") + .addOutputLines( + "Test.java", + "import java.io.InputStream;", + "import java.io.OutputStream;", + "class Test extends InputStream {", + " @Override", + " public long transferTo(OutputStream output) throws java.io.IOException {", + " return super.transferTo(output);", + " }", + "", + " @Override", + " public int read() throws java.io.IOException {", + " return -1;", + " }", + "}") + .doTest(BugCheckerRefactoringTestHelper.TestMode.TEXT_MATCH); + } + + @Test + public void auto_fix_Guava_ByteStreams_copy_stream_transferTo_delegates() { + RefactoringValidator.of(PreferInputStreamTransferTo.class, getClass()) + .addInputLines( + "Test.java", + "import java.io.InputStream;", + "import java.io.OutputStream;", + "class Test extends InputStream {", + " @Override", + " public long transferTo(OutputStream output) throws java.io.IOException {", + " return com.google.common.io.ByteStreams.copy(this.delegate(), output);", + " }", + "", + " @Override", + " public int read() throws java.io.IOException {", + " return -1;", + " }", + "", + " InputStream delegate() {", + " return InputStream.nullInputStream();", + " }", + "}") + .addOutputLines( + "Test.java", + "import java.io.InputStream;", + "import java.io.OutputStream;", + "class Test extends InputStream {", + " @Override", + " public long transferTo(OutputStream output) throws java.io.IOException {", + " return this.delegate().transferTo(output);", + " }", + "", + " @Override", + " public int read() throws java.io.IOException {", + " return -1;", + " }", + "", + " InputStream delegate() {", + " return InputStream.nullInputStream();", + " }", + "}") + .doTest(BugCheckerRefactoringTestHelper.TestMode.TEXT_MATCH); + } + + @Test + public void auto_fix_Apache_copy() { + RefactoringValidator.of(PreferInputStreamTransferTo.class, getClass()) + .addInputLines( + "Test.java", + "import java.io.InputStream;", + "import java.io.OutputStream;", + "class Test {", + " long f() throws java.io.IOException {", + " InputStream in = InputStream.nullInputStream();", + " OutputStream out = OutputStream.nullOutputStream();", + " return org.apache.commons.io.IOUtils.copy(in, out);", + " }", + "}") + .addOutputLines( + "Test.java", + "import java.io.InputStream;", + "import java.io.OutputStream;", + "class Test {", + " long f() throws java.io.IOException {", + " InputStream in = InputStream.nullInputStream();", + " OutputStream out = OutputStream.nullOutputStream();", + " return in.transferTo(out);", + " }", + "}") + .doTest(BugCheckerRefactoringTestHelper.TestMode.TEXT_MATCH); + + RefactoringValidator.of(PreferInputStreamTransferTo.class, getClass()) + .addInputLines( + "Test.java", + "import java.io.InputStream;", + "import java.io.OutputStream;", + "class Test {", + " long f() throws java.io.IOException {", + " InputStream in = InputStream.nullInputStream();", + " OutputStream out = OutputStream.nullOutputStream();", + " return org.apache.commons.io.IOUtils.copyLarge(in, out);", + " }", + "}") + .addOutputLines( + "Test.java", + "import java.io.InputStream;", + "import java.io.OutputStream;", + "class Test {", + " long f() throws java.io.IOException {", + " InputStream in = InputStream.nullInputStream();", + " OutputStream out = OutputStream.nullOutputStream();", + " return in.transferTo(out);", + " }", + "}") + .doTest(BugCheckerRefactoringTestHelper.TestMode.TEXT_MATCH); + + RefactoringValidator.of(PreferInputStreamTransferTo.class, getClass()) + .addInputLines( + "Test.java", + "import java.io.InputStream;", + "import java.io.OutputStream;", + "class Test extends InputStream {", + " @Override", + " public long transferTo(OutputStream output) throws java.io.IOException {", + " return org.apache.commons.io.IOUtils.copyLarge(this, output);", + " }", + "", + " @Override", + " public int read() throws java.io.IOException {", + " return -1;", + " }", + "}") + .addOutputLines( + "Test.java", + "import java.io.InputStream;", + "import java.io.OutputStream;", + "class Test extends InputStream {", + " @Override", + " public long transferTo(OutputStream output) throws java.io.IOException {", + " return super.transferTo(output);", + " }", + "", + " @Override", + " public int read() throws java.io.IOException {", + " return -1;", + " }", + "}") + .doTest(BugCheckerRefactoringTestHelper.TestMode.TEXT_MATCH); + } +} diff --git a/changelog/@unreleased/pr-2616.v2.yml b/changelog/@unreleased/pr-2616.v2.yml new file mode 100644 index 000000000..0ad2bf1ce --- /dev/null +++ b/changelog/@unreleased/pr-2616.v2.yml @@ -0,0 +1,25 @@ +type: improvement +improvement: + description: |- + Prefer `InputStream.transferTo(OutputStream)` + + Add error-prone check to automate migration to prefer `InputStream.transferTo(OutputStream)` instead of utility methods such as Guava's `com.google.common.io.ByteStreams.copy(InputStream, OutputStream)`. + + Allow for optimization when underlying input stream (such as `ByteArrayInputStream`, `ChannelInputStream`) overrides `transferTo(OutputStream)` to avoid extra array allocations and copy larger chunks at a time (e.g. allowing 16KiB chunks via `ApacheHttpClientBlockingChannel.ModulatingOutputStream` from #1790). + + When running on JDK 21+, this also enables 16KiB byte chunk copies via `InputStream.transferTo(OutputStream)` per + [JDK-8299336](https://bugs.openjdk.org/browse/JDK-8299336), where as on JDK < 21 and when using Guava `ByteStreams.copy` 8KiB byte chunk copies are used. + + References: + * https://github.com/palantir/hadoop-crypto/pull/586 + * https://bugs.openjdk.org/browse/JDK-8299336 + * https://bugs.openjdk.org/browse/JDK-8067661 + * https://bugs.openjdk.org/browse/JDK-8265891 + * https://bugs.openjdk.org/browse/JDK-8273038 + * https://bugs.openjdk.org/browse/JDK-8279283 + * https://bugs.openjdk.org/browse/JDK-8296431 + + Closes https://github.com/palantir/gradle-baseline/issues/2615 + links: + - https://github.com/palantir/gradle-baseline/pull/2615 + - https://github.com/palantir/gradle-baseline/pull/2616 diff --git a/gradle-baseline-java/src/main/groovy/com/palantir/baseline/extensions/BaselineErrorProneExtension.java b/gradle-baseline-java/src/main/groovy/com/palantir/baseline/extensions/BaselineErrorProneExtension.java index db0b0cbb5..6f30c8755 100644 --- a/gradle-baseline-java/src/main/groovy/com/palantir/baseline/extensions/BaselineErrorProneExtension.java +++ b/gradle-baseline-java/src/main/groovy/com/palantir/baseline/extensions/BaselineErrorProneExtension.java @@ -57,6 +57,7 @@ public class BaselineErrorProneExtension { "PreferBuiltInConcurrentKeySet", "PreferCollectionConstructors", "PreferCollectionTransform", + "PreferInputStreamTransferTo", "PreferListsPartition", "PreferSafeLoggableExceptions", "PreferSafeLogger", diff --git a/versions.lock b/versions.lock index 74821b657..56287a4d3 100644 --- a/versions.lock +++ b/versions.lock @@ -31,7 +31,7 @@ com.palantir.gradle.utils:lazily-configured-mapping:0.1.0 (1 constraints: 0305ee com.palantir.javaformat:gradle-palantir-java-format:1.1.0 (1 constraints: 0405f335) com.palantir.javaformat:palantir-java-format-spi:1.1.0 (1 constraints: 711560be) com.uber.nullaway:nullaway:0.10.12 (1 constraints: 66058a40) -commons-io:commons-io:2.13.0 (1 constraints: be14ed98) +commons-io:commons-io:2.13.0 (2 constraints: f519f007) commons-lang:commons-lang:2.6 (1 constraints: ac04232c) io.github.java-diff-utils:java-diff-utils:4.0 (1 constraints: 811205f6) javax.annotation:javax.annotation-api:1.3.2 (2 constraints: cd204f35) From 16be1b5edc15e68ca5c87537e7b185b809153c70 Mon Sep 17 00:00:00 2001 From: svc-autorelease Date: Fri, 18 Aug 2023 13:24:13 +0000 Subject: [PATCH 107/129] Autorelease 5.19.0 [skip ci] --- changelog/{@unreleased => 5.19.0}/pr-2616.v2.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename changelog/{@unreleased => 5.19.0}/pr-2616.v2.yml (100%) diff --git a/changelog/@unreleased/pr-2616.v2.yml b/changelog/5.19.0/pr-2616.v2.yml similarity index 100% rename from changelog/@unreleased/pr-2616.v2.yml rename to changelog/5.19.0/pr-2616.v2.yml From ea1f8724fe08b56f911f1168d79281a9b004bb22 Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Fri, 18 Aug 2023 08:35:13 -0700 Subject: [PATCH 108/129] Excavator: Upgrades Baseline to the latest version (#2626) --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 6b798b1c4..5f9b559b8 100644 --- a/build.gradle +++ b/build.gradle @@ -14,7 +14,7 @@ buildscript { classpath 'com.palantir.gradle.externalpublish:gradle-external-publish-plugin:1.12.0' classpath 'com.palantir.gradle.consistentversions:gradle-consistent-versions:2.13.0' classpath 'com.gradle.publish:plugin-publish-plugin:1.2.0' - classpath 'com.palantir.baseline:gradle-baseline-java:5.18.0' + classpath 'com.palantir.baseline:gradle-baseline-java:5.19.0' classpath 'com.palantir.javaformat:gradle-palantir-java-format:2.33.0' } } From 617d2059d7906d7b777f16a21e3c9f8fb0321433 Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Sat, 19 Aug 2023 23:27:33 -0700 Subject: [PATCH 109/129] Excavator: Update open-source publishing plugins (#2627) --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 5f9b559b8..868b02a47 100644 --- a/build.gradle +++ b/build.gradle @@ -13,7 +13,7 @@ buildscript { classpath 'com.diffplug.gradle:goomph:3.32.1' classpath 'com.palantir.gradle.externalpublish:gradle-external-publish-plugin:1.12.0' classpath 'com.palantir.gradle.consistentversions:gradle-consistent-versions:2.13.0' - classpath 'com.gradle.publish:plugin-publish-plugin:1.2.0' + classpath 'com.gradle.publish:plugin-publish-plugin:1.2.1' classpath 'com.palantir.baseline:gradle-baseline-java:5.19.0' classpath 'com.palantir.javaformat:gradle-palantir-java-format:2.33.0' } From 390207dd974667e813df51c7154464f36a995c79 Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Mon, 28 Aug 2023 00:07:25 -0700 Subject: [PATCH 110/129] Excavator: Upgrade buildscript dependencies (#2630) --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 868b02a47..683f05a37 100644 --- a/build.gradle +++ b/build.gradle @@ -12,7 +12,7 @@ buildscript { classpath 'com.palantir.gradle.jdkslatest:gradle-jdks-latest:0.10.0' classpath 'com.diffplug.gradle:goomph:3.32.1' classpath 'com.palantir.gradle.externalpublish:gradle-external-publish-plugin:1.12.0' - classpath 'com.palantir.gradle.consistentversions:gradle-consistent-versions:2.13.0' + classpath 'com.palantir.gradle.consistentversions:gradle-consistent-versions:2.15.0' classpath 'com.gradle.publish:plugin-publish-plugin:1.2.1' classpath 'com.palantir.baseline:gradle-baseline-java:5.19.0' classpath 'com.palantir.javaformat:gradle-palantir-java-format:2.33.0' From 8ef943863e5ebbb2d90023d9d12b0d0a670de040 Mon Sep 17 00:00:00 2001 From: David Schlosnagle Date: Mon, 28 Aug 2023 08:34:26 -0400 Subject: [PATCH 111/129] Fix junit5 excavator --- gradle-junit-reports/build.gradle | 2 ++ .../com/palantir/gradle/junit/CheckstyleReportHandler.java | 3 ++- versions.lock | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/gradle-junit-reports/build.gradle b/gradle-junit-reports/build.gradle index 0af1e9190..9d04c6b3d 100644 --- a/gradle-junit-reports/build.gradle +++ b/gradle-junit-reports/build.gradle @@ -11,6 +11,8 @@ dependencies { compileOnly 'org.immutables:value::annotations' compileOnly 'org.inferred:freebuilder' + implementation 'com.palantir.safe-logging:safe-logging' + testImplementation 'com.google.guava:guava' testImplementation 'com.netflix.nebula:nebula-test' testImplementation 'org.assertj:assertj-core' diff --git a/gradle-junit-reports/src/main/java/com/palantir/gradle/junit/CheckstyleReportHandler.java b/gradle-junit-reports/src/main/java/com/palantir/gradle/junit/CheckstyleReportHandler.java index 7978aa7c9..00ff473a6 100644 --- a/gradle-junit-reports/src/main/java/com/palantir/gradle/junit/CheckstyleReportHandler.java +++ b/gradle-junit-reports/src/main/java/com/palantir/gradle/junit/CheckstyleReportHandler.java @@ -18,6 +18,7 @@ import java.io.File; import java.util.ArrayList; import java.util.List; +import java.util.Locale; import org.gradle.api.plugins.quality.Checkstyle; import org.xml.sax.Attributes; @@ -43,7 +44,7 @@ public void startElement(String uri, String localName, String qName, Attributes case "error": failures.add(Failure.builder() .source(attributes.getValue("source")) - .severity(attributes.getValue("severity").toUpperCase()) + .severity(attributes.getValue("severity").toUpperCase(Locale.ROOT)) .file(file) .line(Integer.parseInt(attributes.getValue("line"))) .message(attributes.getValue("message")) diff --git a/versions.lock b/versions.lock index d4b00fca6..bf9d9f604 100644 --- a/versions.lock +++ b/versions.lock @@ -30,6 +30,7 @@ com.googlecode.javaewah:JavaEWAH:1.1.12 (1 constraints: 750eee5e) com.palantir.gradle.utils:lazily-configured-mapping:0.1.0 (1 constraints: 0305ee35) com.palantir.javaformat:gradle-palantir-java-format:1.1.0 (1 constraints: 0405f335) com.palantir.javaformat:palantir-java-format-spi:1.1.0 (1 constraints: 711560be) +com.palantir.safe-logging:safe-logging:3.2.0 (8 constraints: 5f77a6d7) com.uber.nullaway:nullaway:0.10.10 (1 constraints: 64058840) commons-io:commons-io:2.11.0 (1 constraints: 57119bcb) commons-lang:commons-lang:2.6 (1 constraints: ac04232c) @@ -98,7 +99,6 @@ com.palantir.safe-logging:logger-slf4j:3.2.0 (1 constraints: 000e5942) com.palantir.safe-logging:logger-spi:3.2.0 (2 constraints: 0f1e997a) com.palantir.safe-logging:preconditions:3.2.0 (6 constraints: 1457bcb5) com.palantir.safe-logging:preconditions-assertj:3.2.0 (1 constraints: 07050036) -com.palantir.safe-logging:safe-logging:3.2.0 (8 constraints: 5f77a6d7) com.palantir.tokens:auth-tokens:3.17.0 (2 constraints: 5f1502db) com.palantir.tritium:tritium-registry:0.62.0 (1 constraints: 3a053d3b) io.dropwizard.metrics:metrics-core:4.1.1 (1 constraints: 901088a5) From f265e1caccc8d67dbebc73586a6e849dbcd87d97 Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Tue, 29 Aug 2023 14:17:32 -0700 Subject: [PATCH 112/129] Excavator: Update gradle-jdks infrastructure plugins (#2632) --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 683f05a37..5aa95e413 100644 --- a/build.gradle +++ b/build.gradle @@ -9,7 +9,7 @@ buildscript { dependencies { classpath 'com.palantir.jakartapackagealignment:jakarta-package-alignment:0.5.0' classpath 'com.palantir.gradle.jdks:gradle-jdks:0.33.0' - classpath 'com.palantir.gradle.jdkslatest:gradle-jdks-latest:0.10.0' + classpath 'com.palantir.gradle.jdkslatest:gradle-jdks-latest:0.11.0' classpath 'com.diffplug.gradle:goomph:3.32.1' classpath 'com.palantir.gradle.externalpublish:gradle-external-publish-plugin:1.12.0' classpath 'com.palantir.gradle.consistentversions:gradle-consistent-versions:2.15.0' From 41af8c761be604bfa2c099fd56db49b1caeb37ab Mon Sep 17 00:00:00 2001 From: Carter Kozak Date: Tue, 29 Aug 2023 17:41:03 -0400 Subject: [PATCH 113/129] Improve SafeLoggingPropagation on Immutables (#2629) Improve SafeLoggingPropagation on Immutables, taking into account fields from superinterfaces --- .../errorprone/SafeLoggingPropagation.java | 102 +++++++++++------- .../errorprone/safety/SafetyAnnotations.java | 19 ++++ .../SafeLoggingPropagationTest.java | 64 +++++++++++ changelog/@unreleased/pr-2629.v2.yml | 6 ++ .../BaselineErrorProneExtension.java | 1 + 5 files changed, 152 insertions(+), 40 deletions(-) create mode 100644 changelog/@unreleased/pr-2629.v2.yml diff --git a/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/SafeLoggingPropagation.java b/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/SafeLoggingPropagation.java index 4edbce4a9..396624f99 100644 --- a/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/SafeLoggingPropagation.java +++ b/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/SafeLoggingPropagation.java @@ -49,6 +49,7 @@ import com.sun.tools.javac.code.Symbol.MethodSymbol; import com.sun.tools.javac.code.Symbol.TypeSymbol; import com.sun.tools.javac.code.Symbol.VarSymbol; +import com.sun.tools.javac.code.Type; import com.sun.tools.javac.util.Name; import java.util.List; import javax.lang.model.element.Modifier; @@ -76,28 +77,6 @@ public final class SafeLoggingPropagation extends BugChecker Matchers.not(Matchers.isStatic()), Matchers.methodReturns(Matchers.isSameType(String.class))); private static final Matcher METHOD_RETURNS_VOID = Matchers.methodReturns(Matchers.isVoidType()); - private static final Matcher NON_STATIC_NON_CTOR = - Matchers.not(Matchers.anyOf(Matchers.hasModifier(Modifier.STATIC), Matchers.methodIsConstructor())); - - private static final Matcher IS_IMMUTABLES_FIELD = Matchers.anyOf( - Matchers.hasModifier(Modifier.ABSTRACT), - Matchers.symbolHasAnnotation("org.immutables.value.Value.Default"), - Matchers.symbolHasAnnotation("org.immutables.value.Value.Derived"), - Matchers.symbolHasAnnotation("org.immutables.value.Value.Lazy"), - Matchers.allOf(Matchers.hasModifier(Modifier.DEFAULT), Matchers.enclosingClass((Matcher) - (classTree, state) -> { - ClassSymbol classSymbol = ASTHelpers.getSymbol(classTree); - return classSymbol != null && immutablesDefaultAsDefault(classSymbol, state); - })), - (methodTree, state) -> hasJacksonAnnotation(ASTHelpers.getSymbol(methodTree), state)); - private static final Matcher GETTER_METHOD_MATCHER = Matchers.anyOf( - Matchers.allOf( - NON_STATIC_NON_CTOR, - Matchers.not(METHOD_RETURNS_VOID), - Matchers.methodHasNoParameters(), - IS_IMMUTABLES_FIELD), - // Always include toString safety - TO_STRING); private static final com.google.errorprone.suppliers.Supplier TO_STRING_NAME = VisitorState.memoize(state -> state.getName("toString")); @@ -195,43 +174,86 @@ private Description matchClassOrInterface(ClassTree classTree, ClassSymbol class return matchBasedOnToString(classTree, classSymbol, state); } + private static boolean isImmutablesField( + ClassSymbol enclosingClass, MethodSymbol methodSymbol, VisitorState state) { + return methodSymbol.getModifiers().contains(Modifier.ABSTRACT) + || ASTHelpers.hasAnnotation(methodSymbol, "org.immutables.value.Value.Default", state) + || ASTHelpers.hasAnnotation(methodSymbol, "org.immutables.value.Value.Derived", state) + || ASTHelpers.hasAnnotation(methodSymbol, "org.immutables.value.Value.Lazy", state) + || immutablesDefaultAsDefault(enclosingClass, state) + || hasJacksonAnnotation(methodSymbol, state); + } + + private static boolean isToString(MethodSymbol methodSymbol, VisitorState state) { + return !methodSymbol.isConstructor() + && !methodSymbol.isStaticOrInstanceInit() + && state.getTypes().isSameType(methodSymbol.getReturnType(), state.getSymtab().stringType) + && methodSymbol.name.contentEquals("toString") + && methodSymbol.getParameters().isEmpty(); + } + + private static boolean isGetterMethod(ClassSymbol enclosingClass, MethodSymbol methodSymbol, VisitorState state) { + return !methodSymbol.isConstructor() + && !methodSymbol.isStaticOrInstanceInit() + && !state.getTypes().isSameType(methodSymbol.getReturnType(), state.getSymtab().voidType) + && methodSymbol.getParameters().isEmpty() + && (isImmutablesField(enclosingClass, methodSymbol, state) || isToString(methodSymbol, state)); + } + @SuppressWarnings("checkstyle:CyclomaticComplexity") - private Description matchImmutables(ClassTree classTree, ClassSymbol classSymbol, VisitorState state) { - Safety existingClassSafety = SafetyAnnotations.getSafety(classTree, state); - Safety safety = SafetyAnnotations.getTypeSafetyFromAncestors(classTree, state); - boolean hasKnownGetter = false; - boolean isJson = hasJacksonAnnotation(classSymbol, state); - for (Tree member : classTree.getMembers()) { - if (member instanceof MethodTree) { - MethodTree methodMember = (MethodTree) member; - if (GETTER_METHOD_MATCHER.matches(methodMember, state)) { - MethodSymbol methodSymbol = ASTHelpers.getSymbol(methodMember); + private static Safety scanSymbolMethods(ClassSymbol begin, VisitorState state, boolean usesJackson) { + Safety safety = Safety.UNKNOWN; + for (Symbol enclosed : begin.getEnclosedElements()) { + if (enclosed instanceof MethodSymbol) { + MethodSymbol methodSymbol = (MethodSymbol) enclosed; + if (isGetterMethod(begin, methodSymbol, state)) { boolean redacted = ASTHelpers.hasAnnotation(methodSymbol, "org.immutables.value.Value.Redacted", state); - if (redacted && !isJson && !hasJacksonAnnotation(methodSymbol, state)) { + if (redacted && !usesJackson && !hasJacksonAnnotation(methodSymbol, state)) { // Redacted fields can be ignored so long as the object is not json-serializable, in which // case logging may occur using jackson rather than toString. continue; } + Safety getterSafety = + Safety.mergeAssumingUnknownIsSame(safety, SafetyAnnotations.getSafety(methodSymbol, state)); + getterSafety = Safety.mergeAssumingUnknownIsSame( + getterSafety, SafetyAnnotations.getSafety(methodSymbol.getReturnType(), state)); + getterSafety = Safety.mergeAssumingUnknownIsSame( + getterSafety, SafetyAnnotations.getSafety(methodSymbol.getReturnType().tsym, state)); // The redaction check allows us to add @DoNotLog to redacted fields in the same sweep as // adding class-level safety annotations. Otherwise, we would have to run the automatic // fixes twice. - Safety getterSafety = SafetyAnnotations.getSafety(methodMember.getReturnType(), state); if (redacted && (getterSafety == Safety.UNKNOWN || getterSafety == Safety.SAFE)) { // unsafe data may be redacted, however we assume redaction means do-not-log by default getterSafety = Safety.DO_NOT_LOG; } - if (getterSafety != Safety.UNKNOWN) { - hasKnownGetter = true; - } safety = safety.leastUpperBound(getterSafety); } } } - // If no getter-style methods are detected, assume this is not a value type. - if (!hasKnownGetter) { - return Description.NO_MATCH; + Type superClassType = begin.getSuperclass(); + if (superClassType != null && superClassType.tsym instanceof ClassSymbol) { + ClassSymbol superClassSym = (ClassSymbol) superClassType.tsym; + Safety superClassMethodSafety = scanSymbolMethods(superClassSym, state, usesJackson); + safety = Safety.mergeAssumingUnknownIsSame(safety, superClassMethodSafety); } + for (Type superIface : begin.getInterfaces()) { + if (superIface.tsym instanceof ClassSymbol) { + ClassSymbol superIfaceClassSymbol = (ClassSymbol) superIface.tsym; + Safety superClassMethodSafety = scanSymbolMethods(superIfaceClassSymbol, state, usesJackson); + safety = Safety.mergeAssumingUnknownIsSame(safety, superClassMethodSafety); + } + } + return safety; + } + + private Description matchImmutables(ClassTree classTree, ClassSymbol classSymbol, VisitorState state) { + Safety existingClassSafety = SafetyAnnotations.getAnnotatedSafety(classTree, state); + Safety safety = SafetyAnnotations.getTypeSafetyFromAncestors(classTree, state); + boolean isJson = hasJacksonAnnotation(classSymbol, state); + ClassSymbol symbol = ASTHelpers.getSymbol(classTree); + Safety scanned = scanSymbolMethods(symbol, state, isJson); + safety = safety.leastUpperBound(scanned); return handleSafety(classTree, classTree.getModifiers(), state, existingClassSafety, safety); } diff --git a/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/safety/SafetyAnnotations.java b/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/safety/SafetyAnnotations.java index 83dec84f6..e9dc00159 100644 --- a/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/safety/SafetyAnnotations.java +++ b/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/safety/SafetyAnnotations.java @@ -20,6 +20,7 @@ import com.google.errorprone.VisitorState; import com.google.errorprone.suppliers.Suppliers; import com.google.errorprone.util.ASTHelpers; +import com.sun.source.tree.AnnotationTree; import com.sun.source.tree.ClassTree; import com.sun.source.tree.ExpressionTree; import com.sun.source.tree.Tree; @@ -69,6 +70,24 @@ public final class SafetyAnnotations { new TypeArgumentHandler(Stream.class), new TypeArgumentHandler(Optional.class)); + public static Safety getAnnotatedSafety(Tree tree, VisitorState state) { + Safety safety = Safety.UNKNOWN; + for (AnnotationTree annotationTree : ASTHelpers.getAnnotations(tree)) { + Tree annotationType = annotationTree.getAnnotationType(); + Type type = ASTHelpers.getType(annotationType); + if (type != null) { + if (type.tsym.getQualifiedName().equals(doNotLogName.get(state))) { + safety = Safety.mergeAssumingUnknownIsSame(safety, Safety.DO_NOT_LOG); + } else if (type.tsym.getQualifiedName().equals(unsafeName.get(state))) { + safety = Safety.mergeAssumingUnknownIsSame(safety, Safety.UNSAFE); + } else if (type.tsym.getQualifiedName().equals(safeName.get(state))) { + safety = Safety.mergeAssumingUnknownIsSame(safety, Safety.SAFE); + } + } + } + return safety; + } + public static Safety getSafety(Tree tree, VisitorState state) { // Check the symbol itself: Symbol treeSymbol = ASTHelpers.getSymbol(tree); diff --git a/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/SafeLoggingPropagationTest.java b/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/SafeLoggingPropagationTest.java index 816ee192d..2bf216b85 100644 --- a/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/SafeLoggingPropagationTest.java +++ b/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/SafeLoggingPropagationTest.java @@ -44,6 +44,70 @@ void testAddsAnnotation_dnlType() { .doTest(); } + @Test + void testAddsAnnotation_extendsDnlInterface() { + fix().addInputLines( + "Test.java", + "import com.palantir.logsafe.*;", + "import org.immutables.value.Value;", + "class Test {", + " @DoNotLog", + " interface DnlIface {", + " Object value();", + " }", + " @Value.Immutable", + " interface ImmutablesIface extends DnlIface {", + " }", + "}") + .addOutputLines( + "Test.java", + "import com.palantir.logsafe.*;", + "import org.immutables.value.Value;", + "class Test {", + " @DoNotLog", + " interface DnlIface {", + " Object value();", + " }", + " @DoNotLog", + " @Value.Immutable", + " interface ImmutablesIface extends DnlIface {", + " }", + "}") + .doTest(); + } + + @Test + void testAddsAnnotation_extendsInterfaceWithDnlType() { + fix().addInputLines( + "Test.java", + "import com.palantir.tokens.auth.*;", + "import com.palantir.logsafe.*;", + "import org.immutables.value.Value;", + "class Test {", + " interface DnlIface {", + " BearerToken value();", + " }", + " @Value.Immutable", + " interface ImmutablesIface extends DnlIface {", + " }", + "}") + .addOutputLines( + "Test.java", + "import com.palantir.tokens.auth.*;", + "import com.palantir.logsafe.*;", + "import org.immutables.value.Value;", + "class Test {", + " interface DnlIface {", + " BearerToken value();", + " }", + " @DoNotLog", + " @Value.Immutable", + " interface ImmutablesIface extends DnlIface {", + " }", + "}") + .doTest(); + } + @Test void testMixedSafety() { fix().addInputLines( diff --git a/changelog/@unreleased/pr-2629.v2.yml b/changelog/@unreleased/pr-2629.v2.yml new file mode 100644 index 000000000..9d768f188 --- /dev/null +++ b/changelog/@unreleased/pr-2629.v2.yml @@ -0,0 +1,6 @@ +type: improvement +improvement: + description: Improve SafeLoggingPropagation on Immutables, taking into account fields + from superinterfaces + links: + - https://github.com/palantir/gradle-baseline/pull/2629 diff --git a/gradle-baseline-java/src/main/groovy/com/palantir/baseline/extensions/BaselineErrorProneExtension.java b/gradle-baseline-java/src/main/groovy/com/palantir/baseline/extensions/BaselineErrorProneExtension.java index 6f30c8755..9a97ceee4 100644 --- a/gradle-baseline-java/src/main/groovy/com/palantir/baseline/extensions/BaselineErrorProneExtension.java +++ b/gradle-baseline-java/src/main/groovy/com/palantir/baseline/extensions/BaselineErrorProneExtension.java @@ -67,6 +67,7 @@ public class BaselineErrorProneExtension { "ReadReturnValueIgnored", "RedundantMethodReference", "RedundantModifier", + "SafeLoggingPropagation", "Slf4jLevelCheck", "Slf4jLogsafeArgs", "Slf4jThrowable", From 1b02033dd8b88c5ac048a2ab079284b931f922ff Mon Sep 17 00:00:00 2001 From: svc-autorelease Date: Tue, 29 Aug 2023 21:41:15 +0000 Subject: [PATCH 114/129] Autorelease 5.20.0 [skip ci] --- changelog/{@unreleased => 5.20.0}/pr-2629.v2.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename changelog/{@unreleased => 5.20.0}/pr-2629.v2.yml (100%) diff --git a/changelog/@unreleased/pr-2629.v2.yml b/changelog/5.20.0/pr-2629.v2.yml similarity index 100% rename from changelog/@unreleased/pr-2629.v2.yml rename to changelog/5.20.0/pr-2629.v2.yml From ec6287d038921dfe71143e9b10d20713ce6ed656 Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Tue, 29 Aug 2023 19:23:51 -0700 Subject: [PATCH 115/129] Excavator: Upgrades Baseline to the latest version (#2633) --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 5aa95e413..620d3c7b3 100644 --- a/build.gradle +++ b/build.gradle @@ -14,7 +14,7 @@ buildscript { classpath 'com.palantir.gradle.externalpublish:gradle-external-publish-plugin:1.12.0' classpath 'com.palantir.gradle.consistentversions:gradle-consistent-versions:2.15.0' classpath 'com.gradle.publish:plugin-publish-plugin:1.2.1' - classpath 'com.palantir.baseline:gradle-baseline-java:5.19.0' + classpath 'com.palantir.baseline:gradle-baseline-java:5.20.0' classpath 'com.palantir.javaformat:gradle-palantir-java-format:2.33.0' } } From efe82a609be03444aaf4712caf193602f477a3d1 Mon Sep 17 00:00:00 2001 From: Carter Kozak Date: Thu, 31 Aug 2023 13:18:58 -0400 Subject: [PATCH 116/129] Upgrade error-prone to 2.21.1 (from 2.19.1) (#2628) Upgrade error-prone to 2.21.1 (from 2.19.1) --- .../baseline-class-uniqueness.lock | 2 +- baseline-error-prone/build.gradle | 2 +- .../errorprone/ForbidJavaxParameterType.java | 2 +- .../baseline/errorprone/MoreASTHelpers.java | 2 +- .../errorprone/SafeLoggingPropagation.java | 2 +- .../errorprone/UnsafeGaugeRegistration.java | 3 ++- .../safety/SafetyPropagationTransfer.java | 12 ++++++++++++ changelog/@unreleased/pr-2628.v2.yml | 5 +++++ versions.lock | 18 +++++++++--------- versions.props | 2 +- 10 files changed, 34 insertions(+), 16 deletions(-) create mode 100644 changelog/@unreleased/pr-2628.v2.yml diff --git a/baseline-error-prone/baseline-class-uniqueness.lock b/baseline-error-prone/baseline-class-uniqueness.lock index ee641fc71..3fc74511f 100644 --- a/baseline-error-prone/baseline-class-uniqueness.lock +++ b/baseline-error-prone/baseline-class-uniqueness.lock @@ -2,7 +2,7 @@ # Run ./gradlew checkClassUniqueness --write-locks to update this file ## runtimeClasspath -[org.checkerframework:checker-qual, org.checkerframework:dataflow-errorprone] +[io.github.eisop:dataflow-errorprone, org.checkerframework:checker-qual] - org.checkerframework.dataflow.qual.Deterministic - org.checkerframework.dataflow.qual.Pure - org.checkerframework.dataflow.qual.Pure$Kind diff --git a/baseline-error-prone/build.gradle b/baseline-error-prone/build.gradle index eed42bc27..6ef5f3848 100644 --- a/baseline-error-prone/build.gradle +++ b/baseline-error-prone/build.gradle @@ -11,7 +11,7 @@ javaVersion { dependencies { implementation 'com.google.errorprone:error_prone_core' // Ensure a new enough version of dataflow-errorprone is available - implementation 'org.checkerframework:dataflow-errorprone' + implementation 'io.github.eisop:dataflow-errorprone' testImplementation gradleApi() testImplementation 'com.palantir.tokens:auth-tokens' diff --git a/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/ForbidJavaxParameterType.java b/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/ForbidJavaxParameterType.java index 24b9cc14d..8d78a7806 100644 --- a/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/ForbidJavaxParameterType.java +++ b/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/ForbidJavaxParameterType.java @@ -120,7 +120,7 @@ private boolean hasJavaxInclusionsOnType(TypeSymbol symbol, VisitorState state) .addAll(classType.getInterfaces()) .build(); for (Type t : thisAndParents) { - for (Symbol sym : t.tsym.getEnclosedElements()) { + for (Symbol sym : ASTHelpers.getEnclosedElements(t.tsym)) { if (HAS_JAXRS_ANNOTATION.test(sym)) { return true; } diff --git a/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/MoreASTHelpers.java b/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/MoreASTHelpers.java index e9e4feb99..9432e7931 100644 --- a/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/MoreASTHelpers.java +++ b/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/MoreASTHelpers.java @@ -97,7 +97,7 @@ static ImmutableSet getThrownExceptionsFromTryBody(TryTree tree, VisitorSt /** Returns an optional of the {@link AutoCloseable#close()} method on the provided symbol. */ private static Optional getCloseMethod(Symbol.ClassSymbol symbol, VisitorState state) { Types types = state.getTypes(); - return symbol.getEnclosedElements().stream() + return ASTHelpers.getEnclosedElements(symbol).stream() .filter(sym -> types.isAssignable(symbol.type, state.getTypeFromString(AutoCloseable.class.getName())) && sym.getSimpleName().contentEquals("close") && sym.getTypeParameters().isEmpty()) diff --git a/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/SafeLoggingPropagation.java b/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/SafeLoggingPropagation.java index 396624f99..db652149b 100644 --- a/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/SafeLoggingPropagation.java +++ b/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/SafeLoggingPropagation.java @@ -203,7 +203,7 @@ private static boolean isGetterMethod(ClassSymbol enclosingClass, MethodSymbol m @SuppressWarnings("checkstyle:CyclomaticComplexity") private static Safety scanSymbolMethods(ClassSymbol begin, VisitorState state, boolean usesJackson) { Safety safety = Safety.UNKNOWN; - for (Symbol enclosed : begin.getEnclosedElements()) { + for (Symbol enclosed : ASTHelpers.getEnclosedElements(begin)) { if (enclosed instanceof MethodSymbol) { MethodSymbol methodSymbol = (MethodSymbol) enclosed; if (isGetterMethod(begin, methodSymbol, state)) { diff --git a/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/UnsafeGaugeRegistration.java b/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/UnsafeGaugeRegistration.java index 288fe52ef..fb1727db0 100644 --- a/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/UnsafeGaugeRegistration.java +++ b/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/UnsafeGaugeRegistration.java @@ -26,6 +26,7 @@ import com.google.errorprone.matchers.Matcher; import com.google.errorprone.matchers.method.MethodMatchers; import com.google.errorprone.suppliers.Supplier; +import com.google.errorprone.util.ASTHelpers; import com.sun.source.tree.ExpressionTree; import com.sun.source.tree.MethodInvocationTree; import com.sun.tools.javac.code.Symbol; @@ -79,7 +80,7 @@ private static boolean hasRegisterWithReplacement(VisitorState state) { return false; } Symbol.ClassSymbol classSymbol = (Symbol.ClassSymbol) symbol; - for (Symbol enclosed : classSymbol.getEnclosedElements()) { + for (Symbol enclosed : ASTHelpers.getEnclosedElements(classSymbol)) { if (enclosed instanceof Symbol.MethodSymbol) { Symbol.MethodSymbol enclosedMethod = (Symbol.MethodSymbol) enclosed; if (enclosedMethod.name.contentEquals(REGISTER_WITH_REPLACEMENT)) { diff --git a/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/safety/SafetyPropagationTransfer.java b/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/safety/SafetyPropagationTransfer.java index cb32e074b..380907fe4 100644 --- a/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/safety/SafetyPropagationTransfer.java +++ b/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/safety/SafetyPropagationTransfer.java @@ -100,6 +100,7 @@ import org.checkerframework.errorprone.dataflow.cfg.node.DoubleLiteralNode; import org.checkerframework.errorprone.dataflow.cfg.node.EqualToNode; import org.checkerframework.errorprone.dataflow.cfg.node.ExplicitThisNode; +import org.checkerframework.errorprone.dataflow.cfg.node.ExpressionStatementNode; import org.checkerframework.errorprone.dataflow.cfg.node.FieldAccessNode; import org.checkerframework.errorprone.dataflow.cfg.node.FloatLiteralNode; import org.checkerframework.errorprone.dataflow.cfg.node.FloatingDivisionNode; @@ -716,7 +717,12 @@ public TransferResult> visitBitwiseXor( return binary(node, input); } + /** + * Method should no longer be called, leaving in place until deletion for broader compatibility. + * @deprecated StringConcatenateAssignmentNode is generated as separate concatenation and assignment operations + */ @Override + @Deprecated public TransferResult> visitStringConcatenateAssignment( StringConcatenateAssignmentNode node, TransferInput> input) { Safety safety = getValueOfSubNode(input, node.getLeftOperand()) @@ -1296,6 +1302,12 @@ public TransferResult> visitClassDeclaration( return unknown(input); } + @Override + public TransferResult> visitExpressionStatement( + ExpressionStatementNode node, TransferInput> input) { + return unknown(input); + } + /** * Equivalent to {@link TransferInput#getValueOfSubNode(Node)}, * but returning {@link Safety#UNKNOWN} rather than null. diff --git a/changelog/@unreleased/pr-2628.v2.yml b/changelog/@unreleased/pr-2628.v2.yml new file mode 100644 index 000000000..9f1826270 --- /dev/null +++ b/changelog/@unreleased/pr-2628.v2.yml @@ -0,0 +1,5 @@ +type: improvement +improvement: + description: Upgrade error-prone to 2.21.1 (from 2.19.1) + links: + - https://github.com/palantir/gradle-baseline/pull/2628 diff --git a/versions.lock b/versions.lock index 56287a4d3..43842e1f7 100644 --- a/versions.lock +++ b/versions.lock @@ -13,17 +13,17 @@ com.google.auto.service:auto-service:1.1.1 (1 constraints: 0505f435) com.google.auto.service:auto-service-annotations:1.1.1 (2 constraints: 8a20341c) com.google.auto.value:auto-value-annotations:1.9 (3 constraints: 802d5ac8) com.google.code.findbugs:jsr305:3.0.2 (6 constraints: 66626968) -com.google.errorprone:error_prone_annotation:2.19.1 (3 constraints: d338dff0) -com.google.errorprone:error_prone_annotations:2.19.1 (12 constraints: c3bd77ce) -com.google.errorprone:error_prone_check_api:2.19.1 (2 constraints: bc255700) -com.google.errorprone:error_prone_core:2.19.1 (1 constraints: 3f054b3b) -com.google.errorprone:error_prone_type_annotations:2.19.1 (1 constraints: 2a115ec9) +com.google.errorprone:error_prone_annotation:2.21.1 (3 constraints: be3843ec) +com.google.errorprone:error_prone_annotations:2.21.1 (12 constraints: aebde2ad) +com.google.errorprone:error_prone_check_api:2.21.1 (2 constraints: ae2598fe) +com.google.errorprone:error_prone_core:2.21.1 (1 constraints: 3805373b) +com.google.errorprone:error_prone_type_annotations:2.21.1 (1 constraints: 23114ac9) com.google.guava:failureaccess:1.0.1 (2 constraints: f1150513) -com.google.guava:guava:32.1.2-jre (15 constraints: 58f56a81) +com.google.guava:guava:32.1.2-jre (15 constraints: 18f6510c) com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava (1 constraints: bd17c918) com.google.inject:guice:5.1.0 (2 constraints: c21eb8b6) com.google.j2objc:j2objc-annotations:2.8 (1 constraints: be09f5a0) -com.google.protobuf:protobuf-java:3.19.2 (1 constraints: 2c1165c9) +com.google.protobuf:protobuf-java:3.19.6 (1 constraints: 301169c9) com.googlecode.concurrent-trees:concurrent-trees:2.6.1 (1 constraints: 761166da) com.googlecode.java-diff-utils:diffutils:1.3.0 (1 constraints: 0605f935) com.googlecode.javaewah:JavaEWAH:1.1.12 (1 constraints: 750eee5e) @@ -33,6 +33,7 @@ com.palantir.javaformat:palantir-java-format-spi:1.1.0 (1 constraints: 711560be) com.uber.nullaway:nullaway:0.10.12 (1 constraints: 66058a40) commons-io:commons-io:2.13.0 (2 constraints: f519f007) commons-lang:commons-lang:2.6 (1 constraints: ac04232c) +io.github.eisop:dataflow-errorprone:3.34.0-eisop1 (3 constraints: 444080e0) io.github.java-diff-utils:java-diff-utils:4.0 (1 constraints: 811205f6) javax.annotation:javax.annotation-api:1.3.2 (2 constraints: cd204f35) javax.inject:javax.inject:1 (9 constraints: e5867a2e) @@ -56,7 +57,6 @@ org.apache.maven.resolver:maven-resolver-util:1.9.7 (3 constraints: 6e306f6a) org.apache.maven.shared:maven-dependency-analyzer:1.13.2 (1 constraints: 3905343b) org.apache.maven.shared:maven-shared-utils:3.3.4 (1 constraints: e60b61f3) org.checkerframework:checker-qual:3.33.0 (3 constraints: 0725c187) -org.checkerframework:dataflow-errorprone:3.33.0 (4 constraints: 0a3e5c60) org.checkerframework:dataflow-nullaway:3.33.0 (2 constraints: 6a1198f1) org.codehaus.groovy:groovy:3.0.10 (3 constraints: e32879d6) org.codehaus.groovy:groovy-xml:3.0.10 (1 constraints: 791161da) @@ -83,7 +83,7 @@ com.fasterxml.jackson.core:jackson-databind:2.15.2 (5 constraints: b04a5461) com.fasterxml.jackson.module:jackson-module-afterburner:2.15.2 (1 constraints: 3c05403b) com.github.stefanbirkner:system-rules:1.19.0 (1 constraints: 3d05443b) com.google.auto.value:auto-value:1.7.4 (1 constraints: 1f1221fb) -com.google.errorprone:error_prone_test_helpers:2.19.1 (1 constraints: 3f054b3b) +com.google.errorprone:error_prone_test_helpers:2.21.1 (1 constraints: 3805373b) com.google.googlejavaformat:google-java-format:1.13.0 (1 constraints: 8b149d75) com.google.jimfs:jimfs:1.2 (1 constraints: fb138b38) com.google.testing.compile:compile-testing:0.19 (1 constraints: 3214b94c) diff --git a/versions.props b/versions.props index c76fc74f0..975ac098f 100644 --- a/versions.props +++ b/versions.props @@ -11,7 +11,7 @@ org.jooq:jooq = 3.18.6 org.slf4j:* = 1.7.36 org.immutables:* = 2.9.3 org.ow2.asm:asm = 9.5 -com.google.errorprone:error_prone_* = 2.19.1 +com.google.errorprone:error_prone_* = 2.21.1 com.googlecode.java-diff-utils:diffutils = 1.3.0 com.puppycrawl.tools:checkstyle = 10.12.2 com.palantir.gradle.utils:* = 0.1.0 From cd14fa221e06ba3e94efd2e9901e0135394c5fda Mon Sep 17 00:00:00 2001 From: svc-autorelease Date: Thu, 31 Aug 2023 17:19:07 +0000 Subject: [PATCH 117/129] Autorelease 5.21.0 [skip ci] --- changelog/{@unreleased => 5.21.0}/pr-2628.v2.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename changelog/{@unreleased => 5.21.0}/pr-2628.v2.yml (100%) diff --git a/changelog/@unreleased/pr-2628.v2.yml b/changelog/5.21.0/pr-2628.v2.yml similarity index 100% rename from changelog/@unreleased/pr-2628.v2.yml rename to changelog/5.21.0/pr-2628.v2.yml From 7d4594c37464ec0dec29660bb5b0603b2116e1a3 Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Thu, 31 Aug 2023 13:23:59 -0700 Subject: [PATCH 118/129] Excavator: Upgrades Baseline to the latest version (#2634) --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 620d3c7b3..3f0063fa6 100644 --- a/build.gradle +++ b/build.gradle @@ -14,7 +14,7 @@ buildscript { classpath 'com.palantir.gradle.externalpublish:gradle-external-publish-plugin:1.12.0' classpath 'com.palantir.gradle.consistentversions:gradle-consistent-versions:2.15.0' classpath 'com.gradle.publish:plugin-publish-plugin:1.2.1' - classpath 'com.palantir.baseline:gradle-baseline-java:5.20.0' + classpath 'com.palantir.baseline:gradle-baseline-java:5.21.0' classpath 'com.palantir.javaformat:gradle-palantir-java-format:2.33.0' } } From dca88ac7faf672d9ab5d941061cd155fcf6fdf0c Mon Sep 17 00:00:00 2001 From: Patrick Koenig Date: Thu, 28 Sep 2023 14:36:35 -0700 Subject: [PATCH 119/129] Allow incubating method use inside other incubating methods (#2636) --- .../baseline/errorprone/IncubatingMethod.java | 12 ++++++++--- .../errorprone/IncubatingMethodTest.java | 20 +++++++++++++++++++ 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/IncubatingMethod.java b/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/IncubatingMethod.java index 6906e2a50..aaa59abd9 100644 --- a/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/IncubatingMethod.java +++ b/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/IncubatingMethod.java @@ -36,9 +36,11 @@ public final class IncubatingMethod extends BugChecker implements BugChecker.MethodInvocationTreeMatcher, BugChecker.MemberReferenceTreeMatcher { - /** Matcher for the Incubating annotation, using the full qualified path. */ - private static final Matcher INCUBATING_MATCHER = - Matchers.symbolHasAnnotation("com.palantir.conjure.java.lib.internal.Incubating"); + private static final String INCUBATING = "com.palantir.conjure.java.lib.internal.Incubating"; + + private static final Matcher INCUBATING_MATCHER = Matchers.symbolHasAnnotation(INCUBATING); + private static final Matcher IN_INCUBATING_MATCHER = + Matchers.enclosingMethod(Matchers.symbolHasAnnotation(INCUBATING)); @Override public Description matchMethodInvocation(MethodInvocationTree tree, VisitorState state) { @@ -55,6 +57,10 @@ private Description checkTree(Tree tree, VisitorState state) { return Description.NO_MATCH; } + if (IN_INCUBATING_MATCHER.matches(tree, state)) { + return Description.NO_MATCH; + } + // Allow users to test incubating endpoints in test code without complaining. if (TestCheckUtils.isTestCode(state)) { return Description.NO_MATCH; diff --git a/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/IncubatingMethodTest.java b/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/IncubatingMethodTest.java index 56381c6a8..8a75899a0 100644 --- a/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/IncubatingMethodTest.java +++ b/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/IncubatingMethodTest.java @@ -67,6 +67,26 @@ public void testIncubatingMethodReference() { .doTest(); } + @Test + public void testIncubatingMethodInsideIncubatingMethod() { + CompilationTestHelper.newInstance(IncubatingMethod.class, getClass()) + .addSourceLines("Service.java", SERVICE_DEFINITION) + .addSourceLines( + "Main.java", + "package com.palantir;", + "import java.util.function.Supplier;", + "import com.palantir.conjure.java.lib.internal.Incubating;", + "public final class Main {", + "@Incubating", + "public static void main(String[] args) {", + "Service service = null;", + "int result = service.test();", + "Supplier supp = service::test;", + "}", + "}") + .doTest(); + } + @Test public void testNonIncubatingMethod() { CompilationTestHelper.newInstance(IncubatingMethod.class, getClass()) From 1eefbf55c3a2ced9af0785014a2eb9a2396a4b9a Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Thu, 28 Sep 2023 16:31:00 -0700 Subject: [PATCH 120/129] Excavator: Upgrades Baseline to the latest version (#2637) --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 3f0063fa6..e43e50a60 100644 --- a/build.gradle +++ b/build.gradle @@ -14,7 +14,7 @@ buildscript { classpath 'com.palantir.gradle.externalpublish:gradle-external-publish-plugin:1.12.0' classpath 'com.palantir.gradle.consistentversions:gradle-consistent-versions:2.15.0' classpath 'com.gradle.publish:plugin-publish-plugin:1.2.1' - classpath 'com.palantir.baseline:gradle-baseline-java:5.21.0' + classpath 'com.palantir.baseline:gradle-baseline-java:5.22.0' classpath 'com.palantir.javaformat:gradle-palantir-java-format:2.33.0' } } From 777e9f7e69a3b21daa5d2b8a70267dbb38bc8f4c Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Thu, 5 Oct 2023 23:21:25 -0700 Subject: [PATCH 121/129] Excavator: Upgrade buildscript dependencies (#2638) --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index e43e50a60..0519e65fd 100644 --- a/build.gradle +++ b/build.gradle @@ -12,7 +12,7 @@ buildscript { classpath 'com.palantir.gradle.jdkslatest:gradle-jdks-latest:0.11.0' classpath 'com.diffplug.gradle:goomph:3.32.1' classpath 'com.palantir.gradle.externalpublish:gradle-external-publish-plugin:1.12.0' - classpath 'com.palantir.gradle.consistentversions:gradle-consistent-versions:2.15.0' + classpath 'com.palantir.gradle.consistentversions:gradle-consistent-versions:2.16.0' classpath 'com.gradle.publish:plugin-publish-plugin:1.2.1' classpath 'com.palantir.baseline:gradle-baseline-java:5.22.0' classpath 'com.palantir.javaformat:gradle-palantir-java-format:2.33.0' From 437d3920294ba82c8296acf844ddfa866df1662c Mon Sep 17 00:00:00 2001 From: Felix de Souza Date: Thu, 12 Oct 2023 11:49:00 +0100 Subject: [PATCH 122/129] Use a `Proxy` for `JavaInstallationMetadata` so we can work across Gradle 7 and 8 (#2605) Use a `Proxy` for `JavaInstallationMetadata` so we can work across Gradle 7 and 8. --- changelog/@unreleased/pr-2605.v2.yml | 6 + ...ava => JavaInstallationMetadataProxy.java} | 50 ++++---- .../plugins/javaversions/JavaToolchains.java | 2 +- .../BaselineJavaVersionIntegrationTest.groovy | 107 ++++++++++++++---- 4 files changed, 120 insertions(+), 45 deletions(-) create mode 100644 changelog/@unreleased/pr-2605.v2.yml rename gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/javaversions/{JavaInstallationMetadataWrapper.java => JavaInstallationMetadataProxy.java} (55%) diff --git a/changelog/@unreleased/pr-2605.v2.yml b/changelog/@unreleased/pr-2605.v2.yml new file mode 100644 index 000000000..aa1f0f7b5 --- /dev/null +++ b/changelog/@unreleased/pr-2605.v2.yml @@ -0,0 +1,6 @@ +type: fix +fix: + description: Use a `Proxy` for `JavaInstallationMetadata` so we can work across + Gradle 7 and 8. + links: + - https://github.com/palantir/gradle-baseline/pull/2605 diff --git a/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/javaversions/JavaInstallationMetadataWrapper.java b/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/javaversions/JavaInstallationMetadataProxy.java similarity index 55% rename from gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/javaversions/JavaInstallationMetadataWrapper.java rename to gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/javaversions/JavaInstallationMetadataProxy.java index 28c9c38dc..8c907254b 100644 --- a/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/javaversions/JavaInstallationMetadataWrapper.java +++ b/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/javaversions/JavaInstallationMetadataProxy.java @@ -1,5 +1,5 @@ /* - * (c) Copyright 2022 Palantir Technologies Inc. All rights reserved. + * (c) Copyright 2023 Palantir Technologies Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,10 @@ package com.palantir.baseline.plugins.javaversions; -import org.gradle.api.file.Directory; +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Proxy; import org.gradle.api.provider.Provider; import org.gradle.jvm.toolchain.JavaInstallationMetadata; import org.gradle.jvm.toolchain.JavaLanguageVersion; @@ -27,38 +30,37 @@ * check if toolchains are enabled. That can cause a dependency cycle, which causes a StackOverflowException. * This class breaks that cycle by immediately providing the JavaLanguageVersion without possibly causing a resolution. */ -final class JavaInstallationMetadataWrapper implements JavaInstallationMetadata { +final class JavaInstallationMetadataProxy implements InvocationHandler { + private final JavaLanguageVersion javaLanguageVersion; private final Provider delegate; - JavaInstallationMetadataWrapper( + private JavaInstallationMetadataProxy( JavaLanguageVersion javaLanguageVersion, Provider delegate) { this.javaLanguageVersion = javaLanguageVersion; this.delegate = delegate; } - @Override - public JavaLanguageVersion getLanguageVersion() { - return javaLanguageVersion; - } - - @Override - public String getJavaRuntimeVersion() { - return delegate.get().getJavaRuntimeVersion(); - } - - @Override - public String getJvmVersion() { - return delegate.get().getJvmVersion(); - } - - @Override - public String getVendor() { - return delegate.get().getVendor(); + static JavaInstallationMetadata proxyForVersion( + JavaLanguageVersion javaLanguageVersion, Provider delegate) { + return (JavaInstallationMetadata) Proxy.newProxyInstance( + JavaInstallationMetadata.class.getClassLoader(), + new Class[] {JavaInstallationMetadata.class}, + new JavaInstallationMetadataProxy(javaLanguageVersion, delegate)); } @Override - public Directory getInstallationPath() { - return delegate.get().getInstallationPath(); + public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { + try { + if ("getLanguageVersion".equals(method.getName())) { + return javaLanguageVersion; + } else { + return method.invoke(delegate.get(), args); + } + } catch (IllegalAccessException | IllegalArgumentException e) { + throw new RuntimeException(e); + } catch (InvocationTargetException e) { + throw e.getCause(); + } } } diff --git a/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/javaversions/JavaToolchains.java b/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/javaversions/JavaToolchains.java index 9bec70510..9d449919b 100644 --- a/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/javaversions/JavaToolchains.java +++ b/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/javaversions/JavaToolchains.java @@ -45,7 +45,7 @@ public Provider forVersion(Provider ja return new ConfiguredJavaToolchain( project.getObjects(), - project.provider(() -> new JavaInstallationMetadataWrapper( + project.provider(() -> JavaInstallationMetadataProxy.proxyForVersion( chosenJavaVersion.javaLanguageVersion(), configuredJdkMetadata))); }); } diff --git a/gradle-baseline-java/src/test/groovy/com/palantir/baseline/BaselineJavaVersionIntegrationTest.groovy b/gradle-baseline-java/src/test/groovy/com/palantir/baseline/BaselineJavaVersionIntegrationTest.groovy index befc0b909..ba28c4b8b 100644 --- a/gradle-baseline-java/src/test/groovy/com/palantir/baseline/BaselineJavaVersionIntegrationTest.groovy +++ b/gradle-baseline-java/src/test/groovy/com/palantir/baseline/BaselineJavaVersionIntegrationTest.groovy @@ -16,6 +16,9 @@ package com.palantir.baseline +import org.gradle.util.GradleVersion +import spock.lang.Unroll + import java.nio.file.Files import java.nio.file.Path import java.nio.file.Paths @@ -27,7 +30,10 @@ import org.assertj.core.api.Assumptions * This test exercises both the root-plugin {@code BaselineJavaVersions} AND the subproject * specific plugin, {@code BaselineJavaVersion}. */ +@Unroll class BaselineJavaVersionIntegrationTest extends IntegrationSpec { + private static final List GRADLE_TEST_VERSIONS = ['8.4.0', GradleVersion.current().getVersion()] + private static final int JAVA_8_BYTECODE = 52 private static final int JAVA_11_BYTECODE = 55 private static final int JAVA_17_BYTECODE = 61 @@ -101,8 +107,9 @@ class BaselineJavaVersionIntegrationTest extends IntegrationSpec { buildFile << standardBuildFile } - def 'java 11 compilation fails targeting java 8'() { + def '#gradleVersionNumber: java 11 compilation fails targeting java 8'() { when: + gradleVersion = gradleVersionNumber buildFile << ''' javaVersions { libraryTarget = 8 @@ -113,9 +120,12 @@ class BaselineJavaVersionIntegrationTest extends IntegrationSpec { then: runTasksWithFailure('compileJava') + + where: + gradleVersionNumber << GRADLE_TEST_VERSIONS } - def 'distribution target is used when no artifacts are published'() { + def '#gradleVersionNumber: distribution target is used when no artifacts are published'() { when: buildFile << ''' javaVersions { @@ -129,9 +139,12 @@ class BaselineJavaVersionIntegrationTest extends IntegrationSpec { then: runTasksSuccessfully('compileJava') assertBytecodeVersion(compiledClass, JAVA_17_BYTECODE, NOT_ENABLE_PREVIEW_BYTECODE) + + where: + gradleVersionNumber << GRADLE_TEST_VERSIONS } - def 'java 17 preview compilation works'() { + def '#gradleVersionNumber: java 17 preview compilation works'() { when: buildFile << ''' javaVersions { @@ -145,9 +158,12 @@ class BaselineJavaVersionIntegrationTest extends IntegrationSpec { then: runTasksSuccessfully('compileJava', '-i') assertBytecodeVersion(compiledClass, JAVA_17_BYTECODE, ENABLE_PREVIEW_BYTECODE) + + where: + gradleVersionNumber << GRADLE_TEST_VERSIONS } - def 'setting library target to preview version fails'() { + def '#gradleVersionNumber: setting library target to preview version fails'() { when: buildFile << ''' javaVersions { @@ -159,9 +175,12 @@ class BaselineJavaVersionIntegrationTest extends IntegrationSpec { then: ExecutionResult result = runTasksWithFailure('compileJava', '-i') result.standardError.contains 'cannot be run on newer JVMs' + + where: + gradleVersionNumber << GRADLE_TEST_VERSIONS } - def 'java 17 preview on single project works'() { + def '#gradleVersionNumber: java 17 preview on single project works'() { when: buildFile << ''' javaVersion { @@ -175,9 +194,12 @@ class BaselineJavaVersionIntegrationTest extends IntegrationSpec { then: runTasksSuccessfully('compileJava', '-i') assertBytecodeVersion(compiledClass, JAVA_17_BYTECODE, ENABLE_PREVIEW_BYTECODE) + + where: + gradleVersionNumber << GRADLE_TEST_VERSIONS } - def 'java 17 preview javadoc works'() { + def '#gradleVersionNumber: java 17 preview javadoc works'() { when: buildFile << ''' javaVersions { @@ -189,9 +211,12 @@ class BaselineJavaVersionIntegrationTest extends IntegrationSpec { then: runTasksSuccessfully('javadoc', '-i') + + where: + gradleVersionNumber << GRADLE_TEST_VERSIONS } - def 'library target is used when no artifacts are published but project is overridden as a library'() { + def '#gradleVersionNumber: library target is used when no artifacts are published but project is overridden as a library'() { when: buildFile << ''' javaVersions { @@ -208,9 +233,12 @@ class BaselineJavaVersionIntegrationTest extends IntegrationSpec { then: runTasksSuccessfully('compileJava') assertBytecodeVersion(compiledClass, JAVA_11_BYTECODE, NOT_ENABLE_PREVIEW_BYTECODE) + + where: + gradleVersionNumber << GRADLE_TEST_VERSIONS } - def 'library target is used when nebula maven publishing plugin is applied'() { + def '#gradleVersionNumber: library target is used when nebula maven publishing plugin is applied'() { when: buildFile << ''' apply plugin: 'nebula.maven-publish' @@ -225,9 +253,12 @@ class BaselineJavaVersionIntegrationTest extends IntegrationSpec { then: runTasksSuccessfully('compileJava') assertBytecodeVersion(compiledClass, JAVA_11_BYTECODE, NOT_ENABLE_PREVIEW_BYTECODE) + + where: + gradleVersionNumber << GRADLE_TEST_VERSIONS } - def 'library target is used when the palantir shadowjar plugin is applied'() { + def '#gradleVersionNumber: library target is used when the palantir shadowjar plugin is applied'() { when: buildFile << ''' apply plugin: 'com.palantir.consistent-versions' // required by shadow-jar @@ -244,9 +275,12 @@ class BaselineJavaVersionIntegrationTest extends IntegrationSpec { runTasksSuccessfully('--write-locks') runTasksSuccessfully('compileJava') assertBytecodeVersion(compiledClass, JAVA_11_BYTECODE, NOT_ENABLE_PREVIEW_BYTECODE) + + where: + gradleVersionNumber << GRADLE_TEST_VERSIONS } - def 'java 11 compilation succeeds targeting java 11'() { + def '#gradleVersionNumber: java 11 compilation succeeds targeting java 11'() { when: buildFile << ''' javaVersions { @@ -259,9 +293,12 @@ class BaselineJavaVersionIntegrationTest extends IntegrationSpec { then: runTasksSuccessfully('compileJava') assertBytecodeVersion(compiledClass, JAVA_11_BYTECODE, NOT_ENABLE_PREVIEW_BYTECODE) + + where: + gradleVersionNumber << GRADLE_TEST_VERSIONS } - def 'java 11 execution succeeds on java 11'() { + def '#gradleVersionNumber: java 11 execution succeeds on java 11'() { when: buildFile << ''' javaVersions { @@ -275,9 +312,12 @@ class BaselineJavaVersionIntegrationTest extends IntegrationSpec { ExecutionResult result = runTasksSuccessfully('run') result.standardOutput.contains 'jdk11 features on runtime 11' assertBytecodeVersion(compiledClass, JAVA_11_BYTECODE, NOT_ENABLE_PREVIEW_BYTECODE) + + where: + gradleVersionNumber << GRADLE_TEST_VERSIONS } - def 'java 11 execution succeeds on java 17'() { + def '#gradleVersionNumber: java 11 execution succeeds on java 17'() { when: buildFile << ''' javaVersions { @@ -292,9 +332,12 @@ class BaselineJavaVersionIntegrationTest extends IntegrationSpec { ExecutionResult result = runTasksSuccessfully('run') result.standardOutput.contains 'jdk11 features on runtime 17' assertBytecodeVersion(compiledClass, JAVA_11_BYTECODE, NOT_ENABLE_PREVIEW_BYTECODE) + + where: + gradleVersionNumber << GRADLE_TEST_VERSIONS } - def 'java 8 execution succeeds on java 8'() { + def '#gradleVersionNumber: java 8 execution succeeds on java 8'() { Assumptions.assumeThat(System.getProperty("os.arch")).describedAs( "On an M1 mac, this test will fail to download https://api.adoptopenjdk.net/v3/binary/latest/8/ga/mac/aarch64/jdk/hotspot/normal/adoptopenjdk") .isNotEqualTo("aarch64"); @@ -309,9 +352,12 @@ class BaselineJavaVersionIntegrationTest extends IntegrationSpec { then: ExecutionResult result = runTasksSuccessfully('run') result.standardOutput.contains 'jdk8 features on runtime 1.8' + + where: + gradleVersionNumber << GRADLE_TEST_VERSIONS } - def 'java 8 execution succeeds on java 11'() { + def '#gradleVersionNumber: java 8 execution succeeds on java 11'() { Assumptions.assumeThat(System.getProperty("os.arch")).describedAs( "On an M1 mac, this test will fail to download https://api.adoptopenjdk.net/v3/binary/latest/8/ga/mac/aarch64/jdk/hotspot/normal/adoptopenjdk") .isNotEqualTo("aarch64"); @@ -330,9 +376,12 @@ class BaselineJavaVersionIntegrationTest extends IntegrationSpec { ExecutionResult result = runTasksSuccessfully('run') result.standardOutput.contains 'jdk8 features on runtime 11' assertBytecodeVersion(compiledClass, JAVA_8_BYTECODE, NOT_ENABLE_PREVIEW_BYTECODE) + + where: + gradleVersionNumber << GRADLE_TEST_VERSIONS } - def 'JavaPluginConvention.getTargetCompatibility() produces the runtime java version'() { + def '#gradleVersionNumber: JavaPluginConvention.getTargetCompatibility() produces the runtime java version'() { when: buildFile << ''' javaVersions { @@ -351,9 +400,12 @@ class BaselineJavaVersionIntegrationTest extends IntegrationSpec { then: ExecutionResult result = runTasksSuccessfully('printTargetCompatibility') result.standardOutput.contains '[[[17]]]' + + where: + gradleVersionNumber << GRADLE_TEST_VERSIONS } - def 'verification should fail when target exceeds the runtime version'() { + def '#gradleVersionNumber: verification should fail when target exceeds the runtime version'() { when: buildFile << ''' javaVersions { @@ -365,9 +417,12 @@ class BaselineJavaVersionIntegrationTest extends IntegrationSpec { then: ExecutionResult result = runTasksWithFailure('checkJavaVersions') result.standardError.contains 'The requested compilation target' + + where: + gradleVersionNumber << GRADLE_TEST_VERSIONS } - def 'verification should fail when --enable-preview is on, but versions differ'() { + def '#gradleVersionNumber: verification should fail when --enable-preview is on, but versions differ'() { when: buildFile << ''' javaVersions { @@ -379,9 +434,12 @@ class BaselineJavaVersionIntegrationTest extends IntegrationSpec { then: ExecutionResult result = runTasksWithFailure('checkJavaVersions') result.standardError.contains 'Runtime Java version (15_PREVIEW) must be exactly the same as the compilation target (11_PREVIEW)' + + where: + gradleVersionNumber << GRADLE_TEST_VERSIONS } - def 'verification should fail when runtime does not use --enable-preview but compilation does'() { + def '#gradleVersionNumber: verification should fail when runtime does not use --enable-preview but compilation does'() { when: buildFile << ''' javaVersions { @@ -393,9 +451,12 @@ class BaselineJavaVersionIntegrationTest extends IntegrationSpec { then: ExecutionResult result = runTasksWithFailure('checkJavaVersions') result.standardError.contains 'Runtime Java version (17) must be exactly the same as the compilation target (17_PREVIEW)' + + where: + gradleVersionNumber << GRADLE_TEST_VERSIONS } - def 'verification should succeed when target and runtime versions match'() { + def '#gradleVersionNumber: verification should succeed when target and runtime versions match'() { when: buildFile << ''' javaVersions { @@ -406,9 +467,12 @@ class BaselineJavaVersionIntegrationTest extends IntegrationSpec { then: runTasksSuccessfully('checkJavaVersions') + + where: + gradleVersionNumber << GRADLE_TEST_VERSIONS } - def 'can configure a jdk path to be used'() { + def '#gradleVersionNumber: can configure a jdk path to be used'() { Assumptions.assumeThat(System.getenv("CI")).describedAs( "This test deletes a directory locally, you don't want to run it on your mac").isNotNull(); @@ -453,6 +517,9 @@ class BaselineJavaVersionIntegrationTest extends IntegrationSpec { then: stdout.contains(newJavaHome.toString()) + + where: + gradleVersionNumber << GRADLE_TEST_VERSIONS } private static final int BYTECODE_IDENTIFIER = (int) 0xCAFEBABE From 642e1e3d675ca49517113b70f73144144914ba0e Mon Sep 17 00:00:00 2001 From: svc-autorelease Date: Thu, 12 Oct 2023 10:49:09 +0000 Subject: [PATCH 123/129] Autorelease 5.23.0 [skip ci] --- changelog/{@unreleased => 5.23.0}/pr-2605.v2.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename changelog/{@unreleased => 5.23.0}/pr-2605.v2.yml (100%) diff --git a/changelog/@unreleased/pr-2605.v2.yml b/changelog/5.23.0/pr-2605.v2.yml similarity index 100% rename from changelog/@unreleased/pr-2605.v2.yml rename to changelog/5.23.0/pr-2605.v2.yml From f6e43095b61de662685810defa070661dad8ee08 Mon Sep 17 00:00:00 2001 From: Callum Rogers Date: Thu, 12 Oct 2023 12:38:37 +0100 Subject: [PATCH 124/129] Lazy exact dependencies (#2639) `baseline-exact-dependencies` is now far more lazy around `Configuration` creation in order to support Gradle 8. --- changelog/@unreleased/pr-2639.v2.yml | 6 + gradle-baseline-java/build.gradle | 1 + .../plugins/BaselineExactDependencies.java | 172 +++++++++--------- .../tasks/CheckImplicitDependenciesTask.java | 6 +- .../tasks/CheckUnusedDependenciesTask.java | 6 +- .../palantir/baseline/GradleTestVersions.java | 2 +- 6 files changed, 101 insertions(+), 92 deletions(-) create mode 100644 changelog/@unreleased/pr-2639.v2.yml diff --git a/changelog/@unreleased/pr-2639.v2.yml b/changelog/@unreleased/pr-2639.v2.yml new file mode 100644 index 000000000..02fb5d091 --- /dev/null +++ b/changelog/@unreleased/pr-2639.v2.yml @@ -0,0 +1,6 @@ +type: fix +fix: + description: '`baseline-exact-dependencies` is now far more lazy around `Configuration` + creation in order to support Gradle 8.' + links: + - https://github.com/palantir/gradle-baseline/pull/2639 diff --git a/gradle-baseline-java/build.gradle b/gradle-baseline-java/build.gradle index 24be90071..5cfa03f2a 100644 --- a/gradle-baseline-java/build.gradle +++ b/gradle-baseline-java/build.gradle @@ -61,6 +61,7 @@ tasks.test.dependsOn tasks.publishToMavenLocal test { environment 'CIRCLE_ARTIFACTS', "${buildDir}/artifacts" environment 'CIRCLE_TEST_REPORTS', "${buildDir}/circle-reports" + systemProperty 'ignoreDeprecations', 'true' } gradlePlugin { diff --git a/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineExactDependencies.java b/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineExactDependencies.java index f19b334a0..7e3f5625c 100644 --- a/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineExactDependencies.java +++ b/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineExactDependencies.java @@ -39,6 +39,7 @@ import org.apache.maven.shared.dependency.analyzer.DefaultClassAnalyzer; import org.apache.maven.shared.dependency.analyzer.DependencyAnalyzer; import org.apache.maven.shared.dependency.analyzer.asm.ASMDependencyAnalyzer; +import org.gradle.api.NamedDomainObjectProvider; import org.gradle.api.Plugin; import org.gradle.api.Project; import org.gradle.api.artifacts.Configuration; @@ -79,7 +80,7 @@ public void apply(Project project) { project.getConvention() .getPlugin(JavaPluginConvention.class) .getSourceSets() - .all(sourceSet -> + .configureEach(sourceSet -> configureSourceSet(project, sourceSet, checkUnusedDependencies, checkImplicitDependencies)); }); } @@ -89,19 +90,15 @@ private static void configureSourceSet( SourceSet sourceSet, TaskProvider checkUnusedDependencies, TaskProvider checkImplicitDependencies) { - Configuration implementation = - project.getConfigurations().getByName(sourceSet.getImplementationConfigurationName()); - Optional maybeCompile = - Optional.ofNullable(project.getConfigurations().findByName(getCompileConfigurationName(sourceSet))); - Configuration compileClasspath = - project.getConfigurations().getByName(sourceSet.getCompileClasspathConfigurationName()); - - Configuration explicitCompile = project.getConfigurations() - .create("baseline-exact-dependencies-" + sourceSet.getName(), conf -> { - conf.setDescription(String.format( - "Tracks the explicit (not inherited) dependencies added to either %s " - + "or compile (deprecated)", - implementation)); + + NamedDomainObjectProvider compileClasspath = + project.getConfigurations().named(sourceSet.getCompileClasspathConfigurationName()); + + NamedDomainObjectProvider explicitCompile = project.getConfigurations() + .register("baseline-exact-dependencies-" + sourceSet.getName(), conf -> { + conf.setDescription( + "Tracks the explicit (not inherited) dependencies added to either implementation " + + "or compile (deprecated)"); conf.setVisible(false); conf.setCanBeConsumed(false); @@ -119,80 +116,93 @@ private static void configureSourceSet( } }); - // Without this, the 'checkUnusedDependencies correctly picks up project dependency on java-library' - // test fails, by not causing gradle run the jar task, but resolving the path to the jar (rather - // than to the classes directory), which then doesn't exist. - - // Specifically, we need to pick up the LIBRARY_ELEMENTS_ATTRIBUTE, which is being configured on - // compileClasspath in JavaBasePlugin.defineConfigurationsForSourceSet, but we can't reference it - // directly because that would require us to depend on Gradle 5.6. - // Instead, we just copy the attributes from compileClasspath. - compileClasspath.getAttributes().keySet().forEach(attribute -> { - Object value = compileClasspath.getAttributes().getAttribute(attribute); - conf.getAttributes().attribute((Attribute) attribute, value); - }); - }); + project.afterEvaluate(_ignored -> { + // Without this, the 'checkUnusedDependencies correctly picks up project dependency on + // java-library' test fails, by not causing gradle run the jar task, but resolving the path to + // the jar (rather than to the classes directory), which then doesn't exist. + // Specifically, we need to pick up the LIBRARY_ELEMENTS_ATTRIBUTE, which is being configured on + // compileClasspath in JavaBasePlugin.defineConfigurationsForSourceSet, but we can't reference + // it directly because that would require us to depend on Gradle 5.6. + // Instead, we just copy the attributes from compileClasspath. + compileClasspath.get().getAttributes().keySet().forEach(attribute -> { + Object value = + compileClasspath.get().getAttributes().getAttribute(attribute); + conf.getAttributes().attribute((Attribute) attribute, value); + }); - // Figure out what our compile dependencies are while ignoring dependencies we've inherited from other source - // sets. For example, if we are `test`, some of our configurations extend from the `main` source set: - // testImplementation extendsFrom(implementation) - // \-- testCompile extendsFrom(compile) - // We therefore want to look at only the dependencies _directly_ declared in the implementation and compile - // configurations (belonging to our source set) - project.afterEvaluate(p -> { - Configuration implCopy = implementation.copy(); - // Without these, explicitCompile will successfully resolve 0 files and you'll waste 1 hour trying - // to figure out why. - project.getConfigurations().add(implCopy); - - explicitCompile.extendsFrom(implCopy); - - // For Gradle 6 and below, the compile configuration might still be used. - maybeCompile.ifPresent(compile -> { - Configuration compileCopy = compile.copy(); - // Ensure it's not resolvable, otherwise plugins that resolve all configurations might have - // a bad time resolving this with GCV, if you have direct dependencies without corresponding entries in - // versions.props, but instead rely on getting a version for them from the lock file. - compileCopy.setCanBeResolved(false); - compileCopy.setCanBeConsumed(false); - - project.getConfigurations().add(compileCopy); - - explicitCompile.extendsFrom(compileCopy); - }); - }); + // Figure out what our compile dependencies are while ignoring dependencies we've inherited from + // other source sets. For example, if we are `test`, some of our configurations extend from the + // `main` source set: + // testImplementation extendsFrom(implementation) + // \-- testCompile extendsFrom(compile) + // We therefore want to look at only the dependencies _directly_ declared in the implementation + // and compile configurations (belonging to our source set) + Configuration implCopy = project.getConfigurations() + .getByName(sourceSet.getImplementationConfigurationName()) + .copy(); + + // Without these, explicitCompile will successfully resolve 0 files and you'll waste 1 hour + // trying to figure out why. + project.getConfigurations().add(implCopy); + + conf.extendsFrom(implCopy); + + Optional maybeCompile = Optional.ofNullable( + project.getConfigurations().findByName(getCompileConfigurationName(sourceSet))); + + // For Gradle 6 and below, the compile configuration might still be used. + maybeCompile.ifPresent(compile -> { + Configuration compileCopy = compile.copy(); + // Ensure it's not resolvable, otherwise plugins that resolve all configurations might have + // a bad time resolving this with GCV, if you have direct dependencies without corresponding + // entries in versions.props, but instead rely on getting a version for them from the lock + // file. + compileCopy.setCanBeResolved(false); + compileCopy.setCanBeConsumed(false); + + project.getConfigurations().add(compileCopy); + + conf.extendsFrom(compileCopy); + }); + }); - explicitCompile.withDependencies(deps -> { - // Pick up GCV locks. We're making an internal assumption that this configuration exists, - // but we can rely on this since we control GCV. - // Alternatively, we could tell GCV to lock this configuration, at the cost of a slightly more - // expensive 'unifiedClasspath' resolution during lock computation. - if (project.getRootProject().getPluginManager().hasPlugin("com.palantir.versions-lock")) { - explicitCompile.extendsFrom(project.getConfigurations().getByName("lockConstraints")); - } - // Inherit the excludes from compileClasspath too (that get aggregated from all its super-configurations). - compileClasspath.getExcludeRules().forEach(rule -> explicitCompile.exclude(excludeRuleAsMap(rule))); - }); + conf.withDependencies(deps -> { + // Pick up GCV locks. We're making an internal assumption that this configuration exists, + // but we can rely on this since we control GCV. + // Alternatively, we could tell GCV to lock this configuration, at the cost of a slightly more + // expensive 'unifiedClasspath' resolution during lock computation. + if (project.getRootProject().getPluginManager().hasPlugin("com.palantir.versions-lock")) { + conf.extendsFrom(project.getConfigurations().getByName("lockConstraints")); + } + // Inherit the excludes from compileClasspath too (that get aggregated from all its + // super-configurations). + compileClasspath.get().getExcludeRules().forEach(rule -> conf.exclude(excludeRuleAsMap(rule))); + }); - // Since we are copying configurations before resolving 'explicitCompile', make double sure that it's not - // being resolved (or dependencies realized via `.getIncoming().getDependencies()`) too early. - AtomicBoolean projectsEvaluated = new AtomicBoolean(); - project.getGradle().projectsEvaluated(g -> projectsEvaluated.set(true)); - explicitCompile - .getIncoming() - .beforeResolve(ir -> Preconditions.checkState( - projectsEvaluated.get() - || (project.getGradle().getStartParameter().isConfigureOnDemand() - && project.getState().getExecuted()), - "Tried to resolve %s too early.", - explicitCompile)); + // Since we are copying configurations before resolving 'explicitCompile', make double sure that + // it's not being resolved (or dependencies realized via `.getIncoming().getDependencies()`) + // too early. + AtomicBoolean projectsEvaluated = new AtomicBoolean(); + project.getGradle().projectsEvaluated(g -> projectsEvaluated.set(true)); + + conf.getIncoming().beforeResolve(_ignored -> { + Preconditions.checkState( + projectsEvaluated.get() + || (project.getGradle() + .getStartParameter() + .isConfigureOnDemand() + && project.getState().getExecuted()), + "Tried to resolve %s too early.", + conf); + }); + }); TaskProvider sourceSetUnusedDependencies = project.getTasks() .register( checkUnusedDependenciesNameForSourceSet(sourceSet), CheckUnusedDependenciesTask.class, task -> { task.dependsOn(sourceSet.getClassesTaskName()); task.setSourceClasses(sourceSet.getOutput().getClassesDirs()); - task.dependenciesConfiguration(explicitCompile); + task.getDependenciesConfigurations().add(explicitCompile); // this is liberally applied to ease the Java8 -> 11 transition task.ignore("javax.annotation", "javax.annotation-api"); @@ -211,7 +221,7 @@ private static void configureSourceSet( task -> { task.dependsOn(sourceSet.getClassesTaskName()); task.setSourceClasses(sourceSet.getOutput().getClassesDirs()); - task.dependenciesConfiguration(compileClasspath); + task.getDependenciesConfigurations().add(compileClasspath); task.suggestionConfigurationName(sourceSet.getImplementationConfigurationName()); task.ignore("org.slf4j", "slf4j-api"); @@ -227,7 +237,7 @@ static String checkUnusedDependenciesNameForSourceSet(SourceSet sourceSet) { } /** - * The {@link SourceSet#getCompileConfigurationName()} method got removed in Gradle 7. Because we want to stay + * The {@code SourceSet#getCompileConfigurationName()} method got removed in Gradle 7. Because we want to stay * compatible with Gradle 6 but can't compile this method, we reimplement it temporarily. * TODO(fwindheuser): Remove after dropping support for Gradle 6. */ diff --git a/gradle-baseline-java/src/main/groovy/com/palantir/baseline/tasks/CheckImplicitDependenciesTask.java b/gradle-baseline-java/src/main/groovy/com/palantir/baseline/tasks/CheckImplicitDependenciesTask.java index 105979ac5..c7b719ea2 100644 --- a/gradle-baseline-java/src/main/groovy/com/palantir/baseline/tasks/CheckImplicitDependenciesTask.java +++ b/gradle-baseline-java/src/main/groovy/com/palantir/baseline/tasks/CheckImplicitDependenciesTask.java @@ -148,14 +148,10 @@ private boolean shouldIgnore(ResolvedArtifact artifact) { } @Classpath - public final Provider> getDependenciesConfigurations() { + public final ListProperty getDependenciesConfigurations() { return dependenciesConfigurations; } - public final void dependenciesConfiguration(Configuration dependenciesConfiguration) { - this.dependenciesConfigurations.add(Objects.requireNonNull(dependenciesConfiguration)); - } - @Classpath public final Provider getSourceClasses() { return sourceClasses; diff --git a/gradle-baseline-java/src/main/groovy/com/palantir/baseline/tasks/CheckUnusedDependenciesTask.java b/gradle-baseline-java/src/main/groovy/com/palantir/baseline/tasks/CheckUnusedDependenciesTask.java index a26e13d3d..e59238885 100644 --- a/gradle-baseline-java/src/main/groovy/com/palantir/baseline/tasks/CheckUnusedDependenciesTask.java +++ b/gradle-baseline-java/src/main/groovy/com/palantir/baseline/tasks/CheckUnusedDependenciesTask.java @@ -173,14 +173,10 @@ private boolean shouldIgnore(ResolvedArtifact artifact) { } @Classpath - public final Provider> getDependenciesConfigurations() { + public final ListProperty getDependenciesConfigurations() { return dependenciesConfigurations; } - public final void dependenciesConfiguration(Configuration dependenciesConfiguration) { - this.dependenciesConfigurations.add(Objects.requireNonNull(dependenciesConfiguration)); - } - @Input public final Provider> getSourceOnlyConfigurations() { return sourceOnlyConfigurations; diff --git a/gradle-baseline-java/src/test/groovy/com/palantir/baseline/GradleTestVersions.java b/gradle-baseline-java/src/test/groovy/com/palantir/baseline/GradleTestVersions.java index 56b2e79a5..52439103b 100644 --- a/gradle-baseline-java/src/test/groovy/com/palantir/baseline/GradleTestVersions.java +++ b/gradle-baseline-java/src/test/groovy/com/palantir/baseline/GradleTestVersions.java @@ -21,7 +21,7 @@ public final class GradleTestVersions { public static final ImmutableList VERSIONS = - ImmutableList.of(Baseline.MIN_GRADLE_VERSION.getVersion(), "7.1.1", "7.3"); + ImmutableList.of(Baseline.MIN_GRADLE_VERSION.getVersion(), "7.6.2", "8.4"); private GradleTestVersions() {} } From 2381f401fb0050eae77a10f27397ad5835cdd3ca Mon Sep 17 00:00:00 2001 From: svc-autorelease Date: Thu, 12 Oct 2023 11:38:46 +0000 Subject: [PATCH 125/129] Autorelease 5.24.0 [skip ci] --- changelog/{@unreleased => 5.24.0}/pr-2639.v2.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename changelog/{@unreleased => 5.24.0}/pr-2639.v2.yml (100%) diff --git a/changelog/@unreleased/pr-2639.v2.yml b/changelog/5.24.0/pr-2639.v2.yml similarity index 100% rename from changelog/@unreleased/pr-2639.v2.yml rename to changelog/5.24.0/pr-2639.v2.yml From 3d12d9eb588c1c20a0d172af00abf57353160981 Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Thu, 12 Oct 2023 06:50:14 -0700 Subject: [PATCH 126/129] Excavator: Upgrades Baseline to the latest version (#2640) --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 0519e65fd..5634ad4b9 100644 --- a/build.gradle +++ b/build.gradle @@ -14,7 +14,7 @@ buildscript { classpath 'com.palantir.gradle.externalpublish:gradle-external-publish-plugin:1.12.0' classpath 'com.palantir.gradle.consistentversions:gradle-consistent-versions:2.16.0' classpath 'com.gradle.publish:plugin-publish-plugin:1.2.1' - classpath 'com.palantir.baseline:gradle-baseline-java:5.22.0' + classpath 'com.palantir.baseline:gradle-baseline-java:5.24.0' classpath 'com.palantir.javaformat:gradle-palantir-java-format:2.33.0' } } From bee51c45a6d8ab57a8691671fe596c8b045a6336 Mon Sep 17 00:00:00 2001 From: Callum Rogers Date: Fri, 13 Oct 2023 12:47:51 +0100 Subject: [PATCH 127/129] Revert "Lazy exact dependencies (#2639)" (#2642) Revert "Lazy exact dependencies" --- changelog/@unreleased/pr-2642.v2.yml | 5 + gradle-baseline-java/build.gradle | 1 - .../plugins/BaselineExactDependencies.java | 172 +++++++++--------- .../tasks/CheckImplicitDependenciesTask.java | 6 +- .../tasks/CheckUnusedDependenciesTask.java | 6 +- .../palantir/baseline/GradleTestVersions.java | 2 +- 6 files changed, 97 insertions(+), 95 deletions(-) create mode 100644 changelog/@unreleased/pr-2642.v2.yml diff --git a/changelog/@unreleased/pr-2642.v2.yml b/changelog/@unreleased/pr-2642.v2.yml new file mode 100644 index 000000000..c3234d032 --- /dev/null +++ b/changelog/@unreleased/pr-2642.v2.yml @@ -0,0 +1,5 @@ +type: fix +fix: + description: Revert "Lazy exact dependencies" + links: + - https://github.com/palantir/gradle-baseline/pull/2642 diff --git a/gradle-baseline-java/build.gradle b/gradle-baseline-java/build.gradle index 5cfa03f2a..24be90071 100644 --- a/gradle-baseline-java/build.gradle +++ b/gradle-baseline-java/build.gradle @@ -61,7 +61,6 @@ tasks.test.dependsOn tasks.publishToMavenLocal test { environment 'CIRCLE_ARTIFACTS', "${buildDir}/artifacts" environment 'CIRCLE_TEST_REPORTS', "${buildDir}/circle-reports" - systemProperty 'ignoreDeprecations', 'true' } gradlePlugin { diff --git a/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineExactDependencies.java b/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineExactDependencies.java index 7e3f5625c..f19b334a0 100644 --- a/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineExactDependencies.java +++ b/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineExactDependencies.java @@ -39,7 +39,6 @@ import org.apache.maven.shared.dependency.analyzer.DefaultClassAnalyzer; import org.apache.maven.shared.dependency.analyzer.DependencyAnalyzer; import org.apache.maven.shared.dependency.analyzer.asm.ASMDependencyAnalyzer; -import org.gradle.api.NamedDomainObjectProvider; import org.gradle.api.Plugin; import org.gradle.api.Project; import org.gradle.api.artifacts.Configuration; @@ -80,7 +79,7 @@ public void apply(Project project) { project.getConvention() .getPlugin(JavaPluginConvention.class) .getSourceSets() - .configureEach(sourceSet -> + .all(sourceSet -> configureSourceSet(project, sourceSet, checkUnusedDependencies, checkImplicitDependencies)); }); } @@ -90,15 +89,19 @@ private static void configureSourceSet( SourceSet sourceSet, TaskProvider checkUnusedDependencies, TaskProvider checkImplicitDependencies) { - - NamedDomainObjectProvider compileClasspath = - project.getConfigurations().named(sourceSet.getCompileClasspathConfigurationName()); - - NamedDomainObjectProvider explicitCompile = project.getConfigurations() - .register("baseline-exact-dependencies-" + sourceSet.getName(), conf -> { - conf.setDescription( - "Tracks the explicit (not inherited) dependencies added to either implementation " - + "or compile (deprecated)"); + Configuration implementation = + project.getConfigurations().getByName(sourceSet.getImplementationConfigurationName()); + Optional maybeCompile = + Optional.ofNullable(project.getConfigurations().findByName(getCompileConfigurationName(sourceSet))); + Configuration compileClasspath = + project.getConfigurations().getByName(sourceSet.getCompileClasspathConfigurationName()); + + Configuration explicitCompile = project.getConfigurations() + .create("baseline-exact-dependencies-" + sourceSet.getName(), conf -> { + conf.setDescription(String.format( + "Tracks the explicit (not inherited) dependencies added to either %s " + + "or compile (deprecated)", + implementation)); conf.setVisible(false); conf.setCanBeConsumed(false); @@ -116,93 +119,80 @@ private static void configureSourceSet( } }); - project.afterEvaluate(_ignored -> { - // Without this, the 'checkUnusedDependencies correctly picks up project dependency on - // java-library' test fails, by not causing gradle run the jar task, but resolving the path to - // the jar (rather than to the classes directory), which then doesn't exist. - // Specifically, we need to pick up the LIBRARY_ELEMENTS_ATTRIBUTE, which is being configured on - // compileClasspath in JavaBasePlugin.defineConfigurationsForSourceSet, but we can't reference - // it directly because that would require us to depend on Gradle 5.6. - // Instead, we just copy the attributes from compileClasspath. - compileClasspath.get().getAttributes().keySet().forEach(attribute -> { - Object value = - compileClasspath.get().getAttributes().getAttribute(attribute); - conf.getAttributes().attribute((Attribute) attribute, value); - }); - - // Figure out what our compile dependencies are while ignoring dependencies we've inherited from - // other source sets. For example, if we are `test`, some of our configurations extend from the - // `main` source set: - // testImplementation extendsFrom(implementation) - // \-- testCompile extendsFrom(compile) - // We therefore want to look at only the dependencies _directly_ declared in the implementation - // and compile configurations (belonging to our source set) - Configuration implCopy = project.getConfigurations() - .getByName(sourceSet.getImplementationConfigurationName()) - .copy(); - - // Without these, explicitCompile will successfully resolve 0 files and you'll waste 1 hour - // trying to figure out why. - project.getConfigurations().add(implCopy); - - conf.extendsFrom(implCopy); - - Optional maybeCompile = Optional.ofNullable( - project.getConfigurations().findByName(getCompileConfigurationName(sourceSet))); - - // For Gradle 6 and below, the compile configuration might still be used. - maybeCompile.ifPresent(compile -> { - Configuration compileCopy = compile.copy(); - // Ensure it's not resolvable, otherwise plugins that resolve all configurations might have - // a bad time resolving this with GCV, if you have direct dependencies without corresponding - // entries in versions.props, but instead rely on getting a version for them from the lock - // file. - compileCopy.setCanBeResolved(false); - compileCopy.setCanBeConsumed(false); - - project.getConfigurations().add(compileCopy); - - conf.extendsFrom(compileCopy); - }); + // Without this, the 'checkUnusedDependencies correctly picks up project dependency on java-library' + // test fails, by not causing gradle run the jar task, but resolving the path to the jar (rather + // than to the classes directory), which then doesn't exist. + + // Specifically, we need to pick up the LIBRARY_ELEMENTS_ATTRIBUTE, which is being configured on + // compileClasspath in JavaBasePlugin.defineConfigurationsForSourceSet, but we can't reference it + // directly because that would require us to depend on Gradle 5.6. + // Instead, we just copy the attributes from compileClasspath. + compileClasspath.getAttributes().keySet().forEach(attribute -> { + Object value = compileClasspath.getAttributes().getAttribute(attribute); + conf.getAttributes().attribute((Attribute) attribute, value); }); + }); - conf.withDependencies(deps -> { - // Pick up GCV locks. We're making an internal assumption that this configuration exists, - // but we can rely on this since we control GCV. - // Alternatively, we could tell GCV to lock this configuration, at the cost of a slightly more - // expensive 'unifiedClasspath' resolution during lock computation. - if (project.getRootProject().getPluginManager().hasPlugin("com.palantir.versions-lock")) { - conf.extendsFrom(project.getConfigurations().getByName("lockConstraints")); - } - // Inherit the excludes from compileClasspath too (that get aggregated from all its - // super-configurations). - compileClasspath.get().getExcludeRules().forEach(rule -> conf.exclude(excludeRuleAsMap(rule))); - }); + // Figure out what our compile dependencies are while ignoring dependencies we've inherited from other source + // sets. For example, if we are `test`, some of our configurations extend from the `main` source set: + // testImplementation extendsFrom(implementation) + // \-- testCompile extendsFrom(compile) + // We therefore want to look at only the dependencies _directly_ declared in the implementation and compile + // configurations (belonging to our source set) + project.afterEvaluate(p -> { + Configuration implCopy = implementation.copy(); + // Without these, explicitCompile will successfully resolve 0 files and you'll waste 1 hour trying + // to figure out why. + project.getConfigurations().add(implCopy); + + explicitCompile.extendsFrom(implCopy); + + // For Gradle 6 and below, the compile configuration might still be used. + maybeCompile.ifPresent(compile -> { + Configuration compileCopy = compile.copy(); + // Ensure it's not resolvable, otherwise plugins that resolve all configurations might have + // a bad time resolving this with GCV, if you have direct dependencies without corresponding entries in + // versions.props, but instead rely on getting a version for them from the lock file. + compileCopy.setCanBeResolved(false); + compileCopy.setCanBeConsumed(false); + + project.getConfigurations().add(compileCopy); + + explicitCompile.extendsFrom(compileCopy); + }); + }); - // Since we are copying configurations before resolving 'explicitCompile', make double sure that - // it's not being resolved (or dependencies realized via `.getIncoming().getDependencies()`) - // too early. - AtomicBoolean projectsEvaluated = new AtomicBoolean(); - project.getGradle().projectsEvaluated(g -> projectsEvaluated.set(true)); - - conf.getIncoming().beforeResolve(_ignored -> { - Preconditions.checkState( - projectsEvaluated.get() - || (project.getGradle() - .getStartParameter() - .isConfigureOnDemand() - && project.getState().getExecuted()), - "Tried to resolve %s too early.", - conf); - }); - }); + explicitCompile.withDependencies(deps -> { + // Pick up GCV locks. We're making an internal assumption that this configuration exists, + // but we can rely on this since we control GCV. + // Alternatively, we could tell GCV to lock this configuration, at the cost of a slightly more + // expensive 'unifiedClasspath' resolution during lock computation. + if (project.getRootProject().getPluginManager().hasPlugin("com.palantir.versions-lock")) { + explicitCompile.extendsFrom(project.getConfigurations().getByName("lockConstraints")); + } + // Inherit the excludes from compileClasspath too (that get aggregated from all its super-configurations). + compileClasspath.getExcludeRules().forEach(rule -> explicitCompile.exclude(excludeRuleAsMap(rule))); + }); + + // Since we are copying configurations before resolving 'explicitCompile', make double sure that it's not + // being resolved (or dependencies realized via `.getIncoming().getDependencies()`) too early. + AtomicBoolean projectsEvaluated = new AtomicBoolean(); + project.getGradle().projectsEvaluated(g -> projectsEvaluated.set(true)); + explicitCompile + .getIncoming() + .beforeResolve(ir -> Preconditions.checkState( + projectsEvaluated.get() + || (project.getGradle().getStartParameter().isConfigureOnDemand() + && project.getState().getExecuted()), + "Tried to resolve %s too early.", + explicitCompile)); TaskProvider sourceSetUnusedDependencies = project.getTasks() .register( checkUnusedDependenciesNameForSourceSet(sourceSet), CheckUnusedDependenciesTask.class, task -> { task.dependsOn(sourceSet.getClassesTaskName()); task.setSourceClasses(sourceSet.getOutput().getClassesDirs()); - task.getDependenciesConfigurations().add(explicitCompile); + task.dependenciesConfiguration(explicitCompile); // this is liberally applied to ease the Java8 -> 11 transition task.ignore("javax.annotation", "javax.annotation-api"); @@ -221,7 +211,7 @@ private static void configureSourceSet( task -> { task.dependsOn(sourceSet.getClassesTaskName()); task.setSourceClasses(sourceSet.getOutput().getClassesDirs()); - task.getDependenciesConfigurations().add(compileClasspath); + task.dependenciesConfiguration(compileClasspath); task.suggestionConfigurationName(sourceSet.getImplementationConfigurationName()); task.ignore("org.slf4j", "slf4j-api"); @@ -237,7 +227,7 @@ static String checkUnusedDependenciesNameForSourceSet(SourceSet sourceSet) { } /** - * The {@code SourceSet#getCompileConfigurationName()} method got removed in Gradle 7. Because we want to stay + * The {@link SourceSet#getCompileConfigurationName()} method got removed in Gradle 7. Because we want to stay * compatible with Gradle 6 but can't compile this method, we reimplement it temporarily. * TODO(fwindheuser): Remove after dropping support for Gradle 6. */ diff --git a/gradle-baseline-java/src/main/groovy/com/palantir/baseline/tasks/CheckImplicitDependenciesTask.java b/gradle-baseline-java/src/main/groovy/com/palantir/baseline/tasks/CheckImplicitDependenciesTask.java index c7b719ea2..105979ac5 100644 --- a/gradle-baseline-java/src/main/groovy/com/palantir/baseline/tasks/CheckImplicitDependenciesTask.java +++ b/gradle-baseline-java/src/main/groovy/com/palantir/baseline/tasks/CheckImplicitDependenciesTask.java @@ -148,10 +148,14 @@ private boolean shouldIgnore(ResolvedArtifact artifact) { } @Classpath - public final ListProperty getDependenciesConfigurations() { + public final Provider> getDependenciesConfigurations() { return dependenciesConfigurations; } + public final void dependenciesConfiguration(Configuration dependenciesConfiguration) { + this.dependenciesConfigurations.add(Objects.requireNonNull(dependenciesConfiguration)); + } + @Classpath public final Provider getSourceClasses() { return sourceClasses; diff --git a/gradle-baseline-java/src/main/groovy/com/palantir/baseline/tasks/CheckUnusedDependenciesTask.java b/gradle-baseline-java/src/main/groovy/com/palantir/baseline/tasks/CheckUnusedDependenciesTask.java index e59238885..a26e13d3d 100644 --- a/gradle-baseline-java/src/main/groovy/com/palantir/baseline/tasks/CheckUnusedDependenciesTask.java +++ b/gradle-baseline-java/src/main/groovy/com/palantir/baseline/tasks/CheckUnusedDependenciesTask.java @@ -173,10 +173,14 @@ private boolean shouldIgnore(ResolvedArtifact artifact) { } @Classpath - public final ListProperty getDependenciesConfigurations() { + public final Provider> getDependenciesConfigurations() { return dependenciesConfigurations; } + public final void dependenciesConfiguration(Configuration dependenciesConfiguration) { + this.dependenciesConfigurations.add(Objects.requireNonNull(dependenciesConfiguration)); + } + @Input public final Provider> getSourceOnlyConfigurations() { return sourceOnlyConfigurations; diff --git a/gradle-baseline-java/src/test/groovy/com/palantir/baseline/GradleTestVersions.java b/gradle-baseline-java/src/test/groovy/com/palantir/baseline/GradleTestVersions.java index 52439103b..56b2e79a5 100644 --- a/gradle-baseline-java/src/test/groovy/com/palantir/baseline/GradleTestVersions.java +++ b/gradle-baseline-java/src/test/groovy/com/palantir/baseline/GradleTestVersions.java @@ -21,7 +21,7 @@ public final class GradleTestVersions { public static final ImmutableList VERSIONS = - ImmutableList.of(Baseline.MIN_GRADLE_VERSION.getVersion(), "7.6.2", "8.4"); + ImmutableList.of(Baseline.MIN_GRADLE_VERSION.getVersion(), "7.1.1", "7.3"); private GradleTestVersions() {} } From aac80ff946a5add7fe9b56d4b523a59cf1720246 Mon Sep 17 00:00:00 2001 From: svc-autorelease Date: Fri, 13 Oct 2023 11:48:01 +0000 Subject: [PATCH 128/129] Autorelease 5.25.0 [skip ci] --- changelog/{@unreleased => 5.25.0}/pr-2642.v2.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename changelog/{@unreleased => 5.25.0}/pr-2642.v2.yml (100%) diff --git a/changelog/@unreleased/pr-2642.v2.yml b/changelog/5.25.0/pr-2642.v2.yml similarity index 100% rename from changelog/@unreleased/pr-2642.v2.yml rename to changelog/5.25.0/pr-2642.v2.yml From 837b9c269cbe219dc1e1917495f44d00961235b1 Mon Sep 17 00:00:00 2001 From: Excavator Bot <33266368+svc-excavator-bot@users.noreply.github.com> Date: Fri, 13 Oct 2023 06:59:46 -0700 Subject: [PATCH 129/129] Excavator: Upgrades Baseline to the latest version (#2643) --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 5634ad4b9..7c1fb1a22 100644 --- a/build.gradle +++ b/build.gradle @@ -14,7 +14,7 @@ buildscript { classpath 'com.palantir.gradle.externalpublish:gradle-external-publish-plugin:1.12.0' classpath 'com.palantir.gradle.consistentversions:gradle-consistent-versions:2.16.0' classpath 'com.gradle.publish:plugin-publish-plugin:1.2.1' - classpath 'com.palantir.baseline:gradle-baseline-java:5.24.0' + classpath 'com.palantir.baseline:gradle-baseline-java:5.25.0' classpath 'com.palantir.javaformat:gradle-palantir-java-format:2.33.0' } }