Rename PMD rules that were renamed within the PMD 7 line
org.openrewrite.java.pmd.Pmd7RuleRenamesArtifactorg.openrewrite.recipe:rewrite-pmdPMD renamed a number of rules during the PMD 7 line, keeping the old name as a deprecated alias that PMD still loads but warns about. Update the <rule> references and <exclude> elements in PMD ruleset XML files to name each rule's current name, so the ruleset stops emitting deprecation warnings and keeps loading once PMD 8 drops the aliases. Only true renames are applied, meaning the cases where PMD kept the old name as an alias pointing at the new one. Rules PMD deprecated in favour of a *different* rule, such as AvoidCatchingNPE in favour of the configurable AvoidCatchingGenericException, GenericsNaming in favour of TypeParameterNamingConventions, UnnecessaryLocalBeforeReturn in favour of VariableCanBeInlined, UseObjectForClearerAPI in favour of ExcessiveParameterList, and CheckSkipResult, AvoidLosingExceptionInformation and UselessOperationOnImmutable in favour of UnusedReturnValue, are left alone, because the successor reports different things and adopting it is a judgement call rather than a rename. The new names require PMD 7.27.0 or later; a ruleset for an earlier PMD 7 fails to load a name that its version does not know yet.
Usage
This recipe has no required configuration options. You’ll need the Moderne CLI configured before running the command below.
mod run . --recipe org.openrewrite.java.pmd.Pmd7RuleRenamesIf the recipe isn’t available locally, install it with:
mod config recipes jar install org.openrewrite.recipe:rewrite-pmd:RELEASEDefinition
This recipe runs the following recipes in order.
- Replace a PMD rule in a ruleset
org.openrewrite.java.pmd.ReplacePmdRule - Replace a PMD rule in a ruleset
org.openrewrite.java.pmd.ReplacePmdRule - Replace a PMD rule in a ruleset
org.openrewrite.java.pmd.ReplacePmdRule - Replace a PMD rule in a ruleset
org.openrewrite.java.pmd.ReplacePmdRule - Replace a PMD rule in a ruleset
org.openrewrite.java.pmd.ReplacePmdRule - Replace a PMD rule in a ruleset
org.openrewrite.java.pmd.ReplacePmdRule - Replace a PMD rule in a ruleset
org.openrewrite.java.pmd.ReplacePmdRule - Replace a PMD rule in a ruleset
org.openrewrite.java.pmd.ReplacePmdRule - Replace a PMD rule in a ruleset
org.openrewrite.java.pmd.ReplacePmdRule - Replace a PMD rule in a ruleset
org.openrewrite.java.pmd.ReplacePmdRule - Replace a PMD rule in a ruleset
org.openrewrite.java.pmd.ReplacePmdRule - Replace a PMD rule in a ruleset
org.openrewrite.java.pmd.ReplacePmdRule - Replace a PMD rule in a ruleset
org.openrewrite.java.pmd.ReplacePmdRule
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