Skip to content

Commit e37d36d

Browse files
author
Vincent Potucek
committed
activate unused rewrite checks failOnDryRunResults
1 parent 942a2f8 commit e37d36d

File tree

2 files changed

+48
-12
lines changed

2 files changed

+48
-12
lines changed

CONTRIBUTING.md

Lines changed: 41 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -76,18 +76,47 @@ Whenever an acronym is included as part of a field name or parameter name:
7676

7777
#### Code
7878

79-
Code formatting is enforced using the [Spotless](https://github.com/diffplug/spotless)
80-
Gradle plugin. You can use `gradle spotlessApply` to format new code and add missing
81-
license headers to source files. Formatter and import order settings for Eclipse are
82-
available in the repository under
83-
[junit-eclipse-formatter-settings.xml](gradle/config/eclipse/junit-eclipse-formatter-settings.xml)
84-
and [junit-eclipse.importorder](gradle/config/eclipse/junit-eclipse.importorder),
85-
respectively. For IntelliJ IDEA there's a
86-
[plugin](https://plugins.jetbrains.com/plugin/6546) you can use in conjunction with the
87-
Eclipse settings.
88-
89-
It is forbidden to use _wildcard imports_ (e.g., `import static org.junit.jupiter.api.Assertions.*;`)
90-
in Java code.
79+
Code formatting is automatically enforced using the [Spotless](https://github.com/diffplug/spotless) Gradle plugin during the build process. The build will:
80+
81+
- Automatically format all code
82+
- Add missing license headers
83+
- Correct import order
84+
- Fix other style issues
85+
86+
You can run the plugin goal `gradle spotlessApply` to apply formation.
87+
Nevertheless, that´s not required, as the build handles everything automatically.
88+
89+
IDE configuration is available for consistency:
90+
- **Eclipse**: Use our predefined settings:
91+
- [Formatter config](gradle/config/eclipse/junit-eclipse-formatter-settings.xml)
92+
- [Import order](gradle/config/eclipse/junit-eclipse.importorder)
93+
- **IntelliJ**: Install the [Eclipse Code Formatter plugin](https://plugins.jetbrains.com/plugin/6546) with our settings
94+
95+
**Important**: Wildcard imports (e.g., `import static org.junit.jupiter.api.Assertions.*;`) remain strictly forbidden.
96+
97+
**Usage requirements:**
98+
1. Both `CI` and `rewriteRun` environment variables must be set:
99+
- `CI=false` to enable execution
100+
- `spotlessApply=true` to auto-apply suggestions
101+
2. Dry runs execute by default for change preview
102+
3. Changes are blocked in CI environments (when `CI=true`)
103+
4. Always review changes before applying
104+
105+
just add this to your shell config: ~/.zshrc
106+
export spotlessApply=true
107+
export rewriteRun=true
108+
109+
#### Rewriting
110+
111+
The build supports automated code refactoring through [Moderne](https://moderne.io/) rewrite rules. These transformations are controlled exclusively through environment variables - there is no local variable configuration option to apply automatic fixes out of the box.
112+
113+
**Usage requirements:**
114+
1. Both `CI` and `rewriteRun` environment variables must be set:
115+
- `CI=false` to enable execution
116+
- `rewriteRun=true` to auto-apply suggestions
117+
2. Dry runs execute by default for change preview
118+
3. Changes are blocked in CI environments (when `CI=true`)
119+
4. Always review changes before applying
91120

92121
#### Documentation
93122

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,15 @@ plugins {
1818

1919
rewrite {
2020
activeRecipe("org.openrewrite.java.migrate.UpgradeToJava17")
21+
activeRecipe("org.openrewrite.staticanalysis.RemoveUnusedPrivateMethods")
22+
activeRecipe("org.openrewrite.staticanalysis.MissingOverrideAnnotation")
23+
failOnDryRunResults = true
2124
}
2225

2326
dependencies {
2427
rewrite(platform("org.openrewrite.recipe:rewrite-recipe-bom:latest.release"))
2528
rewrite("org.openrewrite.recipe:rewrite-migrate-java")
29+
rewrite("org.openrewrite.recipe:rewrite-static-analysis")
2630
}
2731

2832
val mavenizedProjects: List<Project> by rootProject.extra
@@ -280,6 +284,9 @@ tasks {
280284
checkstyleTest {
281285
config = resources.text.fromFile(checkstyle.configDirectory.file("checkstyleTest.xml"))
282286
}
287+
check {
288+
dependsOn("rewriteDryRun")
289+
}
283290
}
284291

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

0 commit comments

Comments
 (0)