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..a4c5e21652 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 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. @@ -15,6 +15,8 @@ */ package com.diffplug.spotless; +import static com.diffplug.common.base.Suppliers.memoize; + import java.io.File; import java.io.IOException; import java.io.ObjectInputStream; @@ -38,11 +40,15 @@ 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 final class TestProvisioner { + + private static final Supplier MAVEN_CENTRAL = memoize(() -> caching("mavenCentral", () -> createWithRepositories(RepositoryHandler::mavenCentral))); + + private TestProvisioner() {} + public static Project gradleProject(File dir) { File userHome = new File(StandardSystemProperty.USER_HOME.value()); return ProjectBuilder.builder() @@ -143,16 +149,4 @@ public static Provisioner mavenCentral() { return MAVEN_CENTRAL.get(); } - 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); - } - - /** 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 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);