diff --git a/config/checkstyle.properties b/config/checkstyle.properties
new file mode 100644
index 0000000..2db67e3
--- /dev/null
+++ b/config/checkstyle.properties
@@ -0,0 +1,8 @@
+
+checkstyle.suppressions.file=config/suppressions.xml
+checkstyle.suppressions-xpath.file=config/suppressions.xml
+checkstyle.header.file=https://raw.githubusercontent.com/checkstyle/checkstyle/master/config/java.header
+checkstyle.regexp.header.file=https://raw.githubusercontent.com/checkstyle/checkstyle/master/config/java-regexp.header
+checkstyle.importcontrol.file=config/import-control.xml
+checkstyle.importcontroltest.file=config/import-control-test.xml
+checkstyle.java.version=11
\ No newline at end of file
diff --git a/config/import-control-test.xml b/config/import-control-test.xml
new file mode 100644
index 0000000..76f669e
--- /dev/null
+++ b/config/import-control-test.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/config/import-control.xml b/config/import-control.xml
new file mode 100644
index 0000000..c2c794a
--- /dev/null
+++ b/config/import-control.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/config/suppressions.xml b/config/suppressions.xml
new file mode 100644
index 0000000..1d3a562
--- /dev/null
+++ b/config/suppressions.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 13553e7..8e54ad6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -24,6 +24,10 @@
3.9.0
5.13.0
3.24.2
+
+
+ 3.6.0
+ 10.25.0
@@ -97,9 +101,46 @@
+
+
+
+ org.apache.maven.plugins
+ maven-checkstyle-plugin
+ ${maven.checkstyle.plugin.version}
+
+
+ com.puppycrawl.tools
+ checkstyle
+ ${checkstyle.version}
+
+
+
+
+ check
+
+ check
+
+
+ false
+ false
+ true
+
+ https://raw.githubusercontent.com/checkstyle/checkstyle/checkstyle-${checkstyle.version}/config/checkstyle-checks.xml
+
+ config/checkstyle.properties
+ true
+ true
+ 0
+ error
+ xml
+
+ ${project.build.directory}/checkstyle/checkstyle-report.xml
+
+
+
+
+
-
-
\ No newline at end of file
diff --git a/src/main/java/org/checkstyle/autofix/CheckstyleAutoFix.java b/src/main/java/org/checkstyle/autofix/CheckstyleAutoFix.java
index a46169a..6d13951 100644
--- a/src/main/java/org/checkstyle/autofix/CheckstyleAutoFix.java
+++ b/src/main/java/org/checkstyle/autofix/CheckstyleAutoFix.java
@@ -1,14 +1,13 @@
package org.checkstyle.autofix;
-import org.openrewrite.Recipe;
-
import java.util.Collections;
import java.util.List;
import org.checkstyle.autofix.recipe.UpperEllRecipe;
+import org.openrewrite.Recipe;
/**
- * Main recipe that automatically fixes all supported Checkstyle violations
+ * Main recipe that automatically fixes all supported Checkstyle violations.
*/
public class CheckstyleAutoFix extends Recipe {
@@ -26,7 +25,7 @@ public String getDescription() {
public List getRecipeList() {
return Collections.singletonList(
- new UpperEllRecipe()
+ new UpperEllRecipe()
);
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/checkstyle/autofix/recipe/UpperEllRecipe.java b/src/main/java/org/checkstyle/autofix/recipe/UpperEllRecipe.java
index abfe4ec..a1ca5b9 100644
--- a/src/main/java/org/checkstyle/autofix/recipe/UpperEllRecipe.java
+++ b/src/main/java/org/checkstyle/autofix/recipe/UpperEllRecipe.java
@@ -20,7 +20,8 @@ public String getDisplayName() {
@Override
public String getDescription() {
- return "Replace lowercase 'l' suffix in long literals with uppercase 'L' to improve readability.";
+ return "Replace lowercase 'l' suffix in long literals with uppercase 'L' "
+ + "to improve readability.";
}
@Override
@@ -28,17 +29,20 @@ public TreeVisitor, ExecutionContext> getVisitor() {
return new UpperEllVisitor();
}
- private static class UpperEllVisitor extends JavaIsoVisitor {
+ /**
+ * Visitor that replaces lowercase 'l' suffixes in long literals with uppercase 'L'.
+ */
+ private static final class UpperEllVisitor extends JavaIsoVisitor {
@Override
public J.Literal visitLiteral(J.Literal literal, ExecutionContext ctx) {
J.Literal result = super.visitLiteral(literal, ctx);
- String valueSource = result.getValueSource();
+ final String valueSource = result.getValueSource();
if (valueSource != null && valueSource.endsWith("l")
- && result.getType() == JavaType.Primitive.Long) {
- String numericPart = valueSource.substring(0, valueSource.length() - 1);
- String newValueSource = numericPart + "L";
- result = result.withValueSource(newValueSource);
+ && result.getType() == JavaType.Primitive.Long) {
+ final String numericPart = valueSource.substring(0, valueSource.length() - 1);
+ final String newValueSource = numericPart + "L";
+ result = result.withValueSource(newValueSource);
}
return result;
}
diff --git a/src/test/java/org/checkstyle/autofix/recipe/UpperEllRecipeTest.java b/src/test/java/org/checkstyle/autofix/recipe/UpperEllRecipeTest.java
index a8c1cb5..fa047b0 100644
--- a/src/test/java/org/checkstyle/autofix/recipe/UpperEllRecipeTest.java
+++ b/src/test/java/org/checkstyle/autofix/recipe/UpperEllRecipeTest.java
@@ -1,12 +1,12 @@
package org.checkstyle.autofix.recipe;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.openrewrite.java.Assertions.java;
+
import org.junit.jupiter.api.Test;
import org.openrewrite.test.RecipeSpec;
import org.openrewrite.test.RewriteTest;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.openrewrite.java.Assertions.java;
-
public class UpperEllRecipeTest implements RewriteTest {
@Override
@@ -15,24 +15,24 @@ public void defaults(RecipeSpec spec) {
}
@Test
- void fixesLowercaseLInLongLiteralsFromResources() {
+ void fixesLowercase() {
rewriteRun(
java(
- "class Test {\n" +
- " int value1 = 123l;\n" +
- " long value2 = 0x123l;\n" +
- " long value3 = 0123l;\n" +
- " long value4 = 0b101l;\n" +
- " String value5 = null;\n" +
- "}\n",
- "class Test {\n" +
- " int value1 = 123L;\n" +
- " long value2 = 0x123L;\n" +
- " long value3 = 0123L;\n" +
- " long value4 = 0b101L;\n" +
- " String value5 = null;\n" +
- "}\n"
+ "class Test {\n"
+ + " int value1 = 123l;\n"
+ + " long value2 = 0x123l;\n"
+ + " long value3 = 0123l;\n"
+ + " long value4 = 0b101l;\n"
+ + " String value5 = null;\n"
+ + "}\n",
+ "class Test {\n"
+ + " int value1 = 123L;\n"
+ + " long value2 = 0x123L;\n"
+ + " long value3 = 0123L;\n"
+ + " long value4 = 0b101L;\n"
+ + " String value5 = null;\n"
+ + "}\n"
)
);
assertTrue(true, "Test completed successfully");