Files
pmd/docs/pages/release_notes.md
2022-03-03 22:00:58 +01:00

3.5 KiB

title, permalink, keywords
title permalink keywords
PMD Release Notes pmd_release_notes.html changelog, release notes

{{ site.pmd.date }} - {{ site.pmd.version }}

The PMD team is pleased to announce PMD {{ site.pmd.version }}.

This is a {{ site.pmd.release_type }} release.

{% tocmaker is_release_notes_processor %}

New and noteworthy

New programmatic API

This release introduces a new programmatic API to replace the inflexible {% jdoc core::PMD %} class. Programmatic execution of PMD should now be done with a {% jdoc core::PMDConfiguration %} and a {% jdoc core::PmdAnalysis %}, for instance:

PMDConfiguration config = new PMDConfiguration();
config.setDefaultLanguageVersion(LanguageRegistry.findLanguageByTerseName("java").getVersion("11"));
config.setInputPaths("src/main/java");
config.prependAuxClasspath("target/classes");
config.setMinimumPriority(RulePriority.HIGH);
config.setRuleSets("rulesets/java/quickstart.xml");
config.setReportFormat("xml");
config.setReportFile("target/pmd-report.xml");

try (PmdAnalysis pmd = PmdAnalysis.create(config)) {
    // optional: add more rulesets
    pmd.addRuleSet(RuleSetLoader.fromPmdConfig(configuration).loadFromResource("custom-ruleset.xml"));
    // optional: add more files
    pmd.files().addFile(Paths.get("src", "main", "more-java", "ExtraSource.java"));
    // optional: add more renderers
    pmd.addRenderer(renderer);

    // or just call PMD
    pmd.performAnalysis();
}

The PMD class still supports methods related to CLI execution: runPmd and main. All other members are now deprecated for removal. The CLI itself remains compatible, if you run PMD via command-line, no action is required on your part.

Fixed Issues

  • apex-performance
    • #3773: [apex] EagerlyLoadedDescribeSObjectResult false positives with SObjectField.getDescribe()

API Changes

Deprecated API

  • Several members of {% jdoc core::PMD %} have been newly deprecated, including:

    • PMD#EOL: use System#lineSeparator()
    • PMD#SUPPRESS_MARKER: use {% jdoc core::PMDConfiguration#DEFAULT_SUPPRESS_MARKER %}
    • PMD#processFiles: use the new programmatic API
    • PMD#getApplicableFiles: is internal
  • {% jdoc !!core::PMDConfiguration#prependClasspath(java.lang.String) %} is deprecated in favour of {% jdoc core::PMDConfiguration#prependAuxClasspath(java.lang.String) %}.

  • In modelica, the rule classes {% jdoc modelica::lang.modelica.rule.AmbiguousResolutionRule %} and {% jdoc modelica::lang.modelica.rule.ConnectUsingNonConnector %} have been deprecated, since they didn't comply to the usual rule class naming conventions yet. The replacements are in the subpackage bestpractices.

Experimental APIs

  • Together with the new programmatic API the interface {% jdoc core::lang.document.TextFile %} has been added as experimental. It intends to replace {% jdoc core::util.datasource.DataSource %} and {% jdoc core::cpd.SourceCode %} in the long term.

    This interface will change in PMD 7 to support read/write operations and other things. You don't need to use it in PMD 6, as {% jdoc core::lang.document.FileCollector %} decouples you from this. A file collector is available through {% jdoc !!core::PmdAnalysis#files() %}.

External Contributions

  • #3773: [apex] EagerlyLoadedDescribeSObjectResult false positives with SObjectField.getDescribe() - @filiprafalowicz

{% endtocmaker %}