From 45bcc89bfc739eacb828f152a3ff19c645b07f04 Mon Sep 17 00:00:00 2001 From: Tim te Beek Date: Sun, 18 Aug 2024 11:22:07 +0200 Subject: [PATCH] refactor: Remove unused imports (#4426) Use this link to re-run the recipe: https://app.moderne.io/recipes/org.openrewrite.java.RemoveUnusedImports?organizationId=T3BlblJld3JpdGU%3D Co-authored-by: Moderne --- .../src/main/java/org/openrewrite/PathUtils.java | 1 - .../org/openrewrite/internal/lang/NonNullApi.java | 1 - .../org/openrewrite/internal/lang/NullUtils.java | 1 - .../org/openrewrite/internal/lang/Nullable.java | 1 - .../test/java/org/openrewrite/PathUtilsTest.java | 1 - .../java/org/openrewrite/RecipeLifecycleTest.java | 4 +++- .../openrewrite/table/SourceFileResultsTest.java | 2 -- .../src/test/java/org/openrewrite/RepeatTest.java | 4 +++- .../java/org/openrewrite/java/JavaTypeTest.java | 1 - .../java/search/HasMinimumJavaVersionTest.java | 3 --- .../java/search/IsOrIsNotLikelyTestTest.java | 5 ++++- .../java/format/EmptyNewlineAtEndOfFile.java | 5 ++++- .../maven/ChangePluginConfiguration.java | 14 ++++---------- .../openrewrite/maven/RemoveManagedDependency.java | 1 - .../org/openrewrite/maven/AddDependencyTest.java | 5 ++++- .../org/openrewrite/xml/trait/NamespacedTest.java | 2 +- 16 files changed, 23 insertions(+), 28 deletions(-) diff --git a/rewrite-core/src/main/java/org/openrewrite/PathUtils.java b/rewrite-core/src/main/java/org/openrewrite/PathUtils.java index 528bcc7e479..14e7c65e06b 100755 --- a/rewrite-core/src/main/java/org/openrewrite/PathUtils.java +++ b/rewrite-core/src/main/java/org/openrewrite/PathUtils.java @@ -22,7 +22,6 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; -import java.util.Collections; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; diff --git a/rewrite-core/src/main/java/org/openrewrite/internal/lang/NonNullApi.java b/rewrite-core/src/main/java/org/openrewrite/internal/lang/NonNullApi.java index b2c6109f781..f939f3c2662 100644 --- a/rewrite-core/src/main/java/org/openrewrite/internal/lang/NonNullApi.java +++ b/rewrite-core/src/main/java/org/openrewrite/internal/lang/NonNullApi.java @@ -15,7 +15,6 @@ */ package org.openrewrite.internal.lang; -import org.openrewrite.internal.lang.NonNull; import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; diff --git a/rewrite-core/src/main/java/org/openrewrite/internal/lang/NullUtils.java b/rewrite-core/src/main/java/org/openrewrite/internal/lang/NullUtils.java index ea667d09699..32d37162a9d 100644 --- a/rewrite-core/src/main/java/org/openrewrite/internal/lang/NullUtils.java +++ b/rewrite-core/src/main/java/org/openrewrite/internal/lang/NullUtils.java @@ -15,7 +15,6 @@ */ package org.openrewrite.internal.lang; -import org.openrewrite.internal.lang.NonNull; import org.openrewrite.Option; import java.lang.annotation.Annotation; diff --git a/rewrite-core/src/main/java/org/openrewrite/internal/lang/Nullable.java b/rewrite-core/src/main/java/org/openrewrite/internal/lang/Nullable.java index 0c455f1ec9a..ccf4f6c1ed0 100644 --- a/rewrite-core/src/main/java/org/openrewrite/internal/lang/Nullable.java +++ b/rewrite-core/src/main/java/org/openrewrite/internal/lang/Nullable.java @@ -15,7 +15,6 @@ */ package org.openrewrite.internal.lang; -import org.openrewrite.internal.lang.NonNull; import org.jspecify.annotations.NullMarked; import javax.annotation.meta.TypeQualifierNickname; diff --git a/rewrite-core/src/test/java/org/openrewrite/PathUtilsTest.java b/rewrite-core/src/test/java/org/openrewrite/PathUtilsTest.java index db358016fc2..dec2ab96ae2 100644 --- a/rewrite-core/src/test/java/org/openrewrite/PathUtilsTest.java +++ b/rewrite-core/src/test/java/org/openrewrite/PathUtilsTest.java @@ -15,7 +15,6 @@ */ package org.openrewrite; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import java.nio.file.Path; diff --git a/rewrite-core/src/test/java/org/openrewrite/RecipeLifecycleTest.java b/rewrite-core/src/test/java/org/openrewrite/RecipeLifecycleTest.java index c7208556ce2..f3124134ac4 100644 --- a/rewrite-core/src/test/java/org/openrewrite/RecipeLifecycleTest.java +++ b/rewrite-core/src/test/java/org/openrewrite/RecipeLifecycleTest.java @@ -41,7 +41,9 @@ import java.util.UUID; import static java.util.Objects.requireNonNull; -import static org.assertj.core.api.Assertions.*; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; +import static org.assertj.core.api.Assertions.fail; import static org.openrewrite.Recipe.noop; import static org.openrewrite.test.RewriteTest.toRecipe; import static org.openrewrite.test.SourceSpecs.text; diff --git a/rewrite-core/src/test/java/org/openrewrite/table/SourceFileResultsTest.java b/rewrite-core/src/test/java/org/openrewrite/table/SourceFileResultsTest.java index b46e0cd8fbe..ba017b2aa3b 100644 --- a/rewrite-core/src/test/java/org/openrewrite/table/SourceFileResultsTest.java +++ b/rewrite-core/src/test/java/org/openrewrite/table/SourceFileResultsTest.java @@ -19,8 +19,6 @@ import org.openrewrite.DocumentExample; import org.openrewrite.test.RewriteTest; -import java.io.ByteArrayInputStream; - import static org.assertj.core.api.Assertions.assertThat; import static org.openrewrite.test.SourceSpecs.text; diff --git a/rewrite-java-test/src/test/java/org/openrewrite/RepeatTest.java b/rewrite-java-test/src/test/java/org/openrewrite/RepeatTest.java index 7b70ec3ee40..306db45bb60 100644 --- a/rewrite-java-test/src/test/java/org/openrewrite/RepeatTest.java +++ b/rewrite-java-test/src/test/java/org/openrewrite/RepeatTest.java @@ -24,7 +24,9 @@ import org.openrewrite.test.RewriteTest; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.openrewrite.java.Assertions.java; class RepeatTest implements RewriteTest { diff --git a/rewrite-java-test/src/test/java/org/openrewrite/java/JavaTypeTest.java b/rewrite-java-test/src/test/java/org/openrewrite/java/JavaTypeTest.java index fbbfc968d06..324509f9b89 100644 --- a/rewrite-java-test/src/test/java/org/openrewrite/java/JavaTypeTest.java +++ b/rewrite-java-test/src/test/java/org/openrewrite/java/JavaTypeTest.java @@ -17,7 +17,6 @@ import org.junit.jupiter.api.Test; import org.openrewrite.Issue; -import org.openrewrite.java.search.UsesMethod; import org.openrewrite.java.tree.J; import org.openrewrite.java.tree.JavaType; import org.openrewrite.java.tree.TypeUtils; diff --git a/rewrite-java-test/src/test/java/org/openrewrite/java/search/HasMinimumJavaVersionTest.java b/rewrite-java-test/src/test/java/org/openrewrite/java/search/HasMinimumJavaVersionTest.java index be18fcbd10d..5cb9c5235ce 100644 --- a/rewrite-java-test/src/test/java/org/openrewrite/java/search/HasMinimumJavaVersionTest.java +++ b/rewrite-java-test/src/test/java/org/openrewrite/java/search/HasMinimumJavaVersionTest.java @@ -16,14 +16,11 @@ package org.openrewrite.java.search; import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.ValueSource; import org.openrewrite.DocumentExample; import org.openrewrite.test.RewriteTest; import static org.openrewrite.java.Assertions.java; import static org.openrewrite.java.Assertions.javaVersion; -import static org.openrewrite.test.SourceSpecs.text; class HasMinimumJavaVersionTest implements RewriteTest { diff --git a/rewrite-java-test/src/test/java/org/openrewrite/java/search/IsOrIsNotLikelyTestTest.java b/rewrite-java-test/src/test/java/org/openrewrite/java/search/IsOrIsNotLikelyTestTest.java index 5fc6eefbe0d..d69195804ab 100644 --- a/rewrite-java-test/src/test/java/org/openrewrite/java/search/IsOrIsNotLikelyTestTest.java +++ b/rewrite-java-test/src/test/java/org/openrewrite/java/search/IsOrIsNotLikelyTestTest.java @@ -29,7 +29,10 @@ import org.openrewrite.test.RewriteTest; import org.openrewrite.test.SourceSpecs; -import static org.openrewrite.java.Assertions.*; +import static org.openrewrite.java.Assertions.java; +import static org.openrewrite.java.Assertions.sourceSet; +import static org.openrewrite.java.Assertions.srcMainJava; +import static org.openrewrite.java.Assertions.srcTestJava; import static org.openrewrite.test.RewriteTest.toRecipe; import static org.openrewrite.test.SourceSpecs.dir; import static org.openrewrite.test.SourceSpecs.text; diff --git a/rewrite-java/src/main/java/org/openrewrite/java/format/EmptyNewlineAtEndOfFile.java b/rewrite-java/src/main/java/org/openrewrite/java/format/EmptyNewlineAtEndOfFile.java index 8fc910d27c7..f4ba85865f5 100644 --- a/rewrite-java/src/main/java/org/openrewrite/java/format/EmptyNewlineAtEndOfFile.java +++ b/rewrite-java/src/main/java/org/openrewrite/java/format/EmptyNewlineAtEndOfFile.java @@ -16,7 +16,10 @@ package org.openrewrite.java.format; import org.jspecify.annotations.Nullable; -import org.openrewrite.*; +import org.openrewrite.ExecutionContext; +import org.openrewrite.Recipe; +import org.openrewrite.Tree; +import org.openrewrite.TreeVisitor; import org.openrewrite.internal.ListUtils; import org.openrewrite.internal.StringUtils; import org.openrewrite.java.JavaIsoVisitor; diff --git a/rewrite-maven/src/main/java/org/openrewrite/maven/ChangePluginConfiguration.java b/rewrite-maven/src/main/java/org/openrewrite/maven/ChangePluginConfiguration.java index 065a22c452c..47218c3f986 100644 --- a/rewrite-maven/src/main/java/org/openrewrite/maven/ChangePluginConfiguration.java +++ b/rewrite-maven/src/main/java/org/openrewrite/maven/ChangePluginConfiguration.java @@ -19,20 +19,14 @@ import lombok.Value; import org.intellij.lang.annotations.Language; import org.jspecify.annotations.Nullable; -import org.openrewrite.*; -import org.openrewrite.internal.StringUtils; +import org.openrewrite.ExecutionContext; +import org.openrewrite.Option; +import org.openrewrite.Recipe; +import org.openrewrite.TreeVisitor; import org.openrewrite.xml.XPathMatcher; -import org.openrewrite.xml.XsltTransformation; -import org.openrewrite.xml.XsltTransformationVisitor; import org.openrewrite.xml.tree.Xml; -import java.io.IOException; -import java.io.InputStream; -import java.nio.charset.Charset; import java.util.Optional; -import java.util.stream.Stream; - -import static java.util.Objects.requireNonNull; import static org.openrewrite.xml.AddOrUpdateChild.addOrUpdateChild; import static org.openrewrite.xml.FilterTagChildrenVisitor.filterChildren; diff --git a/rewrite-maven/src/main/java/org/openrewrite/maven/RemoveManagedDependency.java b/rewrite-maven/src/main/java/org/openrewrite/maven/RemoveManagedDependency.java index 6b0ff091bd3..d277aca5aa1 100644 --- a/rewrite-maven/src/main/java/org/openrewrite/maven/RemoveManagedDependency.java +++ b/rewrite-maven/src/main/java/org/openrewrite/maven/RemoveManagedDependency.java @@ -19,7 +19,6 @@ import lombok.Value; import org.jspecify.annotations.Nullable; import org.openrewrite.*; -import org.openrewrite.maven.tree.ResolvedManagedDependency; import org.openrewrite.maven.tree.Scope; import org.openrewrite.xml.RemoveContentVisitor; import org.openrewrite.xml.tree.Xml; diff --git a/rewrite-maven/src/test/java/org/openrewrite/maven/AddDependencyTest.java b/rewrite-maven/src/test/java/org/openrewrite/maven/AddDependencyTest.java index eaad20ee99b..9a5249a41d9 100644 --- a/rewrite-maven/src/test/java/org/openrewrite/maven/AddDependencyTest.java +++ b/rewrite-maven/src/test/java/org/openrewrite/maven/AddDependencyTest.java @@ -26,7 +26,10 @@ import org.openrewrite.test.RecipeSpec; import org.openrewrite.test.RewriteTest; -import static org.openrewrite.java.Assertions.*; +import static org.openrewrite.java.Assertions.java; +import static org.openrewrite.java.Assertions.mavenProject; +import static org.openrewrite.java.Assertions.srcMainJava; +import static org.openrewrite.java.Assertions.srcTestJava; import static org.openrewrite.maven.Assertions.pomXml; import static org.openrewrite.test.RewriteTest.toRecipe; diff --git a/rewrite-xml/src/test/java/org/openrewrite/xml/trait/NamespacedTest.java b/rewrite-xml/src/test/java/org/openrewrite/xml/trait/NamespacedTest.java index 3ab9b2d5c1c..f2ab33c0330 100644 --- a/rewrite-xml/src/test/java/org/openrewrite/xml/trait/NamespacedTest.java +++ b/rewrite-xml/src/test/java/org/openrewrite/xml/trait/NamespacedTest.java @@ -18,7 +18,7 @@ import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; class NamespacedTest {