PMD 6.37.0 released

31 July 2021


31-July-2021 - 6.37.0

The PMD team is pleased to announce PMD 6.37.0.

This is a minor release.

Table Of Contents

New and noteworthy

Java 17 Support

This release of PMD brings support for Java 17. PMD supports JEP 409: Sealed Classes which has been promoted to be a standard language feature of Java 17.

PMD also supports JEP 406: Pattern Matching for switch (Preview) as a preview language feature. In order to analyze a project with PMD that uses these language features, you’ll need to enable it via the environment variable PMD_JAVA_OPTS and select the new language version 17-preview:

export PMD_JAVA_OPTS=--enable-preview
./run.sh pmd -language java -version 17-preview ...

Note: Support for Java 15 preview language features have been removed. The version “15-preview” is no longer available.

Updated PMD Designer

This PMD release ships a new version of the pmd-designer. For the changes, see PMD Designer Changelog.

New rules

This release ships with 3 new Java rules.

    <rule ref="category/java/bestpractices.xml/PrimitiveWrapperInstantiation" />

The rule is part of the quickstart.xml ruleset.

    <rule ref="category/java/bestpractices.xml/SimplifiableTestAssertion" />

The rule is part of the quickstart.xml ruleset.

    <rule ref="category/java/errorprone.xml/ReturnEmptyCollectionRatherThanNull" />

The rule is part of the quickstart.xml ruleset.

Renamed rules

  • The Java rule MissingBreakInSwitch has been renamed to ImplicitSwitchFallThrough (category error prone) to better reflect the rule’s purpose: The rule finds implicit fall-through cases in switch statements, which are most likely unexpected. The old rule name described only one way how to avoid a fall-through, namely using break but continue, throw and return avoid a fall-through as well. This enables us to improve this rule in the future.

Deprecated rules

Fixed Issues

  • apex
    • #3201: [apex] ApexCRUDViolation doesn’t report Database class DMLs, inline no-arg object instantiations and inline list initialization
    • #3329: [apex] ApexCRUDViolation doesn’t report SOQL for loops
  • core
    • #1603: [core] Language version comparison
    • #2133: [xml] Allow to check Salesforce XML Metadata using XPath rules
    • #3377: [core] NPE when specifying report file in current directory in PMD CLI
    • #3387: [core] CPD should avoid unnecessary copies when running with –skip-lexical-errors
  • java-bestpractices
    • #2908: [java] Merge Junit assertion simplification rules
    • #3235: [java] UseTryWithResources false positive when closeable is provided as a method argument or class field
  • java-errorprone
    • #3361: [java] Rename rule MissingBreakInSwitch to ImplicitSwitchFallThrough
    • #3382: [java] New rule ReturnEmptyCollectionRatherThanNull
  • java-performance
    • #3420: [java] NPE in InefficientStringBuffering with Records

API Changes

PMD CLI

  • PMD has a new CLI option -force-language. With that a language can be forced to be used for all input files, irrespective of filenames. When using this option, the automatic language selection by extension is disabled and all files are tried to be parsed with the given language. Parsing errors are ignored and unparsable files are skipped.

    This option allows to use the xml language for files, that don’t use xml as extension. See also the examples on PMD CLI reference.

Experimental APIs

Internal API

Those APIs are not intended to be used by clients, and will be hidden or removed with PMD 7.0.0. You can identify them with the @InternalApi annotation. You’ll also get a deprecation warning.

External Contributions

Stats

  • 82 commits
  • 29 closed tickets & PRs
  • Days since last release: 35