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
- Updated PMD Designer
- New rules
- Renamed rules
- Deprecated rules
- Fixed Issues
- API Changes
- PMD CLI
- Experimental APIs
- Internal API
- External Contributions
- Stats
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.
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 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 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 ruleSimplifiableTestAssertion
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 rulePrimitiveWrapperInstantiation
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
- java-performance
- #3420: [java] NPE in
InefficientStringBuffering
with Records
- #3420: [java] NPE in
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
- 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
- #3417: [core] Support forcing a specific language from the command-line - Aidan Harding
Stats
- 82 commits
- 29 closed tickets & PRs
- Days since last release: 35