Rename PMD rules that were renamed within the PMD 7 line

MSAL

PMD 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.

org.openrewrite.java.pmd.Pmd7RuleRenames
mod run . --recipe=org.openrewrite.java.pmd.Pmd7RuleRenames

Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.

Recipe list

It runs these recipes, in this order.

  1. Replace a PMD rule in a ruleset
  2. Replace a PMD rule in a ruleset
  3. Replace a PMD rule in a ruleset
  4. Replace a PMD rule in a ruleset
  5. Replace a PMD rule in a ruleset
  6. Replace a PMD rule in a ruleset
  7. Replace a PMD rule in a ruleset
  8. Replace a PMD rule in a ruleset
  9. Replace a PMD rule in a ruleset
  10. Replace a PMD rule in a ruleset
  11. Replace a PMD rule in a ruleset
  12. Replace a PMD rule in a ruleset
  13. Replace a PMD rule in a ruleset
  14. Deduplicate PMD rule references