Skip to content

checkstyle/checkstyle-openrewrite-recipes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

checkstyle-openrewrite-recipes

This OpenRewrite recipe automatically fixes Checkstyle violations in your Java project by analyzing the Checkstyle report and applying code transformations to resolve common issues.

Prerequisites

You need a Java project that already has the Checkstyle plugin configured and running.

Setup

First, add the OpenRewrite plugin and our autofix recipe dependency to your build configuration.

Example:

<plugin>
  <groupId>org.openrewrite.maven</groupId>
  <artifactId>rewrite-maven-plugin</artifactId>
  <version>${rewrite.maven.plugin}</version>
  <configuration>
    <activeRecipes>
      <recipe>CheckstyleAutoFix</recipe>
    </activeRecipes>
  </configuration>
  <dependencies>
    <dependency>
      <groupId>org.checkstyle.autofix</groupId>
      <artifactId>checkstyle-openrewrite-recipes</artifactId>
      <version>1.0.0</version>
    </dependency>
  </dependencies>
</plugin>

Configuration

Create a rewrite.yml file in your project root:

---
type: specs.openrewrite.org/v1beta/recipe
name: CheckstyleAutoFix
displayName: Checkstyle Auto Fix
description: Automatically fix Checkstyle violations
recipeList:
  - org.checkstyle.autofix.CheckstyleAutoFix:
      violationReportPath: "target/checkstyle/checkstyle-report.xml"
      configurationPath: "config/checkstyle.xml"
      propertiesPath: "config/checkstyle.properties"

Parameters:

  • violationReportPath: Path to Checkstyle XML report (required)
  • configurationPath: Path to Checkstyle configuration file (required)
  • propertiesPath: Path to Checkstyle properties file (optional)

How to use it

The autofix process works in two steps: first generate a Checkstyle report, then run the autofix recipe.

mvn checkstyle:check    # Generate the violation report
mvn rewrite:run         # Apply the fixes

OpenRewrite Recipe Coverage for Checkstyle Checks

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:

  • Fully supported via auto-fix
  • Partially supported
  • Not feasible to auto-fix

Status Legend

Status Meaning
🟢 Full Coverage – Complete auto-fix capability for all violation scenarios
🟡 Partial Coverage – Auto-fix available for some violation scenarios
🔴 Won't Be Covered – Auto-fix not feasible or not planned

Annotations

Status Check Recipe Coverage Notes
🟢 AnnotationLocation TBD
🟢 AnnotationOnSameLine TBD

Block Checks

No checks analyzed yet

Class Design

Status Check Recipe Coverage Notes
🟢 FinalClass TBD

Coding

Status Check Recipe Coverage Notes
🟢 FinalLocalVariable TBD
🔴 MagicNumber it requires contextual understanding to replace literals with meaningful named constants
🟢 UnusedLocalVariable TBD
🟢 UnnecessaryParentheses TBD

Headers

Status Check Recipe Coverage Notes
🟡 Header Header only java files are fixed.

Imports

Status Check Recipe Coverage Notes
🟢 RedundantImport RedundantImport

Javadoc Comments

No checks analyzed yet

Metrics

No checks analyzed yet

Miscellaneous

Status Check Recipe Coverage Notes
🟢 UpperEll UpperEll

Modifiers

No checks analyzed yet

Naming Conventions

Status Check Recipe Coverage Notes
🔴 AbbreviationAsWordInName Requires semantic understanding of abbreviations and context
🟡 AbstractClassName TBD Partially covered by renaming abstract class names to match the configured pattern.

Regexp

No checks analyzed yet

Size Violations

No checks analyzed yet

Whitespace

No checks analyzed yet

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages