Skip to content

Commit 82fe777

Browse files
committed
Issue #88: Added configuration guildelines to README.
1 parent 580c91f commit 82fe777

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

README.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,57 @@
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+
## Prerequisites
4+
You need a Java project that already has the Checkstyle plugin configured and running.
5+
## Setup
6+
First, add the OpenRewrite plugin and our autofix recipe dependency to your build configuration.
7+
8+
### Example:
9+
```xml
10+
<plugin>
11+
<groupId>org.openrewrite.maven</groupId>
12+
<artifactId>rewrite-maven-plugin</artifactId>
13+
<version>${rewrite.maven.plugin}</version>
14+
<configuration>
15+
<activeRecipes>
16+
<recipe>AutoFix</recipe>
17+
</activeRecipes>
18+
</configuration>
19+
<dependencies>
20+
<dependency>
21+
<groupId>org.checkstyle.autofix</groupId>
22+
<artifactId>checkstyle-openrewrite-recipes</artifactId>
23+
<version>1.0.0</version>
24+
</dependency>
25+
</dependencies>
26+
</plugin>
27+
```
28+
## Configuration
29+
Next, create a rewrite.yml file in your project's root directory. This file tells the recipe where to find your Checkstyle report and configuration.
30+
The recipe needs to know three things:
31+
32+
- violationReportPath: Where your Checkstyle XML report is generated (required)
33+
- configurationPath: Path to your Checkstyle configuration file (required)
34+
- propertiesPath: Path to your Checkstyle properties file if you use one (optional)
35+
36+
### Example:
37+
```yml
38+
---
39+
type: specs.openrewrite.org/v1beta/recipe
40+
name: AutoFix
41+
displayName: Checkstyle Auto Fix
42+
description: Automatically fix Checkstyle violations
43+
recipeList:
44+
- org.checkstyle.autofix.CheckstyleAutoFix:
45+
violationReportPath: "target/checkstyle/checkstyle-report.xml"
46+
configurationPath: "config/checkstyle.xml"
47+
propertiesPath: "config/checkstyle.properties"
48+
```
49+
## How to use it
50+
The autofix process works in two steps: first generate a fresh Checkstyle report, then run the autofix recipe.
51+
```
52+
mvn checkstyle:check # Generate the violation report
53+
mvn rewrite:run # Apply the fixes
54+
```
255
## OpenRewrite Recipe Coverage for Checkstyle Checks
356

457
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)