-
Notifications
You must be signed in to change notification settings - Fork 88
Description
My goal is to bulk-refactor a project at build time, following the CheckStyle rules defined in a checkstyle.xml file.
To that end, I read the documentation at https://docs.openrewrite.org/running-recipes/popular-recipe-guides/automatically-fix-checkstyle-violations, mandating the following Maven config:
pom.xml from the documentation page
<project>
<build>
<plugins>
<plugin>
<groupId>org.openrewrite.maven</groupId>
<artifactId>rewrite-maven-plugin</artifactId>
<version>6.16.1</version>
<configuration>
<activeRecipes>
<recipe>org.openrewrite.staticanalysis.CodeCleanup</recipe>
</activeRecipes>
</configuration>
<dependencies>
<dependency>
<groupId>org.openrewrite.recipe</groupId>
<artifactId>rewrite-static-analysis</artifactId>
<version>{{VERSION_REWRITE_STATIC_ANALYSIS}}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.4.0</version>
<configuration>
<configLocation>checkstyle.xml</configLocation>
</configuration>
</plugin>
</plugins>
</build>
</project>My own Maven config (relevant part of) is the following, which looks similar enough:
My own pom.xml
<plugins>
<plugin>
<groupId>org.openrewrite.maven</groupId>
<artifactId>rewrite-maven-plugin</artifactId>
<version>6.17.0</version>
<configuration>
<activeRecipes>
<recipe>org.openrewrite.staticanalysis.CodeCleanup</recipe>
</activeRecipes>
</configuration>
<dependencies>
<dependency>
<groupId>org.openrewrite.recipe</groupId>
<artifactId>rewrite-static-analysis</artifactId>
<version>2.16.0</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${checkstyle.version}</version> // 3.6.0
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
<configuration>
<configLocation>checkstyle.xml</configLocation>
<consoleOutput>true</consoleOutput>
<failsOnError>true</failsOnError>
<violationSeverity>warning</violationSeverity>
</configuration>
</plugin>
</plugins>However, running mvn rewrite:dryRun seems to ignore some style issues that CheckStyle complains about, and complains about issues that CheckStyle does not complain about; in other words, it seems rewrite-maven-plugin isn't picking up the checkstyle.xml file.
Indeed, if I run mvn rewrite:discover I get
...
[INFO]
[INFO] Active Styles:
[INFO]
[INFO] Active Recipes:
[INFO] org.openrewrite.staticanalysis.CodeCleanup
[INFO]
[INFO] Found 447 available recipes and 6 available styles.
[INFO] Configured with 1 active recipes and 0 active styles.
So, no active styles.
I double-checked that, on the other hand, CheckStyle is actually running based on that file (if I alter the name of the file in the <configLocation/> property, mvn clean checkstyle:check breaks because it can't find it.
What could I be doing wrong?
Thanks in advance!
Edit: here is a small PoC of this problem.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status