From c131cac02bb49be349ad4ca9d8d94ac8ac2206cd Mon Sep 17 00:00:00 2001 From: Vincent Potucek Date: Sat, 10 Jan 2026 20:14:01 +0100 Subject: [PATCH 01/27] [rewrite] add `CodeCleanup` Signed-off-by: Vincent Potucek - https://docs.openrewrite.org/recipes/staticanalysis/codecleanup ``` There were problems parsing lib/src/main/resources/com/diffplug/spotless/npm/eslint-package.json There were problems parsing lib/src/main/resources/com/diffplug/spotless/npm/prettier-package.json There were problems parsing lib/src/main/resources/com/diffplug/spotless/npm/tsfmt-package.json All sources parsed, running active recipes: com.diffplug.spotless.openrewrite.SanityCheck Changes have been made to testlib/src/main/java/com/diffplug/spotless/TestProvisioner.java by: org.openrewrite.staticanalysis.HideUtilityClassConstructor Changes have been made to testlib/src/main/java/com/diffplug/spotless/ReflectionUtil.java by: org.openrewrite.staticanalysis.HideUtilityClassConstructor Changes have been made to testlib/src/test/java/com/diffplug/spotless/PaddedCellTest.java by: org.openrewrite.staticanalysis.ForLoopControlVariablePostfixOperators Please review and commit the results. Estimate time saved: 15m ``` --- .github/workflows/ci.yml | 31 ++- README.md | 6 +- rewrite.yml | 19 +- .../com/diffplug/spotless/ReflectionUtil.java | 53 ---- .../diffplug/spotless/TestProvisioner.java | 227 ++++++++++-------- .../com/diffplug/spotless/PaddedCellTest.java | 4 +- 6 files changed, 166 insertions(+), 174 deletions(-) delete mode 100644 testlib/src/main/java/com/diffplug/spotless/ReflectionUtil.java diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0282bddf72..34ecc4acea 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,7 +7,6 @@ on: push: branches: [main, release] workflow_dispatch: - concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true @@ -19,7 +18,7 @@ jobs: buildcacheuser: ${{ secrets.BUILDCACHE_USER }} buildcachepass: ${{ secrets.BUILDCACHE_PASS }} steps: - - name: Checkout + - name: Checkout Code ðŸ“Ĩ uses: actions/checkout@v6 with: fetch-depth: 0 @@ -27,26 +26,25 @@ jobs: with: distribution: "temurin" java-version: 21 - - name: gradle caching + - name: Setup Gradle 🐘 uses: gradle/actions/setup-gradle@v5 - name: Spotless âœĻ - run: ./gradlew spotlessCheck + run: ./gradlew clean spotlessCheck - name: Rewrite â™ŧïļ - run: ./gradlew rewriteDryRun - - name: assemble testClasses - run: ./gradlew assemble testClasses + run: ./gradlew clean rewriteDryRun + - name: Assemble Test Classes ⚙ïļ + run: ./gradlew clean assemble testClasses build: + name: Build 🏗ïļ needs: sanity-check strategy: fail-fast: false matrix: kind: [maven, gradle] - # Test on the latest Java version once Gradle & Maven support it. - jre: [17, 21, 24] + jre: [17, 21, 24] # test on the latest Java version once Gradle & Maven support it. os: [ubuntu-latest, windows-latest] include: - # npm on linux only (crazy slow on windows) - - kind: npm + - kind: npm # npm on linux only (crazy slow on windows). jre: 17 os: ubuntu-latest - kind: shfmt @@ -99,14 +97,13 @@ jobs: ./gradlew testIdea - name: junit result uses: mikepenz/action-junit-report@v6 - if: always() # always run even if the previous step fails + if: always() # always run even if the previous step fails. with: check_name: JUnit ${{ matrix.kind }} ${{ matrix.jre }} ${{ matrix.os }} report_paths: '*/build/test-results/*/TEST-*.xml' check_retries: true - - # Status check that is required in branch protection rules. - final-status: + complete: # this check is required in branch protection rules. + name: Complete ✅ needs: - sanity-check - build @@ -117,7 +114,7 @@ jobs: run: | results=$(tr -d '\n' <<< '${{ toJSON(needs.*.result) }}') if ! grep -q -v -E '(failure|cancelled)' <<< "$results"; then - echo "One or more required jobs failed" + echo ❌ One or more required jobs failed. exit 1 fi - echo "All required jobs completed successfully." + echo ✅ All required jobs completed successfully. diff --git a/README.md b/README.md index 064509f3f5..59edbdd2cd 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Spotless can format <antlr | c | c# | c++ | css | flow | graphql | groovy | h You probably want one of the links below: -## [❇ïļ Spotless for Gradle](plugin-gradle) (with integrations for [VS Code](https://marketplace.visualstudio.com/items?itemName=richardwillis.vscode-spotless-gradle) and [IntelliJ](https://plugins.jetbrains.com/plugin/18321-spotless-gradle)) +## [âœĻïļ Spotless for Gradle](plugin-gradle) (with integrations for [VS Code](https://marketplace.visualstudio.com/items?itemName=richardwillis.vscode-spotless-gradle) and [IntelliJ](https://plugins.jetbrains.com/plugin/18321-spotless-gradle)) ```console user@machine repo % ./gradlew build @@ -25,7 +25,7 @@ user@machine repo % ./gradlew build BUILD SUCCESSFUL ``` -## [❇ïļ Spotless for Maven](plugin-maven) +## [âœĻïļ Spotless for Maven](plugin-maven) ```console user@machine repo % mvn spotless:check @@ -40,7 +40,7 @@ user@machine repo % mvn spotless:check [INFO] BUILD SUCCESS ``` -## [❇ïļ Spotless for SBT (external for now)](https://github.com/moznion/sbt-spotless) +## [âœĻïļ Spotless for SBT (external for now)](https://github.com/moznion/sbt-spotless) ## [Other build systems](CONTRIBUTING.md#how-to-add-a-new-plugin-for-a-build-system) ## How it works (for potential contributors) diff --git a/rewrite.yml b/rewrite.yml index d318e9bce3..92c936b8bd 100644 --- a/rewrite.yml +++ b/rewrite.yml @@ -8,12 +8,16 @@ recipeList: - org.openrewrite.gradle.EnableGradleParallelExecution - org.openrewrite.gradle.GradleBestPractices - org.openrewrite.java.RemoveUnusedImports + - org.openrewrite.java.ShortenFullyQualifiedTypeReferences + - org.openrewrite.java.SimplifySingleElementAnnotation + - org.openrewrite.java.format.EmptyNewlineAtEndOfFile - org.openrewrite.java.format.NormalizeFormat - org.openrewrite.java.format.NormalizeLineBreaks + - org.openrewrite.java.format.PadEmptyForLoopComponents - org.openrewrite.java.format.RemoveTrailingWhitespace - org.openrewrite.java.migrate.UpgradeToJava17 + - org.openrewrite.java.migrate.lang.JavaLangAPIs - org.openrewrite.java.migrate.lang.StringRulesRecipes - - org.openrewrite.java.migrate.util.JavaLangAPIs - org.openrewrite.java.migrate.util.JavaUtilAPIs - org.openrewrite.java.migrate.util.MigrateInflaterDeflaterToClose - org.openrewrite.java.migrate.util.ReplaceStreamCollectWithToList @@ -22,19 +26,32 @@ recipeList: - org.openrewrite.java.recipes.RecipeTestingBestPractices - org.openrewrite.java.security.JavaSecurityBestPractices - org.openrewrite.staticanalysis.BufferedWriterCreationRecipes + - org.openrewrite.staticanalysis.ChainStringBuilderAppendCalls - org.openrewrite.staticanalysis.CommonStaticAnalysis + - org.openrewrite.staticanalysis.CustomImportOrder + - org.openrewrite.staticanalysis.DefaultComesLast + - org.openrewrite.staticanalysis.EmptyBlock - org.openrewrite.staticanalysis.EqualsAvoidsNull + - org.openrewrite.staticanalysis.ExplicitInitialization + - org.openrewrite.staticanalysis.FallThrough + - org.openrewrite.staticanalysis.FinalizePrivateFields + - org.openrewrite.staticanalysis.ForLoopControlVariablePostfixOperators + - org.openrewrite.staticanalysis.HideUtilityClassConstructor - org.openrewrite.staticanalysis.JavaApiBestPractices - org.openrewrite.staticanalysis.LowercasePackage - org.openrewrite.staticanalysis.MissingOverrideAnnotation - org.openrewrite.staticanalysis.ModifierOrder + - org.openrewrite.staticanalysis.NeedBraces - org.openrewrite.staticanalysis.NoFinalizer - org.openrewrite.staticanalysis.NoToStringOnStringType - org.openrewrite.staticanalysis.NoValueOfOnStringType - org.openrewrite.staticanalysis.RemoveUnusedLocalVariables - org.openrewrite.staticanalysis.RemoveUnusedPrivateFields - org.openrewrite.staticanalysis.RemoveUnusedPrivateMethods + - org.openrewrite.staticanalysis.ReplaceStringBuilderWithString + - org.openrewrite.staticanalysis.ReplaceThreadRunWithThreadStart - org.openrewrite.staticanalysis.SimplifyTernaryRecipes + - org.openrewrite.staticanalysis.TypecastParenPad - org.openrewrite.staticanalysis.URLEqualsHashCodeRecipes - org.openrewrite.staticanalysis.UnnecessaryCloseInTryWithResources - org.openrewrite.staticanalysis.UnnecessaryExplicitTypeArguments diff --git a/testlib/src/main/java/com/diffplug/spotless/ReflectionUtil.java b/testlib/src/main/java/com/diffplug/spotless/ReflectionUtil.java deleted file mode 100644 index 1590b08311..0000000000 --- a/testlib/src/main/java/com/diffplug/spotless/ReflectionUtil.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2016-2025 DiffPlug - * - * 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.diffplug.spotless; - -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.lang.reflect.Parameter; -import java.util.Arrays; -import java.util.Iterator; - -/** - * Utilities for dumping class info, helpful for - * debugging reflection code. Probably easiest to - * just copy-paste these methods where you need - * them. - */ -public class ReflectionUtil { - public static void dumpAllInfo(String name, Object obj) { - System.out.println(name + " of type " + obj.getClass()); - for (Method method : obj.getClass().getMethods()) { - dumpMethod(method); - } - } - - public static void dumpMethod(Method method) { - System.out.print(Modifier.toString(method.getModifiers())); - System.out.print(" " + method.getReturnType()); - System.out.print(" " + method.getName() + "("); - Iterator paramIter = Arrays.asList(method.getParameters()).iterator(); - while (paramIter.hasNext()) { - Parameter param = paramIter.next(); - - System.out.print(param.getType().getName()); - if (paramIter.hasNext()) { - System.out.print(", "); - } - } - System.out.println(")"); - } -} diff --git a/testlib/src/main/java/com/diffplug/spotless/TestProvisioner.java b/testlib/src/main/java/com/diffplug/spotless/TestProvisioner.java index 55558f9b37..0ec0775567 100644 --- a/testlib/src/main/java/com/diffplug/spotless/TestProvisioner.java +++ b/testlib/src/main/java/com/diffplug/spotless/TestProvisioner.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2025 DiffPlug + * Copyright 2026 DiffPlug * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,12 +15,33 @@ */ package com.diffplug.spotless; +import static com.diffplug.common.base.Errors.asRuntime; +import static com.diffplug.common.base.StandardSystemProperty.USER_DIR; +import static com.diffplug.common.base.StandardSystemProperty.USER_HOME; +import static com.diffplug.common.base.Suppliers.memoize; +import static com.diffplug.common.collect.ImmutableSet.copyOf; +import static com.diffplug.common.io.Files.asByteSink; +import static com.diffplug.common.io.Files.asByteSource; +import static com.diffplug.common.io.Files.createParentDirs; +import static com.diffplug.common.io.Files.createTempDir; +import static java.nio.file.Files.walk; +import static java.nio.file.Path.of; +import static java.util.Comparator.reverseOrder; +import static java.util.Objects.requireNonNull; +import static org.gradle.api.attributes.Bundling.BUNDLING_ATTRIBUTE; +import static org.gradle.api.attributes.Bundling.EXTERNAL; +import static org.gradle.api.attributes.Category.CATEGORY_ATTRIBUTE; +import static org.gradle.api.attributes.Category.LIBRARY; +import static org.gradle.api.attributes.java.TargetJvmEnvironment.STANDARD_JVM; +import static org.gradle.api.attributes.java.TargetJvmEnvironment.TARGET_JVM_ENVIRONMENT_ATTRIBUTE; +import static org.gradle.testfixtures.ProjectBuilder.builder; + import java.io.File; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.nio.file.Path; -import java.util.Comparator; +import java.util.Collection; import java.util.HashMap; import java.util.Map; import java.util.function.Consumer; @@ -34,125 +55,135 @@ import org.gradle.api.attributes.Bundling; import org.gradle.api.attributes.Category; import org.gradle.api.attributes.java.TargetJvmEnvironment; -import org.gradle.testfixtures.ProjectBuilder; -import com.diffplug.common.base.Errors; -import com.diffplug.common.base.StandardSystemProperty; -import com.diffplug.common.base.Suppliers; import com.diffplug.common.collect.ImmutableSet; -import com.diffplug.common.io.Files; -public class TestProvisioner { - public static Project gradleProject(File dir) { - File userHome = new File(StandardSystemProperty.USER_HOME.value()); - return ProjectBuilder.builder() - .withGradleUserHomeDir(new File(userHome, ".gradle")) - .withProjectDir(dir) +public final class TestProvisioner { + + private static final String MAVEN_CENTRAL_CACHE = "build/tmp/testprovisioner.mavenCentral.cache"; + private static final String TEST_LIB = "testlib"; + + private TestProvisioner() {} + + public static Project gradleProject(File projectDir) { + return builder() + .withGradleUserHomeDir(new File(requireNonNull(USER_HOME.value()), ".gradle")) + .withProjectDir(projectDir) .build(); } /** - * Creates a Provisioner for the given repositories. - *

- * The first time a project is created, there are ~7 seconds of configuration - * which will go away for all subsequent runs. - *

- * Every call to resolve will take about 1 second, even when all artifacts are resolved. + * Creates a Provisioner for the mavenCentral repo. */ - private static Provisioner createWithRepositories(Consumer repoConfig) { - // Running this takes ~3 seconds the first time it is called. Probably because of classloading. - File tempDir = Files.createTempDir(); - Project project = TestProvisioner.gradleProject(tempDir); - repoConfig.accept(project.getRepositories()); - return (withTransitives, mavenCoords) -> { - Dependency[] deps = mavenCoords.stream() - .map(project.getDependencies()::create) - .toArray(Dependency[]::new); - Configuration config = project.getConfigurations().detachedConfiguration(deps); - config.setTransitive(withTransitives); - config.setDescription(mavenCoords.toString()); - config.attributes(attr -> { - attr.attribute(Category.CATEGORY_ATTRIBUTE, project.getObjects().named(Category.class, Category.LIBRARY)); - attr.attribute(Bundling.BUNDLING_ATTRIBUTE, project.getObjects().named(Bundling.class, Bundling.EXTERNAL)); - // Add this attribute for resolving Guava dependency, see https://github.com/google/guava/issues/6801. - attr.attribute(TargetJvmEnvironment.TARGET_JVM_ENVIRONMENT_ATTRIBUTE, project.getObjects().named(TargetJvmEnvironment.class, TargetJvmEnvironment.STANDARD_JVM)); - }); - try { - return config.resolve(); - } catch (ResolveException e) { - /* Provide Maven coordinates in exception message instead of static string 'detachedConfiguration' */ - throw new RuntimeException("Error resolving configuration: " + config.getDescription(), e); - } finally { - // delete the temp dir - try { - java.nio.file.Files.walk(tempDir.toPath()) - .sorted(Comparator.reverseOrder()) - .map(Path::toFile) - .forEach(File::delete); + public static Provisioner mavenCentral() { + return memoize(() -> caching(() -> createWithRepositories(RepositoryHandler::mavenCentral))).get(); + } + + /** + * Creates a Provisioner which will cache the result of previous calls. + */ + private static Provisioner caching(Supplier delegate) { + var cacheFile = new File(new File(new File(requireNonNull(USER_DIR.value())).getParentFile(), TEST_LIB), MAVEN_CENTRAL_CACHE); + return (withTransitives, rawCoords) -> resolveAndCache( + delegate, + withTransitives, + loadCache(cacheFile), + copyOf(rawCoords), + cacheFile); + } + + private static ImmutableSet resolveAndCache(Supplier delegate, + boolean withTransitives, + Map, ImmutableSet> artifactCache, + ImmutableSet mavenCoords, + File cacheFile) { + synchronized (TestProvisioner.class) { + var cachedFiles = artifactCache.get(mavenCoords); + var cacheValid = cachedFiles != null && + cachedFiles.stream().allMatch( + f -> f.exists() && f.isFile() && f.length() > 0); + if (!cacheValid) { + cachedFiles = copyOf( + delegate.get() + .provisionWithTransitives(withTransitives, mavenCoords)); + artifactCache.put(mavenCoords, cachedFiles); + try (var out = new ObjectOutputStream(asByteSink(cacheFile).openBufferedStream())) { + out.writeObject(artifactCache); } catch (IOException e) { - throw Errors.asRuntime(e); + throw asRuntime(e); } } - }; + return cachedFiles; + } } - /** Creates a Provisioner which will cache the result of previous calls. */ @SuppressWarnings("unchecked") - private static Provisioner caching(String name, Supplier input) { - File spotlessDir = new File(StandardSystemProperty.USER_DIR.value()).getParentFile(); - File testlib = new File(spotlessDir, "testlib"); - File cacheFile = new File(testlib, "build/tmp/testprovisioner." + name + ".cache"); - - Map, ImmutableSet> cached; + private static Map, ImmutableSet> loadCache(File cacheFile) { if (cacheFile.exists()) { - try (ObjectInputStream inputStream = new ObjectInputStream(Files.asByteSource(cacheFile).openBufferedStream())) { - cached = (Map, ImmutableSet>) inputStream.readObject(); + try (var in = new ObjectInputStream(asByteSource(cacheFile).openBufferedStream())) { + return (Map, ImmutableSet>) in.readObject(); } catch (IOException | ClassNotFoundException e) { - throw Errors.asRuntime(e); - } - } else { - cached = new HashMap<>(); - try { - Files.createParentDirs(cacheFile); - } catch (IOException e) { - throw Errors.asRuntime(e); + throw asRuntime(e); } } - return (withTransitives, mavenCoordsRaw) -> { - ImmutableSet mavenCoords = ImmutableSet.copyOf(mavenCoordsRaw); - synchronized (TestProvisioner.class) { - ImmutableSet result = cached.get(mavenCoords); - // double-check that depcache pruning hasn't removed them since our cache cached them - boolean needsToBeSet = result == null || !result.stream().allMatch(file -> file.exists() && file.isFile() && file.length() > 0); - if (needsToBeSet) { - result = ImmutableSet.copyOf(input.get().provisionWithTransitives(withTransitives, mavenCoords)); - cached.put(mavenCoords, result); - try (ObjectOutputStream outputStream = new ObjectOutputStream(Files.asByteSink(cacheFile).openBufferedStream())) { - outputStream.writeObject(cached); - } catch (IOException e) { - throw Errors.asRuntime(e); - } - } - return result; - } - }; + try { + createParentDirs(cacheFile); + return new HashMap<>(); + } catch (IOException e) { + throw asRuntime(e); + } } - /** Creates a Provisioner for the mavenCentral repo. */ - public static Provisioner mavenCentral() { - return MAVEN_CENTRAL.get(); + /** + * Creates a Provisioner for the given repositories. + */ + private static Provisioner createWithRepositories(Consumer repositoryConfigurer) { + return createProvisioner(repositoryConfigurer, gradleProject(createTempDir())); } - private static final Supplier MAVEN_CENTRAL = Suppliers.memoize(() -> caching("mavenCentral", () -> createWithRepositories(RepositoryHandler::mavenCentral))); - - /** Creates a Provisioner for the local maven repo for development purpose. */ - public static Provisioner mavenLocal() { - return createWithRepositories(RepositoryHandler::mavenLocal); + private static Provisioner createProvisioner(Consumer repositoryConfigurer, Project project) { + repositoryConfigurer.accept(project.getRepositories()); + return (withTransitives, mavenCoords) -> { + var configuration = applyAttributes(project + .getConfigurations() + .detachedConfiguration(mavenCoords + .stream() + .map(project.getDependencies()::create) + .toArray(Dependency[]::new)), + withTransitives, + mavenCoords, + project); + try { + return configuration.resolve(); + } catch (ResolveException e) { + throw new RuntimeException("Error resolving configuration: " + configuration.getDescription(), e); + } finally { + try (var paths = walk(of(project.getPath()))) { + paths.sorted(reverseOrder()) + .map(Path::toFile) + .forEach(File::delete); + } catch (IOException ignored) {} + } + }; } - /** Creates a Provisioner for the Sonatype snapshots maven repo for development purpose. */ - public static Provisioner snapshots() { - return createWithRepositories(repo -> repo.maven(setup -> setup.setUrl("https://oss.sonatype.org/content/repositories/snapshots"))); + private static Configuration applyAttributes(Configuration configuration, + boolean withTransitives, + Collection mavenCoords, + Project project) { + configuration.setTransitive(withTransitives); + configuration.setDescription(mavenCoords.toString()); + configuration.attributes(attrs -> { + attrs.attribute( + CATEGORY_ATTRIBUTE, + project.getObjects().named(Category.class, LIBRARY)); + attrs.attribute( + BUNDLING_ATTRIBUTE, + project.getObjects().named(Bundling.class, EXTERNAL)); + attrs.attribute( + TARGET_JVM_ENVIRONMENT_ATTRIBUTE, + project.getObjects().named(TargetJvmEnvironment.class, STANDARD_JVM)); + }); + return configuration; } - } diff --git a/testlib/src/test/java/com/diffplug/spotless/PaddedCellTest.java b/testlib/src/test/java/com/diffplug/spotless/PaddedCellTest.java index 2820aadeef..1a62c62097 100644 --- a/testlib/src/test/java/com/diffplug/spotless/PaddedCellTest.java +++ b/testlib/src/test/java/com/diffplug/spotless/PaddedCellTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2024 DiffPlug + * Copyright 2016-2026 DiffPlug * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -116,7 +116,7 @@ void diverging() throws IOException { void cycleOrder() { BiConsumer testCase = (unorderedStr, canonical) -> { List unordered = Arrays.asList(unorderedStr.split(",")); - for (int i = 0; i < unordered.size(); ++i) { + for (int i = 0; i < unordered.size(); i++) { // try every rotation of the list Collections.rotate(unordered, 1); PaddedCell result = CYCLE.create(rootFolder, unordered); From 0641ba00d552ed049a44e418b3d1343fb4ef21f9 Mon Sep 17 00:00:00 2001 From: Vincent Potucek Date: Sat, 10 Jan 2026 21:19:45 +0100 Subject: [PATCH 02/27] [rewrite] add `CodeCleanup` Signed-off-by: Vincent Potucek - https://docs.openrewrite.org/recipes/staticanalysis/codecleanup ``` There were problems parsing lib/src/main/resources/com/diffplug/spotless/npm/eslint-package.json There were problems parsing lib/src/main/resources/com/diffplug/spotless/npm/prettier-package.json There were problems parsing lib/src/main/resources/com/diffplug/spotless/npm/tsfmt-package.json All sources parsed, running active recipes: com.diffplug.spotless.openrewrite.SanityCheck Changes have been made to testlib/src/main/java/com/diffplug/spotless/TestProvisioner.java by: org.openrewrite.staticanalysis.HideUtilityClassConstructor Changes have been made to testlib/src/main/java/com/diffplug/spotless/ReflectionUtil.java by: org.openrewrite.staticanalysis.HideUtilityClassConstructor Changes have been made to testlib/src/test/java/com/diffplug/spotless/PaddedCellTest.java by: org.openrewrite.staticanalysis.ForLoopControlVariablePostfixOperators Please review and commit the results. Estimate time saved: 15m ``` --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 34ecc4acea..fd429b5771 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -66,10 +66,10 @@ jobs: uses: gradle/actions/setup-gradle@v5 - name: build (maven-only) if: matrix.kind == 'maven' - run: ./gradlew :plugin-maven:build -x spotlessCheck -x rewriteDryRun + run: ./gradlew clean :plugin-maven:build - name: build (everything-but-maven) if: matrix.kind == 'gradle' - run: ./gradlew build -x spotlessCheck -x rewriteDryRun -PSPOTLESS_EXCLUDE_MAVEN=true + run: ./gradlew clean build -PSPOTLESS_EXCLUDE_MAVEN=true - name: test npm if: matrix.kind == 'npm' run: ./gradlew testNpm From 91c39a8fe548bd752995cae530392fb9ce1b4fd9 Mon Sep 17 00:00:00 2001 From: Vincent Potucek Date: Sat, 10 Jan 2026 21:28:50 +0100 Subject: [PATCH 03/27] [rewrite] add `CodeCleanup` Signed-off-by: Vincent Potucek - https://docs.openrewrite.org/recipes/staticanalysis/codecleanup ``` There were problems parsing lib/src/main/resources/com/diffplug/spotless/npm/eslint-package.json There were problems parsing lib/src/main/resources/com/diffplug/spotless/npm/prettier-package.json There were problems parsing lib/src/main/resources/com/diffplug/spotless/npm/tsfmt-package.json All sources parsed, running active recipes: com.diffplug.spotless.openrewrite.SanityCheck Changes have been made to testlib/src/main/java/com/diffplug/spotless/TestProvisioner.java by: org.openrewrite.staticanalysis.HideUtilityClassConstructor Changes have been made to testlib/src/main/java/com/diffplug/spotless/ReflectionUtil.java by: org.openrewrite.staticanalysis.HideUtilityClassConstructor Changes have been made to testlib/src/test/java/com/diffplug/spotless/PaddedCellTest.java by: org.openrewrite.staticanalysis.ForLoopControlVariablePostfixOperators Please review and commit the results. Estimate time saved: 15m ``` --- .github/workflows/ci.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fd429b5771..48deb0988d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -64,12 +64,14 @@ jobs: java-version: ${{ matrix.jre }} - name: gradle caching uses: gradle/actions/setup-gradle@v5 + - name: clean + run: ./gradlew clean - name: build (maven-only) if: matrix.kind == 'maven' - run: ./gradlew clean :plugin-maven:build + run: ./gradlew :plugin-maven:build - name: build (everything-but-maven) if: matrix.kind == 'gradle' - run: ./gradlew clean build -PSPOTLESS_EXCLUDE_MAVEN=true + run: ./gradlew build -PSPOTLESS_EXCLUDE_MAVEN=true - name: test npm if: matrix.kind == 'npm' run: ./gradlew testNpm From a36e4a6facf8c6c446a51a737982bb4aa371af78 Mon Sep 17 00:00:00 2001 From: Vincent Potucek Date: Sat, 10 Jan 2026 21:29:48 +0100 Subject: [PATCH 04/27] [rewrite] add `CodeCleanup` Signed-off-by: Vincent Potucek - https://docs.openrewrite.org/recipes/staticanalysis/codecleanup ``` There were problems parsing lib/src/main/resources/com/diffplug/spotless/npm/eslint-package.json There were problems parsing lib/src/main/resources/com/diffplug/spotless/npm/prettier-package.json There were problems parsing lib/src/main/resources/com/diffplug/spotless/npm/tsfmt-package.json All sources parsed, running active recipes: com.diffplug.spotless.openrewrite.SanityCheck Changes have been made to testlib/src/main/java/com/diffplug/spotless/TestProvisioner.java by: org.openrewrite.staticanalysis.HideUtilityClassConstructor Changes have been made to testlib/src/main/java/com/diffplug/spotless/ReflectionUtil.java by: org.openrewrite.staticanalysis.HideUtilityClassConstructor Changes have been made to testlib/src/test/java/com/diffplug/spotless/PaddedCellTest.java by: org.openrewrite.staticanalysis.ForLoopControlVariablePostfixOperators Please review and commit the results. Estimate time saved: 15m ``` --- .github/workflows/ci.yml | 2 +- .github/workflows/codeql-analysis.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 48deb0988d..8eec91007b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -56,7 +56,7 @@ jobs: os: ubuntu-latest runs-on: ${{ matrix.os }} steps: - - name: Checkout + - name: Checkout Code ðŸ“Ĩ uses: actions/checkout@v6 - uses: actions/setup-java@v5 with: diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 9f8f931c62..1c54de5741 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -36,7 +36,7 @@ jobs: # https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection steps: - - name: Checkout repository + - name: Checkout Code ðŸ“Ĩ uses: actions/checkout@v6 with: # We must fetch at least the immediate parents so that if this is @@ -54,7 +54,7 @@ jobs: with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. + # By default, queries listed here will override any specified in a config file. # Prefix the list here with "+" to use these queries and those in the config file. # queries: ./path/to/local/query, your-org/your-repo/queries@main From 71b299c3b5621082f3ca0f416135aa728f8c473f Mon Sep 17 00:00:00 2001 From: Vincent Potucek Date: Sat, 10 Jan 2026 21:31:00 +0100 Subject: [PATCH 05/27] [rewrite] add `CodeCleanup` Signed-off-by: Vincent Potucek - https://docs.openrewrite.org/recipes/staticanalysis/codecleanup ``` There were problems parsing lib/src/main/resources/com/diffplug/spotless/npm/eslint-package.json There were problems parsing lib/src/main/resources/com/diffplug/spotless/npm/prettier-package.json There were problems parsing lib/src/main/resources/com/diffplug/spotless/npm/tsfmt-package.json All sources parsed, running active recipes: com.diffplug.spotless.openrewrite.SanityCheck Changes have been made to testlib/src/main/java/com/diffplug/spotless/TestProvisioner.java by: org.openrewrite.staticanalysis.HideUtilityClassConstructor Changes have been made to testlib/src/main/java/com/diffplug/spotless/ReflectionUtil.java by: org.openrewrite.staticanalysis.HideUtilityClassConstructor Changes have been made to testlib/src/test/java/com/diffplug/spotless/PaddedCellTest.java by: org.openrewrite.staticanalysis.ForLoopControlVariablePostfixOperators Please review and commit the results. Estimate time saved: 15m ``` --- .github/workflows/changelog-print.yml | 2 +- .github/workflows/ci.yml | 2 +- .github/workflows/deploy.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/changelog-print.yml b/.github/workflows/changelog-print.yml index 184608f0b1..86040e0f71 100644 --- a/.github/workflows/changelog-print.yml +++ b/.github/workflows/changelog-print.yml @@ -14,6 +14,6 @@ jobs: with: java-version: 21 distribution: 'temurin' - - name: gradle caching + - name: Setup Gradle 🐘 uses: gradle/actions/setup-gradle@v5 - run: ./gradlew changelogPrint diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8eec91007b..a80f3eb6c6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -62,7 +62,7 @@ jobs: with: distribution: "temurin" java-version: ${{ matrix.jre }} - - name: gradle caching + - name: Setup Gradle 🐘 uses: gradle/actions/setup-gradle@v5 - name: clean run: ./gradlew clean diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 31e4dd2711..ff5824a20a 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -42,7 +42,7 @@ jobs: with: java-version: 21 distribution: 'temurin' - - name: gradle caching + - name: Setup Gradle 🐘 uses: gradle/actions/setup-gradle@v5 - name: git fetch origin main run: git fetch origin main From f0555346085629ed57cd41071e31b69c9f693e9a Mon Sep 17 00:00:00 2001 From: Vincent Potucek Date: Sat, 10 Jan 2026 21:33:22 +0100 Subject: [PATCH 06/27] [rewrite] add `CodeCleanup` Signed-off-by: Vincent Potucek - https://docs.openrewrite.org/recipes/staticanalysis/codecleanup ``` There were problems parsing lib/src/main/resources/com/diffplug/spotless/npm/eslint-package.json There were problems parsing lib/src/main/resources/com/diffplug/spotless/npm/prettier-package.json There were problems parsing lib/src/main/resources/com/diffplug/spotless/npm/tsfmt-package.json All sources parsed, running active recipes: com.diffplug.spotless.openrewrite.SanityCheck Changes have been made to testlib/src/main/java/com/diffplug/spotless/TestProvisioner.java by: org.openrewrite.staticanalysis.HideUtilityClassConstructor Changes have been made to testlib/src/main/java/com/diffplug/spotless/ReflectionUtil.java by: org.openrewrite.staticanalysis.HideUtilityClassConstructor Changes have been made to testlib/src/test/java/com/diffplug/spotless/PaddedCellTest.java by: org.openrewrite.staticanalysis.ForLoopControlVariablePostfixOperators Please review and commit the results. Estimate time saved: 15m ``` --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a80f3eb6c6..c2189ffbe8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -66,10 +66,10 @@ jobs: uses: gradle/actions/setup-gradle@v5 - name: clean run: ./gradlew clean - - name: build (maven-only) + - name: Build ðŸ“Ķ Maven ðŸŠķ if: matrix.kind == 'maven' run: ./gradlew :plugin-maven:build - - name: build (everything-but-maven) + - name: Build ðŸ“Ķ Gradle 🐘 if: matrix.kind == 'gradle' run: ./gradlew build -PSPOTLESS_EXCLUDE_MAVEN=true - name: test npm From 19acd469fdc13252f4cba4168d00a76e5e2d5cf2 Mon Sep 17 00:00:00 2001 From: Vincent Potucek Date: Sat, 10 Jan 2026 21:36:24 +0100 Subject: [PATCH 07/27] [rewrite] add `CodeCleanup` Signed-off-by: Vincent Potucek - https://docs.openrewrite.org/recipes/staticanalysis/codecleanup ``` There were problems parsing lib/src/main/resources/com/diffplug/spotless/npm/eslint-package.json There were problems parsing lib/src/main/resources/com/diffplug/spotless/npm/prettier-package.json There were problems parsing lib/src/main/resources/com/diffplug/spotless/npm/tsfmt-package.json All sources parsed, running active recipes: com.diffplug.spotless.openrewrite.SanityCheck Changes have been made to testlib/src/main/java/com/diffplug/spotless/TestProvisioner.java by: org.openrewrite.staticanalysis.HideUtilityClassConstructor Changes have been made to testlib/src/main/java/com/diffplug/spotless/ReflectionUtil.java by: org.openrewrite.staticanalysis.HideUtilityClassConstructor Changes have been made to testlib/src/test/java/com/diffplug/spotless/PaddedCellTest.java by: org.openrewrite.staticanalysis.ForLoopControlVariablePostfixOperators Please review and commit the results. Estimate time saved: 15m ``` --- rewrite.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/rewrite.yml b/rewrite.yml index 92c936b8bd..5cfe4964ed 100644 --- a/rewrite.yml +++ b/rewrite.yml @@ -7,6 +7,7 @@ recipeList: - org.openrewrite.gradle.EnableGradleBuildCache - org.openrewrite.gradle.EnableGradleParallelExecution - org.openrewrite.gradle.GradleBestPractices + - org.openrewrite.hcl.format.RemoveTrailingWhitespace - org.openrewrite.java.RemoveUnusedImports - org.openrewrite.java.ShortenFullyQualifiedTypeReferences - org.openrewrite.java.SimplifySingleElementAnnotation From a52d33dddb97ba060557549ff2202b820ae5f47a Mon Sep 17 00:00:00 2001 From: Vincent Potucek Date: Sat, 10 Jan 2026 21:40:22 +0100 Subject: [PATCH 08/27] [rewrite] add `CodeCleanup` Signed-off-by: Vincent Potucek - https://docs.openrewrite.org/recipes/staticanalysis/codecleanup ``` There were problems parsing lib/src/main/resources/com/diffplug/spotless/npm/eslint-package.json There were problems parsing lib/src/main/resources/com/diffplug/spotless/npm/prettier-package.json There were problems parsing lib/src/main/resources/com/diffplug/spotless/npm/tsfmt-package.json All sources parsed, running active recipes: com.diffplug.spotless.openrewrite.SanityCheck Changes have been made to testlib/src/main/java/com/diffplug/spotless/TestProvisioner.java by: org.openrewrite.staticanalysis.HideUtilityClassConstructor Changes have been made to testlib/src/main/java/com/diffplug/spotless/ReflectionUtil.java by: org.openrewrite.staticanalysis.HideUtilityClassConstructor Changes have been made to testlib/src/test/java/com/diffplug/spotless/PaddedCellTest.java by: org.openrewrite.staticanalysis.ForLoopControlVariablePostfixOperators Please review and commit the results. Estimate time saved: 15m ``` --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c2189ffbe8..6147dc03b2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,6 +32,8 @@ jobs: run: ./gradlew clean spotlessCheck - name: Rewrite â™ŧïļ run: ./gradlew clean rewriteDryRun + - name: Error Prone 🚧 + run: ./gradlew clean assemble - name: Assemble Test Classes ⚙ïļ run: ./gradlew clean assemble testClasses build: From c89207c0680b42058403f31dfa9dbcde6880fdfb Mon Sep 17 00:00:00 2001 From: Vincent Potucek Date: Sat, 10 Jan 2026 21:41:30 +0100 Subject: [PATCH 09/27] [rewrite] add `CodeCleanup` Signed-off-by: Vincent Potucek - https://docs.openrewrite.org/recipes/staticanalysis/codecleanup ``` There were problems parsing lib/src/main/resources/com/diffplug/spotless/npm/eslint-package.json There were problems parsing lib/src/main/resources/com/diffplug/spotless/npm/prettier-package.json There were problems parsing lib/src/main/resources/com/diffplug/spotless/npm/tsfmt-package.json All sources parsed, running active recipes: com.diffplug.spotless.openrewrite.SanityCheck Changes have been made to testlib/src/main/java/com/diffplug/spotless/TestProvisioner.java by: org.openrewrite.staticanalysis.HideUtilityClassConstructor Changes have been made to testlib/src/main/java/com/diffplug/spotless/ReflectionUtil.java by: org.openrewrite.staticanalysis.HideUtilityClassConstructor Changes have been made to testlib/src/test/java/com/diffplug/spotless/PaddedCellTest.java by: org.openrewrite.staticanalysis.ForLoopControlVariablePostfixOperators Please review and commit the results. Estimate time saved: 15m ``` --- gradle/error-prone.gradle | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/gradle/error-prone.gradle b/gradle/error-prone.gradle index b834bac630..e9b29655a2 100644 --- a/gradle/error-prone.gradle +++ b/gradle/error-prone.gradle @@ -4,18 +4,18 @@ apply plugin: 'net.ltgt.errorprone' tasks.withType(JavaCompile).configureEach { options.errorprone { - disableAllWarnings = true // https://github.com/diffplug/spotless/issues/2745 https://github.com/google/error-prone/issues/5365 - disable( - // consider fix, or reasoning. - 'AnnotateFormatMethod', // We don`t want to use ErrorProne's annotations. - 'DoNotCallSuggester', // We don`t want to use ErrorProne's annotations. - 'FunctionalInterfaceMethodChanged', - 'ImmutableEnumChecker', // We don`t want to use ErrorProne's annotations. - 'InlineMeSuggester', // We don`t want to use ErrorProne's annotations. - 'JavaxInjectOnAbstractMethod', - 'OverridesJavaxInjectableMethod', - 'ReturnValueIgnored', // We don`t want to use ErrorProne's annotations. - ) +// disableAllWarnings = true // https://github.com/diffplug/spotless/issues/2745 https://github.com/google/error-prone/issues/5365 +// disable( +// // consider fix, or reasoning. +// 'AnnotateFormatMethod', // We don`t want to use ErrorProne's annotations. +// 'DoNotCallSuggester', // We don`t want to use ErrorProne's annotations. +// 'FunctionalInterfaceMethodChanged', +// 'ImmutableEnumChecker', // We don`t want to use ErrorProne's annotations. +// 'InlineMeSuggester', // We don`t want to use ErrorProne's annotations. +// 'JavaxInjectOnAbstractMethod', +// 'OverridesJavaxInjectableMethod', +// 'ReturnValueIgnored', // We don`t want to use ErrorProne's annotations. +// ) error( 'ReturnValueIgnored', 'SelfAssignment', @@ -30,7 +30,7 @@ tasks.withType(JavaCompile).configureEach { '.*/GradleIntegrationHarness.java|'+ '.*/SelfTest.java' ) - if (!getenv().containsKey('CI') && getenv('IN_PLACE')?.toBoolean()) { + if (!getenv().containsKey('CI') && getenv('IN_PLACeE')?.toBoolean()) { errorproneArgs.addAll( '-XepPatchLocation:IN_PLACE', '-XepPatchChecks:' + From 2ac524eb78d42d843fce74c95ba67bd72960236c Mon Sep 17 00:00:00 2001 From: Vincent Potucek Date: Sat, 10 Jan 2026 21:42:57 +0100 Subject: [PATCH 10/27] [rewrite] add `CodeCleanup` Signed-off-by: Vincent Potucek - https://docs.openrewrite.org/recipes/staticanalysis/codecleanup ``` There were problems parsing lib/src/main/resources/com/diffplug/spotless/npm/eslint-package.json There were problems parsing lib/src/main/resources/com/diffplug/spotless/npm/prettier-package.json There were problems parsing lib/src/main/resources/com/diffplug/spotless/npm/tsfmt-package.json All sources parsed, running active recipes: com.diffplug.spotless.openrewrite.SanityCheck Changes have been made to testlib/src/main/java/com/diffplug/spotless/TestProvisioner.java by: org.openrewrite.staticanalysis.HideUtilityClassConstructor Changes have been made to testlib/src/main/java/com/diffplug/spotless/ReflectionUtil.java by: org.openrewrite.staticanalysis.HideUtilityClassConstructor Changes have been made to testlib/src/test/java/com/diffplug/spotless/PaddedCellTest.java by: org.openrewrite.staticanalysis.ForLoopControlVariablePostfixOperators Please review and commit the results. Estimate time saved: 15m ``` --- gradle/error-prone.gradle | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/gradle/error-prone.gradle b/gradle/error-prone.gradle index e9b29655a2..b834bac630 100644 --- a/gradle/error-prone.gradle +++ b/gradle/error-prone.gradle @@ -4,18 +4,18 @@ apply plugin: 'net.ltgt.errorprone' tasks.withType(JavaCompile).configureEach { options.errorprone { -// disableAllWarnings = true // https://github.com/diffplug/spotless/issues/2745 https://github.com/google/error-prone/issues/5365 -// disable( -// // consider fix, or reasoning. -// 'AnnotateFormatMethod', // We don`t want to use ErrorProne's annotations. -// 'DoNotCallSuggester', // We don`t want to use ErrorProne's annotations. -// 'FunctionalInterfaceMethodChanged', -// 'ImmutableEnumChecker', // We don`t want to use ErrorProne's annotations. -// 'InlineMeSuggester', // We don`t want to use ErrorProne's annotations. -// 'JavaxInjectOnAbstractMethod', -// 'OverridesJavaxInjectableMethod', -// 'ReturnValueIgnored', // We don`t want to use ErrorProne's annotations. -// ) + disableAllWarnings = true // https://github.com/diffplug/spotless/issues/2745 https://github.com/google/error-prone/issues/5365 + disable( + // consider fix, or reasoning. + 'AnnotateFormatMethod', // We don`t want to use ErrorProne's annotations. + 'DoNotCallSuggester', // We don`t want to use ErrorProne's annotations. + 'FunctionalInterfaceMethodChanged', + 'ImmutableEnumChecker', // We don`t want to use ErrorProne's annotations. + 'InlineMeSuggester', // We don`t want to use ErrorProne's annotations. + 'JavaxInjectOnAbstractMethod', + 'OverridesJavaxInjectableMethod', + 'ReturnValueIgnored', // We don`t want to use ErrorProne's annotations. + ) error( 'ReturnValueIgnored', 'SelfAssignment', @@ -30,7 +30,7 @@ tasks.withType(JavaCompile).configureEach { '.*/GradleIntegrationHarness.java|'+ '.*/SelfTest.java' ) - if (!getenv().containsKey('CI') && getenv('IN_PLACeE')?.toBoolean()) { + if (!getenv().containsKey('CI') && getenv('IN_PLACE')?.toBoolean()) { errorproneArgs.addAll( '-XepPatchLocation:IN_PLACE', '-XepPatchChecks:' + From 5def918c49385af53f4239a3f8ea9d5e974244e9 Mon Sep 17 00:00:00 2001 From: Vincent Potucek Date: Sat, 10 Jan 2026 21:46:07 +0100 Subject: [PATCH 11/27] [rewrite] add `CodeCleanup` Signed-off-by: Vincent Potucek - https://docs.openrewrite.org/recipes/staticanalysis/codecleanup ``` There were problems parsing lib/src/main/resources/com/diffplug/spotless/npm/eslint-package.json There were problems parsing lib/src/main/resources/com/diffplug/spotless/npm/prettier-package.json There were problems parsing lib/src/main/resources/com/diffplug/spotless/npm/tsfmt-package.json All sources parsed, running active recipes: com.diffplug.spotless.openrewrite.SanityCheck Changes have been made to testlib/src/main/java/com/diffplug/spotless/TestProvisioner.java by: org.openrewrite.staticanalysis.HideUtilityClassConstructor Changes have been made to testlib/src/main/java/com/diffplug/spotless/ReflectionUtil.java by: org.openrewrite.staticanalysis.HideUtilityClassConstructor Changes have been made to testlib/src/test/java/com/diffplug/spotless/PaddedCellTest.java by: org.openrewrite.staticanalysis.ForLoopControlVariablePostfixOperators Please review and commit the results. Estimate time saved: 15m ``` --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6147dc03b2..7583735501 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,12 +30,12 @@ jobs: uses: gradle/actions/setup-gradle@v5 - name: Spotless âœĻ run: ./gradlew clean spotlessCheck - - name: Rewrite â™ŧïļ - run: ./gradlew clean rewriteDryRun - name: Error Prone 🚧 run: ./gradlew clean assemble - - name: Assemble Test Classes ⚙ïļ - run: ./gradlew clean assemble testClasses + - name: Test Classes ⚙ïļ + run: ./gradlew clean testClasses + - name: Rewrite â™ŧïļ + run: ./gradlew clean rewriteDryRun build: name: Build 🏗ïļ needs: sanity-check From b20f1b7f80ec3c03fc4a0cdeabea6b025711e860 Mon Sep 17 00:00:00 2001 From: Vincent Potucek Date: Sat, 10 Jan 2026 21:54:31 +0100 Subject: [PATCH 12/27] [rewrite] add `CodeCleanup` Signed-off-by: Vincent Potucek - https://docs.openrewrite.org/recipes/staticanalysis/codecleanup ``` There were problems parsing lib/src/main/resources/com/diffplug/spotless/npm/eslint-package.json There were problems parsing lib/src/main/resources/com/diffplug/spotless/npm/prettier-package.json There were problems parsing lib/src/main/resources/com/diffplug/spotless/npm/tsfmt-package.json All sources parsed, running active recipes: com.diffplug.spotless.openrewrite.SanityCheck Changes have been made to testlib/src/main/java/com/diffplug/spotless/TestProvisioner.java by: org.openrewrite.staticanalysis.HideUtilityClassConstructor Changes have been made to testlib/src/main/java/com/diffplug/spotless/ReflectionUtil.java by: org.openrewrite.staticanalysis.HideUtilityClassConstructor Changes have been made to testlib/src/test/java/com/diffplug/spotless/PaddedCellTest.java by: org.openrewrite.staticanalysis.ForLoopControlVariablePostfixOperators Please review and commit the results. Estimate time saved: 15m ``` --- .github/workflows/ci.yml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7583735501..819da58f87 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -66,18 +66,16 @@ jobs: java-version: ${{ matrix.jre }} - name: Setup Gradle 🐘 uses: gradle/actions/setup-gradle@v5 - - name: clean - run: ./gradlew clean - name: Build ðŸ“Ķ Maven ðŸŠķ if: matrix.kind == 'maven' run: ./gradlew :plugin-maven:build - name: Build ðŸ“Ķ Gradle 🐘 if: matrix.kind == 'gradle' run: ./gradlew build -PSPOTLESS_EXCLUDE_MAVEN=true - - name: test npm + - name: Test npm if: matrix.kind == 'npm' run: ./gradlew testNpm - - name: Setup go + - name: Setup Go if: matrix.kind == 'shfmt' uses: actions/setup-go@v6 with: @@ -89,7 +87,7 @@ jobs: - name: Test shfmt if: matrix.kind == 'shfmt' run: ./gradlew testShfmt - - name: Test idea + - name: Test IDEA if: matrix.kind == 'idea' run: | download_link=$(curl https://data.services.jetbrains.com/products/releases\?code\=IIC\&latest\=true\&type\=release | jq -r '.IIC[0].downloads.linux.link') @@ -99,7 +97,7 @@ jobs: export PATH=${PATH}:$(pwd)/bin cd .. ./gradlew testIdea - - name: junit result + - name: Junit Report uses: mikepenz/action-junit-report@v6 if: always() # always run even if the previous step fails. with: From 87314148beaca84e14de91944bbdd186724751e6 Mon Sep 17 00:00:00 2001 From: Vincent Potucek Date: Sat, 10 Jan 2026 21:56:02 +0100 Subject: [PATCH 13/27] [rewrite] add `CodeCleanup` Signed-off-by: Vincent Potucek - https://docs.openrewrite.org/recipes/staticanalysis/codecleanup ``` There were problems parsing lib/src/main/resources/com/diffplug/spotless/npm/eslint-package.json There were problems parsing lib/src/main/resources/com/diffplug/spotless/npm/prettier-package.json There were problems parsing lib/src/main/resources/com/diffplug/spotless/npm/tsfmt-package.json All sources parsed, running active recipes: com.diffplug.spotless.openrewrite.SanityCheck Changes have been made to testlib/src/main/java/com/diffplug/spotless/TestProvisioner.java by: org.openrewrite.staticanalysis.HideUtilityClassConstructor Changes have been made to testlib/src/main/java/com/diffplug/spotless/ReflectionUtil.java by: org.openrewrite.staticanalysis.HideUtilityClassConstructor Changes have been made to testlib/src/test/java/com/diffplug/spotless/PaddedCellTest.java by: org.openrewrite.staticanalysis.ForLoopControlVariablePostfixOperators Please review and commit the results. Estimate time saved: 15m ``` --- .github/workflows/ci.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 819da58f87..44cf3fa0ea 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -82,8 +82,7 @@ jobs: go-version: 'stable' - name: Install shfmt if: matrix.kind == 'shfmt' - run: | - go install mvdan.cc/sh/v3/cmd/shfmt@${{ matrix.shfmt-version }} + run: go install mvdan.cc/sh/v3/cmd/shfmt@${{ matrix.shfmt-version }} - name: Test shfmt if: matrix.kind == 'shfmt' run: ./gradlew testShfmt From dc1ba60432ccc825016a8f0ee78fa2de08783e7e Mon Sep 17 00:00:00 2001 From: Vincent Potucek Date: Sat, 10 Jan 2026 21:58:45 +0100 Subject: [PATCH 14/27] [rewrite] add `CodeCleanup` Signed-off-by: Vincent Potucek - https://docs.openrewrite.org/recipes/staticanalysis/codecleanup ``` There were problems parsing lib/src/main/resources/com/diffplug/spotless/npm/eslint-package.json There were problems parsing lib/src/main/resources/com/diffplug/spotless/npm/prettier-package.json There were problems parsing lib/src/main/resources/com/diffplug/spotless/npm/tsfmt-package.json All sources parsed, running active recipes: com.diffplug.spotless.openrewrite.SanityCheck Changes have been made to testlib/src/main/java/com/diffplug/spotless/TestProvisioner.java by: org.openrewrite.staticanalysis.HideUtilityClassConstructor Changes have been made to testlib/src/main/java/com/diffplug/spotless/ReflectionUtil.java by: org.openrewrite.staticanalysis.HideUtilityClassConstructor Changes have been made to testlib/src/test/java/com/diffplug/spotless/PaddedCellTest.java by: org.openrewrite.staticanalysis.ForLoopControlVariablePostfixOperators Please review and commit the results. Estimate time saved: 15m ``` --- .github/workflows/ci.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 44cf3fa0ea..7649ece9d8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,7 +24,7 @@ jobs: fetch-depth: 0 - uses: actions/setup-java@v5 with: - distribution: "temurin" + distribution: temurin java-version: 21 - name: Setup Gradle 🐘 uses: gradle/actions/setup-gradle@v5 @@ -62,7 +62,7 @@ jobs: uses: actions/checkout@v6 - uses: actions/setup-java@v5 with: - distribution: "temurin" + distribution: temurin java-version: ${{ matrix.jre }} - name: Setup Gradle 🐘 uses: gradle/actions/setup-gradle@v5 @@ -90,7 +90,7 @@ jobs: if: matrix.kind == 'idea' run: | download_link=$(curl https://data.services.jetbrains.com/products/releases\?code\=IIC\&latest\=true\&type\=release | jq -r '.IIC[0].downloads.linux.link') - curl --location "$download_link" -o idea.tar.gz + curl --location $download_link -o idea.tar.gz tar -xf idea.tar.gz cd idea-IC* export PATH=${PATH}:$(pwd)/bin @@ -111,10 +111,10 @@ jobs: runs-on: ubuntu-latest if: always() steps: - - name: Check + - name: Check ðŸĶ‰ run: | results=$(tr -d '\n' <<< '${{ toJSON(needs.*.result) }}') - if ! grep -q -v -E '(failure|cancelled)' <<< "$results"; then + if ! grep -q -v -E '(failure|cancelled)' <<< $results; then echo ❌ One or more required jobs failed. exit 1 fi From 5f4b4c0a9920ec1862e1ce6308daf5a93ed7e025 Mon Sep 17 00:00:00 2001 From: Vincent Potucek Date: Sat, 10 Jan 2026 21:59:29 +0100 Subject: [PATCH 15/27] [rewrite] add `CodeCleanup` Signed-off-by: Vincent Potucek - https://docs.openrewrite.org/recipes/staticanalysis/codecleanup ``` There were problems parsing lib/src/main/resources/com/diffplug/spotless/npm/eslint-package.json There were problems parsing lib/src/main/resources/com/diffplug/spotless/npm/prettier-package.json There were problems parsing lib/src/main/resources/com/diffplug/spotless/npm/tsfmt-package.json All sources parsed, running active recipes: com.diffplug.spotless.openrewrite.SanityCheck Changes have been made to testlib/src/main/java/com/diffplug/spotless/TestProvisioner.java by: org.openrewrite.staticanalysis.HideUtilityClassConstructor Changes have been made to testlib/src/main/java/com/diffplug/spotless/ReflectionUtil.java by: org.openrewrite.staticanalysis.HideUtilityClassConstructor Changes have been made to testlib/src/test/java/com/diffplug/spotless/PaddedCellTest.java by: org.openrewrite.staticanalysis.ForLoopControlVariablePostfixOperators Please review and commit the results. Estimate time saved: 15m ``` --- .github/workflows/ci.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7649ece9d8..ec90a19184 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -67,27 +67,27 @@ jobs: - name: Setup Gradle 🐘 uses: gradle/actions/setup-gradle@v5 - name: Build ðŸ“Ķ Maven ðŸŠķ - if: matrix.kind == 'maven' + if: matrix.kind == maven run: ./gradlew :plugin-maven:build - name: Build ðŸ“Ķ Gradle 🐘 - if: matrix.kind == 'gradle' + if: matrix.kind == gradle run: ./gradlew build -PSPOTLESS_EXCLUDE_MAVEN=true - name: Test npm - if: matrix.kind == 'npm' + if: matrix.kind == npm run: ./gradlew testNpm - name: Setup Go - if: matrix.kind == 'shfmt' + if: matrix.kind == shfmt uses: actions/setup-go@v6 with: - go-version: 'stable' + go-version: stable - name: Install shfmt - if: matrix.kind == 'shfmt' + if: matrix.kind == shfmt run: go install mvdan.cc/sh/v3/cmd/shfmt@${{ matrix.shfmt-version }} - name: Test shfmt - if: matrix.kind == 'shfmt' + if: matrix.kind == shfmt run: ./gradlew testShfmt - name: Test IDEA - if: matrix.kind == 'idea' + if: matrix.kind == idea run: | download_link=$(curl https://data.services.jetbrains.com/products/releases\?code\=IIC\&latest\=true\&type\=release | jq -r '.IIC[0].downloads.linux.link') curl --location $download_link -o idea.tar.gz From 5a9b6f35707ef0186c6393bf2e0acfb85daf8dcc Mon Sep 17 00:00:00 2001 From: Vincent Potucek Date: Sat, 10 Jan 2026 22:00:19 +0100 Subject: [PATCH 16/27] [rewrite] add `CodeCleanup` Signed-off-by: Vincent Potucek - https://docs.openrewrite.org/recipes/staticanalysis/codecleanup ``` There were problems parsing lib/src/main/resources/com/diffplug/spotless/npm/eslint-package.json There were problems parsing lib/src/main/resources/com/diffplug/spotless/npm/prettier-package.json There were problems parsing lib/src/main/resources/com/diffplug/spotless/npm/tsfmt-package.json All sources parsed, running active recipes: com.diffplug.spotless.openrewrite.SanityCheck Changes have been made to testlib/src/main/java/com/diffplug/spotless/TestProvisioner.java by: org.openrewrite.staticanalysis.HideUtilityClassConstructor Changes have been made to testlib/src/main/java/com/diffplug/spotless/ReflectionUtil.java by: org.openrewrite.staticanalysis.HideUtilityClassConstructor Changes have been made to testlib/src/test/java/com/diffplug/spotless/PaddedCellTest.java by: org.openrewrite.staticanalysis.ForLoopControlVariablePostfixOperators Please review and commit the results. Estimate time saved: 15m ``` --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ec90a19184..ed3b5ee304 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -66,10 +66,10 @@ jobs: java-version: ${{ matrix.jre }} - name: Setup Gradle 🐘 uses: gradle/actions/setup-gradle@v5 - - name: Build ðŸ“Ķ Maven ðŸŠķ + - name: Build 🏗ïļ Maven ðŸŠķ if: matrix.kind == maven run: ./gradlew :plugin-maven:build - - name: Build ðŸ“Ķ Gradle 🐘 + - name: Build 🏗ïļ Gradle 🐘 if: matrix.kind == gradle run: ./gradlew build -PSPOTLESS_EXCLUDE_MAVEN=true - name: Test npm From bd88ca5debc9c3f505178bcbc53f6be51672e7d1 Mon Sep 17 00:00:00 2001 From: Vincent Potucek Date: Sat, 10 Jan 2026 22:03:28 +0100 Subject: [PATCH 17/27] [rewrite] add `CodeCleanup` Signed-off-by: Vincent Potucek - https://docs.openrewrite.org/recipes/staticanalysis/codecleanup ``` There were problems parsing lib/src/main/resources/com/diffplug/spotless/npm/eslint-package.json There were problems parsing lib/src/main/resources/com/diffplug/spotless/npm/prettier-package.json There were problems parsing lib/src/main/resources/com/diffplug/spotless/npm/tsfmt-package.json All sources parsed, running active recipes: com.diffplug.spotless.openrewrite.SanityCheck Changes have been made to testlib/src/main/java/com/diffplug/spotless/TestProvisioner.java by: org.openrewrite.staticanalysis.HideUtilityClassConstructor Changes have been made to testlib/src/main/java/com/diffplug/spotless/ReflectionUtil.java by: org.openrewrite.staticanalysis.HideUtilityClassConstructor Changes have been made to testlib/src/test/java/com/diffplug/spotless/PaddedCellTest.java by: org.openrewrite.staticanalysis.ForLoopControlVariablePostfixOperators Please review and commit the results. Estimate time saved: 15m ``` --- .github/workflows/ci.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ed3b5ee304..8dc00805ea 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,7 +32,7 @@ jobs: run: ./gradlew clean spotlessCheck - name: Error Prone 🚧 run: ./gradlew clean assemble - - name: Test Classes ⚙ïļ + - name: Test 📊 Classes ⚙ïļ run: ./gradlew clean testClasses - name: Rewrite â™ŧïļ run: ./gradlew clean rewriteDryRun @@ -66,13 +66,13 @@ jobs: java-version: ${{ matrix.jre }} - name: Setup Gradle 🐘 uses: gradle/actions/setup-gradle@v5 - - name: Build 🏗ïļ Maven ðŸŠķ + - name: Build Maven ðŸŠķ if: matrix.kind == maven run: ./gradlew :plugin-maven:build - - name: Build 🏗ïļ Gradle 🐘 + - name: Build Gradle 🐘 if: matrix.kind == gradle run: ./gradlew build -PSPOTLESS_EXCLUDE_MAVEN=true - - name: Test npm + - name: Test npm 📊 if: matrix.kind == npm run: ./gradlew testNpm - name: Setup Go @@ -80,13 +80,13 @@ jobs: uses: actions/setup-go@v6 with: go-version: stable - - name: Install shfmt + - name: Install shfmt ðŸ“Ĩ if: matrix.kind == shfmt run: go install mvdan.cc/sh/v3/cmd/shfmt@${{ matrix.shfmt-version }} - - name: Test shfmt + - name: Test shfmt 📊 if: matrix.kind == shfmt run: ./gradlew testShfmt - - name: Test IDEA + - name: Test IDEA 📊 if: matrix.kind == idea run: | download_link=$(curl https://data.services.jetbrains.com/products/releases\?code\=IIC\&latest\=true\&type\=release | jq -r '.IIC[0].downloads.linux.link') @@ -96,7 +96,7 @@ jobs: export PATH=${PATH}:$(pwd)/bin cd .. ./gradlew testIdea - - name: Junit Report + - name: Junit Report 📋 uses: mikepenz/action-junit-report@v6 if: always() # always run even if the previous step fails. with: From ddfcbff55e493f9f08825fb70493062f632b7235 Mon Sep 17 00:00:00 2001 From: Vincent Potucek Date: Sat, 10 Jan 2026 22:05:29 +0100 Subject: [PATCH 18/27] [rewrite] add `CodeCleanup` Signed-off-by: Vincent Potucek - https://docs.openrewrite.org/recipes/staticanalysis/codecleanup ``` There were problems parsing lib/src/main/resources/com/diffplug/spotless/npm/eslint-package.json There were problems parsing lib/src/main/resources/com/diffplug/spotless/npm/prettier-package.json There were problems parsing lib/src/main/resources/com/diffplug/spotless/npm/tsfmt-package.json All sources parsed, running active recipes: com.diffplug.spotless.openrewrite.SanityCheck Changes have been made to testlib/src/main/java/com/diffplug/spotless/TestProvisioner.java by: org.openrewrite.staticanalysis.HideUtilityClassConstructor Changes have been made to testlib/src/main/java/com/diffplug/spotless/ReflectionUtil.java by: org.openrewrite.staticanalysis.HideUtilityClassConstructor Changes have been made to testlib/src/test/java/com/diffplug/spotless/PaddedCellTest.java by: org.openrewrite.staticanalysis.ForLoopControlVariablePostfixOperators Please review and commit the results. Estimate time saved: 15m ``` --- .github/workflows/ci.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8dc00805ea..5a713182ea 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -67,27 +67,27 @@ jobs: - name: Setup Gradle 🐘 uses: gradle/actions/setup-gradle@v5 - name: Build Maven ðŸŠķ - if: matrix.kind == maven + if: matrix.kind == 'maven' run: ./gradlew :plugin-maven:build - name: Build Gradle 🐘 - if: matrix.kind == gradle + if: matrix.kind == 'gradle' run: ./gradlew build -PSPOTLESS_EXCLUDE_MAVEN=true - name: Test npm 📊 - if: matrix.kind == npm + if: matrix.kind == 'npm' run: ./gradlew testNpm - name: Setup Go - if: matrix.kind == shfmt + if: matrix.kind == 'shfmt' uses: actions/setup-go@v6 with: go-version: stable - name: Install shfmt ðŸ“Ĩ - if: matrix.kind == shfmt + if: matrix.kind == 'shfmt' run: go install mvdan.cc/sh/v3/cmd/shfmt@${{ matrix.shfmt-version }} - name: Test shfmt 📊 - if: matrix.kind == shfmt + if: matrix.kind == 'shfmt' run: ./gradlew testShfmt - name: Test IDEA 📊 - if: matrix.kind == idea + if: matrix.kind == 'idea' run: | download_link=$(curl https://data.services.jetbrains.com/products/releases\?code\=IIC\&latest\=true\&type\=release | jq -r '.IIC[0].downloads.linux.link') curl --location $download_link -o idea.tar.gz From b0632186bb183fb25852b6062d0dc5067ad4301e Mon Sep 17 00:00:00 2001 From: Vincent Potucek Date: Sat, 10 Jan 2026 22:15:22 +0100 Subject: [PATCH 19/27] [rewrite] add `CodeCleanup` Signed-off-by: Vincent Potucek - https://docs.openrewrite.org/recipes/staticanalysis/codecleanup ``` There were problems parsing lib/src/main/resources/com/diffplug/spotless/npm/eslint-package.json There were problems parsing lib/src/main/resources/com/diffplug/spotless/npm/prettier-package.json There were problems parsing lib/src/main/resources/com/diffplug/spotless/npm/tsfmt-package.json All sources parsed, running active recipes: com.diffplug.spotless.openrewrite.SanityCheck Changes have been made to testlib/src/main/java/com/diffplug/spotless/TestProvisioner.java by: org.openrewrite.staticanalysis.HideUtilityClassConstructor Changes have been made to testlib/src/main/java/com/diffplug/spotless/ReflectionUtil.java by: org.openrewrite.staticanalysis.HideUtilityClassConstructor Changes have been made to testlib/src/test/java/com/diffplug/spotless/PaddedCellTest.java by: org.openrewrite.staticanalysis.ForLoopControlVariablePostfixOperators Please review and commit the results. Estimate time saved: 15m ``` --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5a713182ea..5b28e00c1c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -68,10 +68,10 @@ jobs: uses: gradle/actions/setup-gradle@v5 - name: Build Maven ðŸŠķ if: matrix.kind == 'maven' - run: ./gradlew :plugin-maven:build + run: ./gradlew :plugin-maven:build -x spotlessCheck - name: Build Gradle 🐘 if: matrix.kind == 'gradle' - run: ./gradlew build -PSPOTLESS_EXCLUDE_MAVEN=true + run: ./gradlew build -PSPOTLESS_EXCLUDE_MAVEN=true -x spotlessCheck - name: Test npm 📊 if: matrix.kind == 'npm' run: ./gradlew testNpm From 92c51036bdfcef7da2992d109df81722b77f423d Mon Sep 17 00:00:00 2001 From: Vincent Potucek Date: Sat, 10 Jan 2026 22:34:57 +0100 Subject: [PATCH 20/27] [rewrite] add `CodeCleanup` Signed-off-by: Vincent Potucek - https://docs.openrewrite.org/recipes/staticanalysis/codecleanup ``` There were problems parsing lib/src/main/resources/com/diffplug/spotless/npm/eslint-package.json There were problems parsing lib/src/main/resources/com/diffplug/spotless/npm/prettier-package.json There were problems parsing lib/src/main/resources/com/diffplug/spotless/npm/tsfmt-package.json All sources parsed, running active recipes: com.diffplug.spotless.openrewrite.SanityCheck Changes have been made to testlib/src/main/java/com/diffplug/spotless/TestProvisioner.java by: org.openrewrite.staticanalysis.HideUtilityClassConstructor Changes have been made to testlib/src/main/java/com/diffplug/spotless/ReflectionUtil.java by: org.openrewrite.staticanalysis.HideUtilityClassConstructor Changes have been made to testlib/src/test/java/com/diffplug/spotless/PaddedCellTest.java by: org.openrewrite.staticanalysis.ForLoopControlVariablePostfixOperators Please review and commit the results. Estimate time saved: 15m ``` --- .../src/main/java/com/diffplug/spotless/TestProvisioner.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/testlib/src/main/java/com/diffplug/spotless/TestProvisioner.java b/testlib/src/main/java/com/diffplug/spotless/TestProvisioner.java index 0ec0775567..b8d445747f 100644 --- a/testlib/src/main/java/com/diffplug/spotless/TestProvisioner.java +++ b/testlib/src/main/java/com/diffplug/spotless/TestProvisioner.java @@ -47,6 +47,8 @@ import java.util.function.Consumer; import java.util.function.Supplier; +import com.diffplug.common.base.Suppliers; + import org.gradle.api.Project; import org.gradle.api.artifacts.Configuration; import org.gradle.api.artifacts.Dependency; @@ -62,6 +64,7 @@ public final class TestProvisioner { private static final String MAVEN_CENTRAL_CACHE = "build/tmp/testprovisioner.mavenCentral.cache"; private static final String TEST_LIB = "testlib"; + private static final Provisioner PROVISIONER = memoize(() -> caching(() -> createWithRepositories(RepositoryHandler::mavenCentral))).get(); private TestProvisioner() {} @@ -76,7 +79,7 @@ public static Project gradleProject(File projectDir) { * Creates a Provisioner for the mavenCentral repo. */ public static Provisioner mavenCentral() { - return memoize(() -> caching(() -> createWithRepositories(RepositoryHandler::mavenCentral))).get(); + return PROVISIONER; } /** From edf6b28c8ddbaf29ff482519ad02e02b104e3087 Mon Sep 17 00:00:00 2001 From: Vincent Potucek Date: Sat, 10 Jan 2026 22:42:57 +0100 Subject: [PATCH 21/27] [rewrite] add `CodeCleanup` Signed-off-by: Vincent Potucek - https://docs.openrewrite.org/recipes/staticanalysis/codecleanup ``` There were problems parsing lib/src/main/resources/com/diffplug/spotless/npm/eslint-package.json There were problems parsing lib/src/main/resources/com/diffplug/spotless/npm/prettier-package.json There were problems parsing lib/src/main/resources/com/diffplug/spotless/npm/tsfmt-package.json All sources parsed, running active recipes: com.diffplug.spotless.openrewrite.SanityCheck Changes have been made to testlib/src/main/java/com/diffplug/spotless/TestProvisioner.java by: org.openrewrite.staticanalysis.HideUtilityClassConstructor Changes have been made to testlib/src/main/java/com/diffplug/spotless/ReflectionUtil.java by: org.openrewrite.staticanalysis.HideUtilityClassConstructor Changes have been made to testlib/src/test/java/com/diffplug/spotless/PaddedCellTest.java by: org.openrewrite.staticanalysis.ForLoopControlVariablePostfixOperators Please review and commit the results. Estimate time saved: 15m ``` --- .../src/main/java/com/diffplug/spotless/TestProvisioner.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/testlib/src/main/java/com/diffplug/spotless/TestProvisioner.java b/testlib/src/main/java/com/diffplug/spotless/TestProvisioner.java index b8d445747f..a1d71c2a02 100644 --- a/testlib/src/main/java/com/diffplug/spotless/TestProvisioner.java +++ b/testlib/src/main/java/com/diffplug/spotless/TestProvisioner.java @@ -47,8 +47,6 @@ import java.util.function.Consumer; import java.util.function.Supplier; -import com.diffplug.common.base.Suppliers; - import org.gradle.api.Project; import org.gradle.api.artifacts.Configuration; import org.gradle.api.artifacts.Dependency; From 6f31ca45f2160d0ebdc3205aa89b9b676e0abeea Mon Sep 17 00:00:00 2001 From: Vincent Potucek Date: Sat, 10 Jan 2026 23:04:48 +0100 Subject: [PATCH 22/27] [rewrite] add `CodeCleanup` Signed-off-by: Vincent Potucek - https://docs.openrewrite.org/recipes/staticanalysis/codecleanup ``` There were problems parsing lib/src/main/resources/com/diffplug/spotless/npm/eslint-package.json There were problems parsing lib/src/main/resources/com/diffplug/spotless/npm/prettier-package.json There were problems parsing lib/src/main/resources/com/diffplug/spotless/npm/tsfmt-package.json All sources parsed, running active recipes: com.diffplug.spotless.openrewrite.SanityCheck Changes have been made to testlib/src/main/java/com/diffplug/spotless/TestProvisioner.java by: org.openrewrite.staticanalysis.HideUtilityClassConstructor Changes have been made to testlib/src/main/java/com/diffplug/spotless/ReflectionUtil.java by: org.openrewrite.staticanalysis.HideUtilityClassConstructor Changes have been made to testlib/src/test/java/com/diffplug/spotless/PaddedCellTest.java by: org.openrewrite.staticanalysis.ForLoopControlVariablePostfixOperators Please review and commit the results. Estimate time saved: 15m ``` --- .../src/main/java/com/diffplug/spotless/TestProvisioner.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/testlib/src/main/java/com/diffplug/spotless/TestProvisioner.java b/testlib/src/main/java/com/diffplug/spotless/TestProvisioner.java index a1d71c2a02..6065a17280 100644 --- a/testlib/src/main/java/com/diffplug/spotless/TestProvisioner.java +++ b/testlib/src/main/java/com/diffplug/spotless/TestProvisioner.java @@ -62,7 +62,8 @@ public final class TestProvisioner { private static final String MAVEN_CENTRAL_CACHE = "build/tmp/testprovisioner.mavenCentral.cache"; private static final String TEST_LIB = "testlib"; - private static final Provisioner PROVISIONER = memoize(() -> caching(() -> createWithRepositories(RepositoryHandler::mavenCentral))).get(); + private static final Provisioner PROVISIONER = memoize( + () -> caching(() -> createWithRepositories(RepositoryHandler::mavenCentral))).get(); private TestProvisioner() {} From bca200952114ac6aac1f9af9b12a8a5225ff8b0c Mon Sep 17 00:00:00 2001 From: Vincent Potucek Date: Sat, 10 Jan 2026 23:06:03 +0100 Subject: [PATCH 23/27] [rewrite] add `CodeCleanup` Signed-off-by: Vincent Potucek - https://docs.openrewrite.org/recipes/staticanalysis/codecleanup ``` There were problems parsing lib/src/main/resources/com/diffplug/spotless/npm/eslint-package.json There were problems parsing lib/src/main/resources/com/diffplug/spotless/npm/prettier-package.json There were problems parsing lib/src/main/resources/com/diffplug/spotless/npm/tsfmt-package.json All sources parsed, running active recipes: com.diffplug.spotless.openrewrite.SanityCheck Changes have been made to testlib/src/main/java/com/diffplug/spotless/TestProvisioner.java by: org.openrewrite.staticanalysis.HideUtilityClassConstructor Changes have been made to testlib/src/main/java/com/diffplug/spotless/ReflectionUtil.java by: org.openrewrite.staticanalysis.HideUtilityClassConstructor Changes have been made to testlib/src/test/java/com/diffplug/spotless/PaddedCellTest.java by: org.openrewrite.staticanalysis.ForLoopControlVariablePostfixOperators Please review and commit the results. Estimate time saved: 15m ``` --- .../src/main/java/com/diffplug/spotless/TestProvisioner.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/testlib/src/main/java/com/diffplug/spotless/TestProvisioner.java b/testlib/src/main/java/com/diffplug/spotless/TestProvisioner.java index 6065a17280..dcc01d107c 100644 --- a/testlib/src/main/java/com/diffplug/spotless/TestProvisioner.java +++ b/testlib/src/main/java/com/diffplug/spotless/TestProvisioner.java @@ -63,7 +63,7 @@ public final class TestProvisioner { private static final String MAVEN_CENTRAL_CACHE = "build/tmp/testprovisioner.mavenCentral.cache"; private static final String TEST_LIB = "testlib"; private static final Provisioner PROVISIONER = memoize( - () -> caching(() -> createWithRepositories(RepositoryHandler::mavenCentral))).get(); + () -> resolveAndCache(() -> createWithRepositories(RepositoryHandler::mavenCentral))).get(); private TestProvisioner() {} @@ -84,7 +84,7 @@ public static Provisioner mavenCentral() { /** * Creates a Provisioner which will cache the result of previous calls. */ - private static Provisioner caching(Supplier delegate) { + private static Provisioner resolveAndCache(Supplier delegate) { var cacheFile = new File(new File(new File(requireNonNull(USER_DIR.value())).getParentFile(), TEST_LIB), MAVEN_CENTRAL_CACHE); return (withTransitives, rawCoords) -> resolveAndCache( delegate, From 953c0b61d646604497c9b4a5aa27f9ee02662931 Mon Sep 17 00:00:00 2001 From: Vincent Potucek Date: Sat, 10 Jan 2026 23:07:13 +0100 Subject: [PATCH 24/27] [rewrite] add `CodeCleanup` Signed-off-by: Vincent Potucek - https://docs.openrewrite.org/recipes/staticanalysis/codecleanup ``` There were problems parsing lib/src/main/resources/com/diffplug/spotless/npm/eslint-package.json There were problems parsing lib/src/main/resources/com/diffplug/spotless/npm/prettier-package.json There were problems parsing lib/src/main/resources/com/diffplug/spotless/npm/tsfmt-package.json All sources parsed, running active recipes: com.diffplug.spotless.openrewrite.SanityCheck Changes have been made to testlib/src/main/java/com/diffplug/spotless/TestProvisioner.java by: org.openrewrite.staticanalysis.HideUtilityClassConstructor Changes have been made to testlib/src/main/java/com/diffplug/spotless/ReflectionUtil.java by: org.openrewrite.staticanalysis.HideUtilityClassConstructor Changes have been made to testlib/src/test/java/com/diffplug/spotless/PaddedCellTest.java by: org.openrewrite.staticanalysis.ForLoopControlVariablePostfixOperators Please review and commit the results. Estimate time saved: 15m ``` --- .../main/java/com/diffplug/spotless/TestProvisioner.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/testlib/src/main/java/com/diffplug/spotless/TestProvisioner.java b/testlib/src/main/java/com/diffplug/spotless/TestProvisioner.java index dcc01d107c..2cae4b63ae 100644 --- a/testlib/src/main/java/com/diffplug/spotless/TestProvisioner.java +++ b/testlib/src/main/java/com/diffplug/spotless/TestProvisioner.java @@ -102,12 +102,9 @@ private static ImmutableSet resolveAndCache(Supplier delegate synchronized (TestProvisioner.class) { var cachedFiles = artifactCache.get(mavenCoords); var cacheValid = cachedFiles != null && - cachedFiles.stream().allMatch( - f -> f.exists() && f.isFile() && f.length() > 0); + cachedFiles.stream().allMatch(f -> f.exists() && f.isFile() && f.length() > 0); if (!cacheValid) { - cachedFiles = copyOf( - delegate.get() - .provisionWithTransitives(withTransitives, mavenCoords)); + cachedFiles = copyOf(delegate.get().provisionWithTransitives(withTransitives, mavenCoords)); artifactCache.put(mavenCoords, cachedFiles); try (var out = new ObjectOutputStream(asByteSink(cacheFile).openBufferedStream())) { out.writeObject(artifactCache); From e1e970a8857734bf667b493fd9e3bec618356df0 Mon Sep 17 00:00:00 2001 From: Vincent Potucek Date: Sat, 10 Jan 2026 23:08:58 +0100 Subject: [PATCH 25/27] [rewrite] add `CodeCleanup` Signed-off-by: Vincent Potucek - https://docs.openrewrite.org/recipes/staticanalysis/codecleanup ``` There were problems parsing lib/src/main/resources/com/diffplug/spotless/npm/eslint-package.json There were problems parsing lib/src/main/resources/com/diffplug/spotless/npm/prettier-package.json There were problems parsing lib/src/main/resources/com/diffplug/spotless/npm/tsfmt-package.json All sources parsed, running active recipes: com.diffplug.spotless.openrewrite.SanityCheck Changes have been made to testlib/src/main/java/com/diffplug/spotless/TestProvisioner.java by: org.openrewrite.staticanalysis.HideUtilityClassConstructor Changes have been made to testlib/src/main/java/com/diffplug/spotless/ReflectionUtil.java by: org.openrewrite.staticanalysis.HideUtilityClassConstructor Changes have been made to testlib/src/test/java/com/diffplug/spotless/PaddedCellTest.java by: org.openrewrite.staticanalysis.ForLoopControlVariablePostfixOperators Please review and commit the results. Estimate time saved: 15m ``` --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5b28e00c1c..7bd02c30d9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,7 +32,7 @@ jobs: run: ./gradlew clean spotlessCheck - name: Error Prone 🚧 run: ./gradlew clean assemble - - name: Test 📊 Classes ⚙ïļ + - name: Test Classes ⚙ïļ run: ./gradlew clean testClasses - name: Rewrite â™ŧïļ run: ./gradlew clean rewriteDryRun From ee6b28d3a740c0e62844bb80219cd230d598e762 Mon Sep 17 00:00:00 2001 From: Vincent Potucek Date: Sun, 11 Jan 2026 07:49:54 +0100 Subject: [PATCH 26/27] [rewrite] fix `JavaLangAPIs` #2804 (#2810) --- .github/workflows/changelog-print.yml | 2 +- .github/workflows/ci.yml | 72 +++--- .github/workflows/codeql-analysis.yml | 4 +- .github/workflows/deploy.yml | 2 +- README.md | 6 +- rewrite.yml | 18 -- .../com/diffplug/spotless/ReflectionUtil.java | 53 ++++ .../diffplug/spotless/TestProvisioner.java | 226 ++++++++---------- .../com/diffplug/spotless/PaddedCellTest.java | 4 +- 9 files changed, 197 insertions(+), 190 deletions(-) create mode 100644 testlib/src/main/java/com/diffplug/spotless/ReflectionUtil.java diff --git a/.github/workflows/changelog-print.yml b/.github/workflows/changelog-print.yml index 86040e0f71..184608f0b1 100644 --- a/.github/workflows/changelog-print.yml +++ b/.github/workflows/changelog-print.yml @@ -14,6 +14,6 @@ jobs: with: java-version: 21 distribution: 'temurin' - - name: Setup Gradle 🐘 + - name: gradle caching uses: gradle/actions/setup-gradle@v5 - run: ./gradlew changelogPrint diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7bd02c30d9..0282bddf72 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,6 +7,7 @@ on: push: branches: [main, release] workflow_dispatch: + concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true @@ -18,35 +19,34 @@ jobs: buildcacheuser: ${{ secrets.BUILDCACHE_USER }} buildcachepass: ${{ secrets.BUILDCACHE_PASS }} steps: - - name: Checkout Code ðŸ“Ĩ + - name: Checkout uses: actions/checkout@v6 with: fetch-depth: 0 - uses: actions/setup-java@v5 with: - distribution: temurin + distribution: "temurin" java-version: 21 - - name: Setup Gradle 🐘 + - name: gradle caching uses: gradle/actions/setup-gradle@v5 - name: Spotless âœĻ - run: ./gradlew clean spotlessCheck - - name: Error Prone 🚧 - run: ./gradlew clean assemble - - name: Test Classes ⚙ïļ - run: ./gradlew clean testClasses + run: ./gradlew spotlessCheck - name: Rewrite â™ŧïļ - run: ./gradlew clean rewriteDryRun + run: ./gradlew rewriteDryRun + - name: assemble testClasses + run: ./gradlew assemble testClasses build: - name: Build 🏗ïļ needs: sanity-check strategy: fail-fast: false matrix: kind: [maven, gradle] - jre: [17, 21, 24] # test on the latest Java version once Gradle & Maven support it. + # Test on the latest Java version once Gradle & Maven support it. + jre: [17, 21, 24] os: [ubuntu-latest, windows-latest] include: - - kind: npm # npm on linux only (crazy slow on windows). + # npm on linux only (crazy slow on windows) + - kind: npm jre: 17 os: ubuntu-latest - kind: shfmt @@ -58,64 +58,66 @@ jobs: os: ubuntu-latest runs-on: ${{ matrix.os }} steps: - - name: Checkout Code ðŸ“Ĩ + - name: Checkout uses: actions/checkout@v6 - uses: actions/setup-java@v5 with: - distribution: temurin + distribution: "temurin" java-version: ${{ matrix.jre }} - - name: Setup Gradle 🐘 + - name: gradle caching uses: gradle/actions/setup-gradle@v5 - - name: Build Maven ðŸŠķ + - name: build (maven-only) if: matrix.kind == 'maven' - run: ./gradlew :plugin-maven:build -x spotlessCheck - - name: Build Gradle 🐘 + run: ./gradlew :plugin-maven:build -x spotlessCheck -x rewriteDryRun + - name: build (everything-but-maven) if: matrix.kind == 'gradle' - run: ./gradlew build -PSPOTLESS_EXCLUDE_MAVEN=true -x spotlessCheck - - name: Test npm 📊 + run: ./gradlew build -x spotlessCheck -x rewriteDryRun -PSPOTLESS_EXCLUDE_MAVEN=true + - name: test npm if: matrix.kind == 'npm' run: ./gradlew testNpm - - name: Setup Go + - name: Setup go if: matrix.kind == 'shfmt' uses: actions/setup-go@v6 with: - go-version: stable - - name: Install shfmt ðŸ“Ĩ + go-version: 'stable' + - name: Install shfmt if: matrix.kind == 'shfmt' - run: go install mvdan.cc/sh/v3/cmd/shfmt@${{ matrix.shfmt-version }} - - name: Test shfmt 📊 + run: | + go install mvdan.cc/sh/v3/cmd/shfmt@${{ matrix.shfmt-version }} + - name: Test shfmt if: matrix.kind == 'shfmt' run: ./gradlew testShfmt - - name: Test IDEA 📊 + - name: Test idea if: matrix.kind == 'idea' run: | download_link=$(curl https://data.services.jetbrains.com/products/releases\?code\=IIC\&latest\=true\&type\=release | jq -r '.IIC[0].downloads.linux.link') - curl --location $download_link -o idea.tar.gz + curl --location "$download_link" -o idea.tar.gz tar -xf idea.tar.gz cd idea-IC* export PATH=${PATH}:$(pwd)/bin cd .. ./gradlew testIdea - - name: Junit Report 📋 + - name: junit result uses: mikepenz/action-junit-report@v6 - if: always() # always run even if the previous step fails. + if: always() # always run even if the previous step fails with: check_name: JUnit ${{ matrix.kind }} ${{ matrix.jre }} ${{ matrix.os }} report_paths: '*/build/test-results/*/TEST-*.xml' check_retries: true - complete: # this check is required in branch protection rules. - name: Complete ✅ + + # Status check that is required in branch protection rules. + final-status: needs: - sanity-check - build runs-on: ubuntu-latest if: always() steps: - - name: Check ðŸĶ‰ + - name: Check run: | results=$(tr -d '\n' <<< '${{ toJSON(needs.*.result) }}') - if ! grep -q -v -E '(failure|cancelled)' <<< $results; then - echo ❌ One or more required jobs failed. + if ! grep -q -v -E '(failure|cancelled)' <<< "$results"; then + echo "One or more required jobs failed" exit 1 fi - echo ✅ All required jobs completed successfully. + echo "All required jobs completed successfully." diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 1c54de5741..9f8f931c62 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -36,7 +36,7 @@ jobs: # https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection steps: - - name: Checkout Code ðŸ“Ĩ + - name: Checkout repository uses: actions/checkout@v6 with: # We must fetch at least the immediate parents so that if this is @@ -54,7 +54,7 @@ jobs: with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. + # By default, queries listed here will override any specified in a config file. # Prefix the list here with "+" to use these queries and those in the config file. # queries: ./path/to/local/query, your-org/your-repo/queries@main diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index ff5824a20a..31e4dd2711 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -42,7 +42,7 @@ jobs: with: java-version: 21 distribution: 'temurin' - - name: Setup Gradle 🐘 + - name: gradle caching uses: gradle/actions/setup-gradle@v5 - name: git fetch origin main run: git fetch origin main diff --git a/README.md b/README.md index 59edbdd2cd..064509f3f5 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Spotless can format <antlr | c | c# | c++ | css | flow | graphql | groovy | h You probably want one of the links below: -## [âœĻïļ Spotless for Gradle](plugin-gradle) (with integrations for [VS Code](https://marketplace.visualstudio.com/items?itemName=richardwillis.vscode-spotless-gradle) and [IntelliJ](https://plugins.jetbrains.com/plugin/18321-spotless-gradle)) +## [❇ïļ Spotless for Gradle](plugin-gradle) (with integrations for [VS Code](https://marketplace.visualstudio.com/items?itemName=richardwillis.vscode-spotless-gradle) and [IntelliJ](https://plugins.jetbrains.com/plugin/18321-spotless-gradle)) ```console user@machine repo % ./gradlew build @@ -25,7 +25,7 @@ user@machine repo % ./gradlew build BUILD SUCCESSFUL ``` -## [âœĻïļ Spotless for Maven](plugin-maven) +## [❇ïļ Spotless for Maven](plugin-maven) ```console user@machine repo % mvn spotless:check @@ -40,7 +40,7 @@ user@machine repo % mvn spotless:check [INFO] BUILD SUCCESS ``` -## [âœĻïļ Spotless for SBT (external for now)](https://github.com/moznion/sbt-spotless) +## [❇ïļ Spotless for SBT (external for now)](https://github.com/moznion/sbt-spotless) ## [Other build systems](CONTRIBUTING.md#how-to-add-a-new-plugin-for-a-build-system) ## How it works (for potential contributors) diff --git a/rewrite.yml b/rewrite.yml index 5cfe4964ed..4bea1dd1b9 100644 --- a/rewrite.yml +++ b/rewrite.yml @@ -7,14 +7,9 @@ recipeList: - org.openrewrite.gradle.EnableGradleBuildCache - org.openrewrite.gradle.EnableGradleParallelExecution - org.openrewrite.gradle.GradleBestPractices - - org.openrewrite.hcl.format.RemoveTrailingWhitespace - org.openrewrite.java.RemoveUnusedImports - - org.openrewrite.java.ShortenFullyQualifiedTypeReferences - - org.openrewrite.java.SimplifySingleElementAnnotation - - org.openrewrite.java.format.EmptyNewlineAtEndOfFile - org.openrewrite.java.format.NormalizeFormat - org.openrewrite.java.format.NormalizeLineBreaks - - org.openrewrite.java.format.PadEmptyForLoopComponents - org.openrewrite.java.format.RemoveTrailingWhitespace - org.openrewrite.java.migrate.UpgradeToJava17 - org.openrewrite.java.migrate.lang.JavaLangAPIs @@ -27,32 +22,19 @@ recipeList: - org.openrewrite.java.recipes.RecipeTestingBestPractices - org.openrewrite.java.security.JavaSecurityBestPractices - org.openrewrite.staticanalysis.BufferedWriterCreationRecipes - - org.openrewrite.staticanalysis.ChainStringBuilderAppendCalls - org.openrewrite.staticanalysis.CommonStaticAnalysis - - org.openrewrite.staticanalysis.CustomImportOrder - - org.openrewrite.staticanalysis.DefaultComesLast - - org.openrewrite.staticanalysis.EmptyBlock - org.openrewrite.staticanalysis.EqualsAvoidsNull - - org.openrewrite.staticanalysis.ExplicitInitialization - - org.openrewrite.staticanalysis.FallThrough - - org.openrewrite.staticanalysis.FinalizePrivateFields - - org.openrewrite.staticanalysis.ForLoopControlVariablePostfixOperators - - org.openrewrite.staticanalysis.HideUtilityClassConstructor - org.openrewrite.staticanalysis.JavaApiBestPractices - org.openrewrite.staticanalysis.LowercasePackage - org.openrewrite.staticanalysis.MissingOverrideAnnotation - org.openrewrite.staticanalysis.ModifierOrder - - org.openrewrite.staticanalysis.NeedBraces - org.openrewrite.staticanalysis.NoFinalizer - org.openrewrite.staticanalysis.NoToStringOnStringType - org.openrewrite.staticanalysis.NoValueOfOnStringType - org.openrewrite.staticanalysis.RemoveUnusedLocalVariables - org.openrewrite.staticanalysis.RemoveUnusedPrivateFields - org.openrewrite.staticanalysis.RemoveUnusedPrivateMethods - - org.openrewrite.staticanalysis.ReplaceStringBuilderWithString - - org.openrewrite.staticanalysis.ReplaceThreadRunWithThreadStart - org.openrewrite.staticanalysis.SimplifyTernaryRecipes - - org.openrewrite.staticanalysis.TypecastParenPad - org.openrewrite.staticanalysis.URLEqualsHashCodeRecipes - org.openrewrite.staticanalysis.UnnecessaryCloseInTryWithResources - org.openrewrite.staticanalysis.UnnecessaryExplicitTypeArguments diff --git a/testlib/src/main/java/com/diffplug/spotless/ReflectionUtil.java b/testlib/src/main/java/com/diffplug/spotless/ReflectionUtil.java new file mode 100644 index 0000000000..1590b08311 --- /dev/null +++ b/testlib/src/main/java/com/diffplug/spotless/ReflectionUtil.java @@ -0,0 +1,53 @@ +/* + * Copyright 2016-2025 DiffPlug + * + * 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.diffplug.spotless; + +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.lang.reflect.Parameter; +import java.util.Arrays; +import java.util.Iterator; + +/** + * Utilities for dumping class info, helpful for + * debugging reflection code. Probably easiest to + * just copy-paste these methods where you need + * them. + */ +public class ReflectionUtil { + public static void dumpAllInfo(String name, Object obj) { + System.out.println(name + " of type " + obj.getClass()); + for (Method method : obj.getClass().getMethods()) { + dumpMethod(method); + } + } + + public static void dumpMethod(Method method) { + System.out.print(Modifier.toString(method.getModifiers())); + System.out.print(" " + method.getReturnType()); + System.out.print(" " + method.getName() + "("); + Iterator paramIter = Arrays.asList(method.getParameters()).iterator(); + while (paramIter.hasNext()) { + Parameter param = paramIter.next(); + + System.out.print(param.getType().getName()); + if (paramIter.hasNext()) { + System.out.print(", "); + } + } + System.out.println(")"); + } +} diff --git a/testlib/src/main/java/com/diffplug/spotless/TestProvisioner.java b/testlib/src/main/java/com/diffplug/spotless/TestProvisioner.java index 2cae4b63ae..55558f9b37 100644 --- a/testlib/src/main/java/com/diffplug/spotless/TestProvisioner.java +++ b/testlib/src/main/java/com/diffplug/spotless/TestProvisioner.java @@ -1,5 +1,5 @@ /* - * Copyright 2026 DiffPlug + * Copyright 2016-2025 DiffPlug * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,33 +15,12 @@ */ package com.diffplug.spotless; -import static com.diffplug.common.base.Errors.asRuntime; -import static com.diffplug.common.base.StandardSystemProperty.USER_DIR; -import static com.diffplug.common.base.StandardSystemProperty.USER_HOME; -import static com.diffplug.common.base.Suppliers.memoize; -import static com.diffplug.common.collect.ImmutableSet.copyOf; -import static com.diffplug.common.io.Files.asByteSink; -import static com.diffplug.common.io.Files.asByteSource; -import static com.diffplug.common.io.Files.createParentDirs; -import static com.diffplug.common.io.Files.createTempDir; -import static java.nio.file.Files.walk; -import static java.nio.file.Path.of; -import static java.util.Comparator.reverseOrder; -import static java.util.Objects.requireNonNull; -import static org.gradle.api.attributes.Bundling.BUNDLING_ATTRIBUTE; -import static org.gradle.api.attributes.Bundling.EXTERNAL; -import static org.gradle.api.attributes.Category.CATEGORY_ATTRIBUTE; -import static org.gradle.api.attributes.Category.LIBRARY; -import static org.gradle.api.attributes.java.TargetJvmEnvironment.STANDARD_JVM; -import static org.gradle.api.attributes.java.TargetJvmEnvironment.TARGET_JVM_ENVIRONMENT_ATTRIBUTE; -import static org.gradle.testfixtures.ProjectBuilder.builder; - import java.io.File; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.nio.file.Path; -import java.util.Collection; +import java.util.Comparator; import java.util.HashMap; import java.util.Map; import java.util.function.Consumer; @@ -55,134 +34,125 @@ import org.gradle.api.attributes.Bundling; import org.gradle.api.attributes.Category; import org.gradle.api.attributes.java.TargetJvmEnvironment; +import org.gradle.testfixtures.ProjectBuilder; +import com.diffplug.common.base.Errors; +import com.diffplug.common.base.StandardSystemProperty; +import com.diffplug.common.base.Suppliers; import com.diffplug.common.collect.ImmutableSet; +import com.diffplug.common.io.Files; -public final class TestProvisioner { - - private static final String MAVEN_CENTRAL_CACHE = "build/tmp/testprovisioner.mavenCentral.cache"; - private static final String TEST_LIB = "testlib"; - private static final Provisioner PROVISIONER = memoize( - () -> resolveAndCache(() -> createWithRepositories(RepositoryHandler::mavenCentral))).get(); - - private TestProvisioner() {} - - public static Project gradleProject(File projectDir) { - return builder() - .withGradleUserHomeDir(new File(requireNonNull(USER_HOME.value()), ".gradle")) - .withProjectDir(projectDir) +public class TestProvisioner { + public static Project gradleProject(File dir) { + File userHome = new File(StandardSystemProperty.USER_HOME.value()); + return ProjectBuilder.builder() + .withGradleUserHomeDir(new File(userHome, ".gradle")) + .withProjectDir(dir) .build(); } /** - * Creates a Provisioner for the mavenCentral repo. - */ - public static Provisioner mavenCentral() { - return PROVISIONER; - } - - /** - * Creates a Provisioner which will cache the result of previous calls. + * Creates a Provisioner for the given repositories. + *

+ * The first time a project is created, there are ~7 seconds of configuration + * which will go away for all subsequent runs. + *

+ * Every call to resolve will take about 1 second, even when all artifacts are resolved. */ - private static Provisioner resolveAndCache(Supplier delegate) { - var cacheFile = new File(new File(new File(requireNonNull(USER_DIR.value())).getParentFile(), TEST_LIB), MAVEN_CENTRAL_CACHE); - return (withTransitives, rawCoords) -> resolveAndCache( - delegate, - withTransitives, - loadCache(cacheFile), - copyOf(rawCoords), - cacheFile); - } - - private static ImmutableSet resolveAndCache(Supplier delegate, - boolean withTransitives, - Map, ImmutableSet> artifactCache, - ImmutableSet mavenCoords, - File cacheFile) { - synchronized (TestProvisioner.class) { - var cachedFiles = artifactCache.get(mavenCoords); - var cacheValid = cachedFiles != null && - cachedFiles.stream().allMatch(f -> f.exists() && f.isFile() && f.length() > 0); - if (!cacheValid) { - cachedFiles = copyOf(delegate.get().provisionWithTransitives(withTransitives, mavenCoords)); - artifactCache.put(mavenCoords, cachedFiles); - try (var out = new ObjectOutputStream(asByteSink(cacheFile).openBufferedStream())) { - out.writeObject(artifactCache); + private static Provisioner createWithRepositories(Consumer repoConfig) { + // Running this takes ~3 seconds the first time it is called. Probably because of classloading. + File tempDir = Files.createTempDir(); + Project project = TestProvisioner.gradleProject(tempDir); + repoConfig.accept(project.getRepositories()); + return (withTransitives, mavenCoords) -> { + Dependency[] deps = mavenCoords.stream() + .map(project.getDependencies()::create) + .toArray(Dependency[]::new); + Configuration config = project.getConfigurations().detachedConfiguration(deps); + config.setTransitive(withTransitives); + config.setDescription(mavenCoords.toString()); + config.attributes(attr -> { + attr.attribute(Category.CATEGORY_ATTRIBUTE, project.getObjects().named(Category.class, Category.LIBRARY)); + attr.attribute(Bundling.BUNDLING_ATTRIBUTE, project.getObjects().named(Bundling.class, Bundling.EXTERNAL)); + // Add this attribute for resolving Guava dependency, see https://github.com/google/guava/issues/6801. + attr.attribute(TargetJvmEnvironment.TARGET_JVM_ENVIRONMENT_ATTRIBUTE, project.getObjects().named(TargetJvmEnvironment.class, TargetJvmEnvironment.STANDARD_JVM)); + }); + try { + return config.resolve(); + } catch (ResolveException e) { + /* Provide Maven coordinates in exception message instead of static string 'detachedConfiguration' */ + throw new RuntimeException("Error resolving configuration: " + config.getDescription(), e); + } finally { + // delete the temp dir + try { + java.nio.file.Files.walk(tempDir.toPath()) + .sorted(Comparator.reverseOrder()) + .map(Path::toFile) + .forEach(File::delete); } catch (IOException e) { - throw asRuntime(e); + throw Errors.asRuntime(e); } } - return cachedFiles; - } + }; } + /** Creates a Provisioner which will cache the result of previous calls. */ @SuppressWarnings("unchecked") - private static Map, ImmutableSet> loadCache(File cacheFile) { + private static Provisioner caching(String name, Supplier input) { + File spotlessDir = new File(StandardSystemProperty.USER_DIR.value()).getParentFile(); + File testlib = new File(spotlessDir, "testlib"); + File cacheFile = new File(testlib, "build/tmp/testprovisioner." + name + ".cache"); + + Map, ImmutableSet> cached; if (cacheFile.exists()) { - try (var in = new ObjectInputStream(asByteSource(cacheFile).openBufferedStream())) { - return (Map, ImmutableSet>) in.readObject(); + try (ObjectInputStream inputStream = new ObjectInputStream(Files.asByteSource(cacheFile).openBufferedStream())) { + cached = (Map, ImmutableSet>) inputStream.readObject(); } catch (IOException | ClassNotFoundException e) { - throw asRuntime(e); + throw Errors.asRuntime(e); + } + } else { + cached = new HashMap<>(); + try { + Files.createParentDirs(cacheFile); + } catch (IOException e) { + throw Errors.asRuntime(e); } } - try { - createParentDirs(cacheFile); - return new HashMap<>(); - } catch (IOException e) { - throw asRuntime(e); - } + return (withTransitives, mavenCoordsRaw) -> { + ImmutableSet mavenCoords = ImmutableSet.copyOf(mavenCoordsRaw); + synchronized (TestProvisioner.class) { + ImmutableSet result = cached.get(mavenCoords); + // double-check that depcache pruning hasn't removed them since our cache cached them + boolean needsToBeSet = result == null || !result.stream().allMatch(file -> file.exists() && file.isFile() && file.length() > 0); + if (needsToBeSet) { + result = ImmutableSet.copyOf(input.get().provisionWithTransitives(withTransitives, mavenCoords)); + cached.put(mavenCoords, result); + try (ObjectOutputStream outputStream = new ObjectOutputStream(Files.asByteSink(cacheFile).openBufferedStream())) { + outputStream.writeObject(cached); + } catch (IOException e) { + throw Errors.asRuntime(e); + } + } + return result; + } + }; } - /** - * Creates a Provisioner for the given repositories. - */ - private static Provisioner createWithRepositories(Consumer repositoryConfigurer) { - return createProvisioner(repositoryConfigurer, gradleProject(createTempDir())); + /** Creates a Provisioner for the mavenCentral repo. */ + public static Provisioner mavenCentral() { + return MAVEN_CENTRAL.get(); } - private static Provisioner createProvisioner(Consumer repositoryConfigurer, Project project) { - repositoryConfigurer.accept(project.getRepositories()); - return (withTransitives, mavenCoords) -> { - var configuration = applyAttributes(project - .getConfigurations() - .detachedConfiguration(mavenCoords - .stream() - .map(project.getDependencies()::create) - .toArray(Dependency[]::new)), - withTransitives, - mavenCoords, - project); - try { - return configuration.resolve(); - } catch (ResolveException e) { - throw new RuntimeException("Error resolving configuration: " + configuration.getDescription(), e); - } finally { - try (var paths = walk(of(project.getPath()))) { - paths.sorted(reverseOrder()) - .map(Path::toFile) - .forEach(File::delete); - } catch (IOException ignored) {} - } - }; + private static final Supplier MAVEN_CENTRAL = Suppliers.memoize(() -> caching("mavenCentral", () -> createWithRepositories(RepositoryHandler::mavenCentral))); + + /** Creates a Provisioner for the local maven repo for development purpose. */ + public static Provisioner mavenLocal() { + return createWithRepositories(RepositoryHandler::mavenLocal); } - private static Configuration applyAttributes(Configuration configuration, - boolean withTransitives, - Collection mavenCoords, - Project project) { - configuration.setTransitive(withTransitives); - configuration.setDescription(mavenCoords.toString()); - configuration.attributes(attrs -> { - attrs.attribute( - CATEGORY_ATTRIBUTE, - project.getObjects().named(Category.class, LIBRARY)); - attrs.attribute( - BUNDLING_ATTRIBUTE, - project.getObjects().named(Bundling.class, EXTERNAL)); - attrs.attribute( - TARGET_JVM_ENVIRONMENT_ATTRIBUTE, - project.getObjects().named(TargetJvmEnvironment.class, STANDARD_JVM)); - }); - return configuration; + /** Creates a Provisioner for the Sonatype snapshots maven repo for development purpose. */ + public static Provisioner snapshots() { + return createWithRepositories(repo -> repo.maven(setup -> setup.setUrl("https://oss.sonatype.org/content/repositories/snapshots"))); } + } diff --git a/testlib/src/test/java/com/diffplug/spotless/PaddedCellTest.java b/testlib/src/test/java/com/diffplug/spotless/PaddedCellTest.java index 1a62c62097..2820aadeef 100644 --- a/testlib/src/test/java/com/diffplug/spotless/PaddedCellTest.java +++ b/testlib/src/test/java/com/diffplug/spotless/PaddedCellTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2026 DiffPlug + * Copyright 2016-2024 DiffPlug * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -116,7 +116,7 @@ void diverging() throws IOException { void cycleOrder() { BiConsumer testCase = (unorderedStr, canonical) -> { List unordered = Arrays.asList(unorderedStr.split(",")); - for (int i = 0; i < unordered.size(); i++) { + for (int i = 0; i < unordered.size(); ++i) { // try every rotation of the list Collections.rotate(unordered, 1); PaddedCell result = CYCLE.create(rootFolder, unordered); From f580ccd8fc4b5d88ec9869df1de480993e7ac0ee Mon Sep 17 00:00:00 2001 From: Vincent Potucek Date: Sun, 11 Jan 2026 10:42:04 +0100 Subject: [PATCH 27/27] [fix] `Rewrite` gatekeeper --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0282bddf72..353ec606b5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,9 +30,9 @@ jobs: - name: gradle caching uses: gradle/actions/setup-gradle@v5 - name: Spotless âœĻ - run: ./gradlew spotlessCheck + run: ./gradlew clean spotlessCheck - name: Rewrite â™ŧïļ - run: ./gradlew rewriteDryRun + run: ./gradlew clean rewriteDryRun - name: assemble testClasses run: ./gradlew assemble testClasses build: