Replace a PMD rule in a ruleset
Recipe ID
org.openrewrite.java.pmd.ReplacePmdRuleArtifactorg.openrewrite.recipe:rewrite-pmdUpdates <rule ref="..."/> references and <exclude name="..."/> elements in PMD ruleset XML files to name a rule's replacement. An <exclude> is only renamed when the replacement lives in the same ruleset file, because an exclusion can only name a rule from the ruleset its enclosing <rule> refers to; when the replacement moved to another ruleset file the exclusion no longer names a rule PMD knows, so it is removed instead.
Single recipeMSAL
Usage
You’ll need the Moderne CLI configured before running the command below.
mod run . --recipe org.openrewrite.java.pmd.ReplacePmdRule --recipe-option "oldRule=category/java/errorprone.xml/MissingBreakInSwitch" --recipe-option "newRule=ImplicitSwitchFallThrough"If the recipe isn’t available locally, install it with:
mod config recipes jar install org.openrewrite.recipe:rewrite-pmd:RELEASEOptions
| Name | Type | Description |
|---|---|---|
oldRulerequired | String | The rule to replace, either a fully qualified reference such as category/java/errorprone.xml/MissingBreakInSwitch or just the rule name, in which case the rule is replaced regardless of which ruleset file it is referenced from.e.g. category/java/errorprone.xml/MissingBreakInSwitch |
newRulerequired | String | The rule to replace it with. Give a fully qualified reference when the replacement lives in a different ruleset file; a bare rule name keeps the existing ruleset file. e.g. ImplicitSwitchFallThrough |
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