31-July-2021 - 6.37.0-SNAPSHOT
The PMD team is pleased to announce PMD 6.37.0-SNAPSHOT.
This is a minor release.
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.
New rules
This release ships with 3 new Java rules.
PrimitiveWrapperInstantiation
reports usages of primitive wrapper constructors. They are deprecated since Java 9 and should not be used.
<rule ref="category/java/bestpractices.xml/PrimitiveWrapperInstantiation" />
The rule is part of the quickstart.xml ruleset.
SimplifiableTestAssertion
suggests rewriting some test assertions to be more readable.
<rule ref="category/java/bestpractices.xml/SimplifiableTestAssertion" />
The rule is part of the quickstart.xml ruleset.
ReturnEmptyCollectionRatherThanNull
suggests returning empty collections / arrays instead of null.
<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 toImplicitSwitchFallThrough
(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 usingbreak
butcontinue
,throw
andreturn
avoid a fall-through as well. This enables us to improve this rule in the future.
Deprecated rules
- The following Java rules are deprecated and removed from the quickstart ruleset,
as the new rule
SimplifiableTestAssertion
merges their functionality: -
The Java rule
ReturnEmptyArrayRatherThanNull
is deprecated and removed from the quickstart ruleset, as the new ruleReturnEmptyCollectionRatherThanNull
supersedes it. - The following Java rules are deprecated and removed from the quickstart ruleset,
as the new rule
PrimitiveWrapperInstantiation
merges their functionality: - The Java rule
UnnecessaryWrapperObjectCreation
is deprecated with no planned replacement before PMD 7. In it’s current state, the rule is not useful as it finds only contrived cases of creating a primitive wrapper and unboxing it explicitly in the same expression. In PMD 7 this and more cases will be covered by a new ruleUnnecessaryBoxing
.
Fixed Issues
- apex
- core
- java-bestpractices
- java-errorprone
API Changes
Experimental APIs
- The AST types and APIs around Sealed Classes are not experimental anymore:
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.
- The inner class
net.sourceforge.pmd.cpd.TokenEntry.State
is considered to be internal API. It will probably be moved away with PMD 7.
External Contributions
- #3367: [apex] Check SOQL CRUD on for loops - Jonathan Wiesel
- #3373: [apex] Add ApexCRUDViolation support for database class, inline no-arg object construction DML and inline list initialization DML - Jonathan Wiesel
- #3385: [core] CPD: Optimize –skip-lexical-errors option - Woongsik Choi
- #3388: [doc] Add Code Inspector in the list of tools - Julien Delange