Add a PMD rule to a ruleset
Recipe ID
org.openrewrite.java.pmd.AddPmdRuleArtifactorg.openrewrite.recipe:rewrite-pmdAdds a <rule ref="..."/> reference to PMD ruleset XML files that do not have one yet. When the ruleset already pulls in the whole ruleset file the rule lives in, the rule is enabled by removing the <exclude name="..."/> that was keeping it out rather than by adding a second reference to it.
Single recipeMSAL
Usage
You’ll need the Moderne CLI configured before running the command below.
mod run . --recipe org.openrewrite.java.pmd.AddPmdRule --recipe-option "rule=category/java/errorprone.xml/EmptyCatchBlock"If the recipe isn’t available locally, install it with:
mod config recipes jar install org.openrewrite.recipe:rewrite-pmd:RELEASEOptions
| Name | Type | Description |
|---|---|---|
rulerequired | String | The rule to add, as a fully qualified reference naming both the ruleset file and the rule within it. A bare rule name is not enough, since PMD resolves a rule through the ruleset file it lives in. e.g. category/java/errorprone.xml/EmptyCatchBlock |
Data tables
Structured output this recipe can produce.
- Source files that had resultsSource files that were modified by the recipe run.
org.openrewrite.table.SourcesFileResults - Source files that had search resultsSearch results that were found during the recipe run.
org.openrewrite.table.SearchResults - Source files that errored on a recipeThe details of all errors produced by a recipe run.
org.openrewrite.table.SourcesFileErrors - Recipe performanceStatistics used in analyzing the performance of recipes.
org.openrewrite.table.RecipeRunStats