Skip to content

Commit 72e79f0

Browse files
author
Vincent Potucek
committed
(re)activate rewrite capability
1 parent 0807b2c commit 72e79f0

File tree

9 files changed

+21
-16
lines changed

9 files changed

+21
-16
lines changed

CONTRIBUTING.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ Whenever an acronym is included as part of a field name or parameter name:
7272
- Otherwise, keep the first letter of the acronym uppercase and use lowercase for the
7373
rest of the acronym -- for example, `String defaultUrl;`.
7474

75-
### Formatting
75+
### Automated Refactoring
7676

77-
#### Code
77+
#### Formatting
7878

7979
Code formatting is enforced using the [Spotless](https://github.com/diffplug/spotless)
8080
Gradle plugin. You can use `gradle spotlessApply` to format new code and add missing
@@ -89,6 +89,12 @@ Eclipse settings.
8989
It is forbidden to use _wildcard imports_ (e.g., `import static org.junit.jupiter.api.Assertions.*;`)
9090
in Java code.
9191

92+
#### Recipes
93+
94+
The build system incorporates [Moderne](https://moderne.io/) rewrite capabilities for automated code transformations. These modifications are environment-driven enlisted in the [junitbuild.java-library-conventions.gradle.kts](gradle/plugins/common/src/main/kotlin/junitbuild.java-library-conventions.gradle.kts)
95+
96+
You can use `gradle rewriteRun` to apply these changes.
97+
9298
#### Documentation
9399

94100
Text in `*.adoc` and `*.md` files should be wrapped at 90 characters whenever technically

documentation/src/test/resources/log4j2-test.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@
1616
<AppenderRef ref="Console" />
1717
</Root>
1818
</Loggers>
19-
</Configuration>
19+
</Configuration>

gradle/plugins/common/src/main/kotlin/junitbuild.java-library-conventions.gradle.kts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@ plugins {
1818
}
1919

2020
rewrite {
21-
activeRecipe("org.openrewrite.java.migrate.UpgradeToJava17")
21+
activeRecipe("org.openrewrite.staticanalysis.MissingOverrideAnnotation")
22+
activeRecipe("org.openrewrite.text.EndOfLineAtEndOfFile")
23+
failOnDryRunResults = true
2224
}
2325

2426
dependencies {
2527
rewrite(platform(dependencyFromLibs("openrewrite-recipe-bom")))
26-
rewrite("org.openrewrite.recipe:rewrite-migrate-java")
28+
rewrite("org.openrewrite.recipe:rewrite-static-analysis")
2729
}
2830

2931
val mavenizedProjects: List<Project> by rootProject.extra
@@ -281,6 +283,9 @@ tasks {
281283
checkstyleTest {
282284
config = resources.text.fromFile(checkstyle.configDirectory.file("checkstyleTest.xml"))
283285
}
286+
check {
287+
dependsOn(rewriteDryRun)
288+
}
284289
}
285290

286291
pluginManager.withPlugin("java-test-fixtures") {

gradle/plugins/common/src/main/kotlin/junitbuild.spotless-conventions.gradle.kts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,11 @@ spotless {
1313
targetExclude("gradle/plugins/**/build/**")
1414
leadingSpacesToTabs()
1515
trimTrailingWhitespace()
16-
endWithNewline()
1716
}
1817

1918
format("documentation") {
2019
target("*.adoc", "*.md", "src/**/*.adoc", "src/**/*.md")
2120
trimTrailingWhitespace()
22-
endWithNewline()
2321
}
2422

2523
pluginManager.withPlugin("java") {
@@ -36,7 +34,6 @@ spotless {
3634
val majorMinorVersion = "([0-9]+\\.[0-9]+).*".toRegex().matchEntire(fullVersion)!!.let { it.groups[1]!!.value }
3735
eclipse(majorMinorVersion).configFile(javaFormatterConfigFile)
3836
trimTrailingWhitespace()
39-
endWithNewline()
4037
removeUnusedImports()
4138
}
4239

@@ -46,7 +43,6 @@ spotless {
4643
})
4744
licenseHeaderFile(license.headerFile, "^$")
4845
trimTrailingWhitespace()
49-
endWithNewline()
5046
}
5147
}
5248

@@ -56,7 +52,6 @@ spotless {
5652
ktlint(requiredVersionFromLibs("ktlint"))
5753
licenseHeaderFile(license.headerFile)
5854
trimTrailingWhitespace()
59-
endWithNewline()
6055
}
6156
configurations.named { it.startsWith("spotless") }.configureEach {
6257
// Workaround for CVE-2024-12798 and CVE-2024-12801
@@ -74,7 +69,6 @@ spotless {
7469
groovy {
7570
licenseHeaderFile(license.headerFile)
7671
trimTrailingWhitespace()
77-
endWithNewline()
7872
}
7973
}
8074
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
org.junit.jupiter.engine.JupiterTestEngine
1+
org.junit.jupiter.engine.JupiterTestEngine
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
org.junit.vintage.engine.VintageTestEngine
1+
org.junit.vintage.engine.VintageTestEngine

junit-vintage-engine/src/test/resources/log4j2-test.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
<AppenderRef ref="Console" />
1414
</Root>
1515
</Loggers>
16-
</Configuration>
16+
</Configuration>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
I am used by tests, so...
22

3-
Do NOT delete me!
3+
Do NOT delete me!
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
org.junit.platform.launcher.listeners.NoopTestExecutionListener
22
org.junit.platform.launcher.listeners.UnusedTestExecutionListener
3-
org.junit.platform.launcher.listeners.AnotherUnusedTestExecutionListener
3+
org.junit.platform.launcher.listeners.AnotherUnusedTestExecutionListener

0 commit comments

Comments
 (0)