Skip to content

Commit 85c5edb

Browse files
Anmol202005rdiachenko
authored andcommitted
Issue #88: Added configuration guildelines to README.
1 parent 580c91f commit 85c5edb

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

README.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,59 @@
11
# checkstyle-openrewrite-recipes
2+
This OpenRewrite recipe automatically fixes Checkstyle violations in your Java project by analyzing the Checkstyle report and applying code transformations to resolve common issues.
3+
4+
## Prerequisites
5+
You need a Java project that already has the Checkstyle plugin configured and running.
6+
7+
## Setup
8+
First, add the OpenRewrite plugin and our autofix recipe dependency to your build configuration.
9+
10+
### Example:
11+
```xml
12+
<plugin>
13+
<groupId>org.openrewrite.maven</groupId>
14+
<artifactId>rewrite-maven-plugin</artifactId>
15+
<version>${rewrite.maven.plugin}</version>
16+
<configuration>
17+
<activeRecipes>
18+
<recipe>CheckstyleAutoFix</recipe>
19+
</activeRecipes>
20+
</configuration>
21+
<dependencies>
22+
<dependency>
23+
<groupId>org.checkstyle.autofix</groupId>
24+
<artifactId>checkstyle-openrewrite-recipes</artifactId>
25+
<version>1.0.0</version>
26+
</dependency>
27+
</dependencies>
28+
</plugin>
29+
```
30+
## Configuration
31+
Create a `rewrite.yml` file in your project root:
32+
33+
```yml
34+
---
35+
type: specs.openrewrite.org/v1beta/recipe
36+
name: CheckstyleAutoFix
37+
displayName: Checkstyle Auto Fix
38+
description: Automatically fix Checkstyle violations
39+
recipeList:
40+
- org.checkstyle.autofix.CheckstyleAutoFix:
41+
violationReportPath: "target/checkstyle/checkstyle-report.xml"
42+
configurationPath: "config/checkstyle.xml"
43+
propertiesPath: "config/checkstyle.properties"
44+
```
45+
46+
Parameters:
47+
- `violationReportPath`: Path to Checkstyle XML report (required)
48+
- `configurationPath`: Path to Checkstyle configuration file (required)
49+
- `propertiesPath`: Path to Checkstyle properties file (optional)
50+
51+
## How to use it
52+
The autofix process works in two steps: first generate a Checkstyle report, then run the autofix recipe.
53+
```
54+
mvn checkstyle:check # Generate the violation report
55+
mvn rewrite:run # Apply the fixes
56+
```
257
## OpenRewrite Recipe Coverage for Checkstyle Checks
358

459
This table tracks the auto-fix support status of OpenRewrite recipes for each Checkstyle check. Organized by Checkstyle categories, it helps contributors identify which checks are:

0 commit comments

Comments
 (0)