30-July-2022 - 6.48.0-SNAPSHOT
The PMD team is pleased to announce PMD 6.48.0-SNAPSHOT.
This is a minor release.
New and noteworthy
Java 19 Support
This release of PMD brings support for Java 19. There are no new standard language features.
PMD supports JEP 427: Pattern Matching for switch (Third Preview) and JEP 405: Record Patterns (Preview) as preview language features.
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 19-preview
:
export PMD_JAVA_OPTS=--enable-preview
./run.sh pmd -language java -version 19-preview ...
Note: Support for Java 17 preview language features have been removed. The version “17-preview” is no longer available.
Gherkin support
Thanks to the contribution from Anne Brouwers PMD now has CPD support for the Gherkin language. It is used to defined test cases for the Cucumber testing tool for behavior-driven development.
Being based on a proper Antlr grammar, CPD can:
- ignore comments
- honor comment-based suppressions
Fixed Issues
- core
- java
- #4015: [java] Support JDK 19
- java-bestpractices
- #3455: [java] WhileLoopWithLiteralBoolean - false negative with complex expressions
- java-design
- java-performance
- #3625: [java] AddEmptyString - false negative with empty var
API Changes
Deprecated API
- The experimental Java AST class
ASTGuardedPattern
has been deprecated and will be removed. It was introduced for Java 17 and Java 18 Preview as part of pattern matching for switch, but it is no longer supported with Java 19 Preview. - The interface
CPDRenderer
is deprecated. For custom CPD renderers the new interfaceCPDReportRenderer
should be used.
Experimental APIs
- To support the Java preview language features “Pattern Matching for Switch” and “Record Patterns”, the following AST nodes have been introduced as experimental:
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.
CPDConfiguration#setRenderer
CPDConfiguration#setCPDRenderer
CPDConfiguration#getRenderer
CPDConfiguration#getCPDRenderer
CPDConfiguration#getRendererFromString
CPDConfiguration#getCPDRendererFromString
CPDRendererAdapter
External Contributions
- #3984: [java] Fix AddEmptyString false-negative issue - @LiGaOg
- #3988: [java] Modify WhileLoopWithLiteralBoolean to meet the missing case #3455 - @VoidxHoshi
- #3992: [java] FinalFieldCouldBeStatic - fix false negative with unnecessary parenthesis - @dalizi007
- #3994: [java] TooManyMethods - improve getter/setter detection (#3729) - @341816041
- #4017: Add Gherkin support to CPD - @ASBrouwers
- #4021: [core] CPD: Add total number of tokens to XML reports - @maikelsteneker