22-March-2024 - 7.0.0
🎉 After a long time, we're excited to bring you now the next major version of PMD! 🎉
Since this is a big release, we provide here only a concise version of the release notes. We prepared a separate
page with the full Detailed Release Notes for PMD 7.0.0.
🤝🙏 Many thanks to all users and contributors who were testing the release candidates and
provided feedback and/or PRs!
✨ PMD 7...
- ...has a new logo
- ...analyzes Java 21 and Java 22 projects with even better type resolution and symbol table support
- ...analyzes Kotlin and Swift
- ...analyzes Apex with a new parser
- ...finds duplicated code in Coco, Julia, TypeScript
- ...ships 11 new rules and tons of improvements for existing rules
- ...provides a new CLI interface with progress bar
- ...supports Antlr based languages
- ...and many more enhancements
💥 Note: Since PMD 7 is a major release, it is not a drop-in replacement for PMD 6.55.0. This section lists the most important changes from the last release candidate. In order to use PMD 7 with maven-pmd-plugin a new It is important to add this dependency as the first in the list, so that maven-pmd-plugin sees the (old) This module is available beginning with version 7.0.0-rc4 and will be there at least for the first Note: This compatibility module only works for the built-in rules, that are still available in PMD 7. E.g. you need As PMD 7 revamped the Java module, if you have custom rules, you need to migrate these rules. Note: Once the default version of PMD is upgraded to PMD7 in maven-pmd-plugin No guarantee is given, that the (deprecated) module pmd-compat6 is being maintained over the This release of PMD brings support for Java 22. There are the following new standard language features, PMD also supports the following preview language features:
In order to analyze a project with PMD that uses these language features, Note: Support for Java 20 preview language features have been removed. The version "20-preview" is no longer available.
This PMD release ships a new version of the pmd-designer. The designer artifact has been For the detailed changes, see PMD Designer Changelog (7.0.0).
When PMD added Apex support with version 5.5.0, it utilized the Apex Jorje library to parse Apex source This causes problems, if binary blobs are not allowed by e.g. a company-wide policy. In that case, the Jorje Also having access to the source code, enhancements and modifications are easier to do.
Under the hood, we use two open source libraries instead:
Although the parser is completely switched, there are only little known changes to the AST. With the new Apex parser, the new language constructs like See #3766 for details.
Contributors: Aaron Hurst (@aaronhurst-google), There was an inconsistency between the naming of the maven module and the language id. The language id If you import rules, you also need to adjust the paths, e.g.
Support for HTML was introduced in PMD 6.55.0 as an experimental feature. With PMD 7.0.0 this Support for Kotlin was introduced with PMD 7.0.0-rc1 as an experimental feature. With PMD 7.0.0 this The module was named just "vm" which was not a good name. Its module name, language id and If you import rules, you also need to adjust the paths, e.g.
New Rules
Changed Rules
Renamed Rulesets
Removed Rules
The following previously deprecated rules have been finally removed:
Removed deprecated rulesets
The following previously deprecated rulesets have been removed. These were the left-over rulesets from PMD 5. See Detailed Release Notes for PMD 7.
The new official logo of PMD:
For more information, see the Detailed Release Notes for PMD 7.
For more information, see the Detailed Release Notes for PMD 7.
Contributors: Clément Fournier (@oowekyala), For more information, see the Detailed Release Notes for PMD 7.
Contributors: Juan Martín Sotuyo Dodero (@jsotuyod)
For more information, see the Detailed Release Notes for PMD 7.
Contributors: Lucas Soncini (@lsoncini), This PMD release ships a new version of the pmd-designer. The designer artifact has been For the detailed changes, see
Thanks to @mohan-chinnappan-n a new CPD report format has been added which features a data table. See the example report.
Contributors: Mohan Chinnappan (@mohan-chinnappan-n)
Note that this is just a concise listing of the highlights. PMD supported Apache Velocity for a very long time, but the CPD integration never got finished. Thanks to a contribution, CPD now supports Coco, a modern programming language Contributors: Wener (@wener-tiobe)
Thanks to a contribution, CPD now supports the Julia language. It is shipped Contributors: Wener (@wener-tiobe)
Thanks to a contribution, CPD now supports the TypeScript language. It is shipped Contributors: Paul Guyot (@pguyot)
This release of PMD brings support for Java 21 and 22. There are the following new standard language features, PMD also supports the following preview language features:
In order to analyze a project with PMD that uses these preview language features, Note: Support for Java 19 and Java 20 preview language features have been removed. The versions "19-preview" and Contributors: Jeroen Borgers (@jborgers), Contributors: Lucas Soncini (@lsoncini), When PMD added Apex support with version 5.5.0, it utilized the Apex Jorje library to parse Apex source This causes problems, if binary blobs are not allowed by e.g. a company-wide policy. In that case, the Jorje Also having access to the source code, enhancements and modifications are easier to do.
Under the hood, we use two open source libraries instead:
Although the parsers is completely switched, there are only little known changes to the AST. See #3766 for details.
Contributors: Aaron Hurst (@aaronhurst-google), Contributors: Wener (@wener-tiobe)
Contributors: Juan Martín Sotuyo Dodero (@jsotuyod)
Support for HTML was introduced in PMD 6.55.0 as an experimental feature. With PMD 7.0.0 this The module was named just "vm" which was not a good name. Its module name, language id and If you import rules, you also need to adjust the paths, e.g.
There was an inconsistency between the naming of the maven module and the language id. The language id If you import rules, you also need to adjust the paths, e.g.
Apex
Java
Kotlin
Swift
XML
The information about changed rules, removed rules and rulesets The API of PMD has been growing over the years and needed some cleanup. The goal is, to Also, there are some improvement and changes in different areas. For the detailed description A detailed documentation of required changes are available in the See also Detailed Release Notes for PMD 7.
More than 300 issues have been fixed in PMD 7. Many thanks to the following contributors: See Detailed Release Notes for PMD 7 for the
A detailed documentation of required changes are available in the Migration Guide for PMD 7.
Expand to see Release Notes
Table Of Contents
Changes since 7.0.0-rc4
The remaining section describes the complete release notes for 7.0.0.
New and Noteworthy
Maven PMD Plugin compatibility with PMD 7
compatibility module has been created. This allows to use PMD 7 by simply adding one additional dependency:
<dependency>
<groupId>net.sourceforge.pmd</groupId>
<artifactId>pmd-compat6</artifactId>
<version>${pmdVersion}</version>
</dependency>
compatible versions of some classes.
final version PMD 7 (7.0.0). It's not decided yet, whether we will keep updating it, after PMD 7 is finally
released.
to review your rulesets and look out for deprecated rules and such. See the use case
I'm using only built-in rules
in the Migration Guide for PMD 7.
See the use case I'm using custom rules
in the Migration Guide.
(see MPMD-379), this
compatibility module is no longer needed. The module pmd-compat6 might not be maintained then
any further, hence it is already declared as deprecated.
whole lifetime of PMD 7.
Java 22 Support
that are supported now:
you'll need to enable it via the environment variable PMD_JAVA_OPTS
and select the new language
version 22-preview
:
export PMD_JAVA_OPTS=--enable-preview
pmd check --use-version java-22-preview ...
Swift Support
Groovy Support (CPD)
CPD-ON
/CPD-OFF
comment pairs.
Updated PMD Designer
renamed from "pmd-ui" to "pmd-designer". While the designer still works with Java 8, the
recommended Java Runtime is Java 11 (or later) with OpenJFX 17 (or later).
Apex Support: Replaced Jorje with fully open source front-end
and generate an AST. This library is however a binary-blob provided as part of the
Salesforce Extensions for VS Code, and it is closed-source.
library prevented that PMD Apex could be used at all.
Kevin Jones (@nawforce).
This project provides the grammar for a ANTLR based parser.
This project translates the ANTLR parse tree into an AST, that is similar to the AST Jorje provided.
Note: This is not an official Google product.
These are documented in the Migration Guide for PMD 7: Apex AST.
User Mode Database Operations
and the new Null Coalescing Operator ??
can be parsed now. PMD should be able to parse Apex code up to version 60.0 (Spring '24).
Edward Klimoshenko (@eklimo)
Changed: Visualforce
used the abbreviation "vf", while the maven module used the longer name "visualforce". This has been
solved by renaming the language module to its full name "visualforce". The java packages have
been renamed as well.
category/vf/security.xml
➡️ category/visualforce/security.xml
Changed: HTML support
is now considered stable.
Changed: Kotlin support
is now considered stable.
Changed: Velocity Template Language (VTL)
package names have been renamed to "velocity".
category/vm/...
➡️ category/velocity/...
Rule Changes
OperationWithHighCostInLoop
finds Schema class methods called in a loop, which is a
potential performance issue.
UseExplicitTypes
reports usages of var
keyword, which was introduced with Java 10.
MissingEncoding
finds XML files without explicit encoding.
EmptyControlStatement
: The rule has a new property to allow empty blocks when
they contain a comment (allowCommentedBlocks
).
MethodNamingConventions
: The deprecated rule property skipTestMethodUnderscores
has
been removed. It was actually deprecated since PMD 6.15.0, but was not mentioned in the release notes
back then. Use the property testPattern
instead to configure valid names for test methods.
CommentRequired
: The deprecated property headerCommentRequirement
has been removed.
Use the property classCommentRequirement
instead.
NonSerializableClass
: The deprecated property prefix
has been removed
without replacement. In a serializable class all fields have to be serializable regardless of the name.
category/vf/security.xml
➡️ category/visualforce/security.xml
category/vm/bestpractices.xml
➡️ category/velocity/bestpractices.xml
category/vm/design.xml
➡️ category/velocity/design.xml
category/vm/errorprone.xml
➡️ category/velocity/errorprone.xml
OperationWithLimitsInLoop
OperationWithLimitsInLoop
OperationWithLimitsInLoop
NcssCount
NcssCount
NonSerializableClass
EmptyControlStatement
EmptyControlStatement
EmptyControlStatement
EmptyControlStatement
UnnecessarySemicolon
EmptyControlStatement
EmptyControlStatement
EmptyControlStatement
EmptyControlStatement
The rules have been moved into categories with PMD 6.
List of deprecated rulesets
Fixed issues
n.s.pmd.reporting
package
n.s.pmd.lang.rule
package
color
and system property pmd.color
in TextColorRenderer
--no-ruleset-compatibility
--ignore-literals
and --ignore-identifiers
work
API Changes
External Contributions
🚀 Major Features and Enhancements
New official logo
Revamped Java module
Andreas Dangel (@adangel),
Juan Martín Sotuyo Dodero (@jsotuyod)
Revamped Command Line Interface
pmd
(pmd.bat
for Windows) to launch the different utilities:
pmd check
to run PMD rules and analyze a project
pmd cpd
to run CPD (copy paste detector)
pmd designer
to run the PMD Rule Designer
pmd check
Full Antlr support
Matías Fraga (@matifraga),
Tomás De Lucca (@tomidelucca)
Updated PMD Designer
renamed from "pmd-ui" to "pmd-designer". While the designer still works with Java 8, the
recommended Java Runtime is Java 11 (or later) with OpenJFX 17 (or later).
New CPD report format cpdhtml-v2.xslt
It uses an XSLT stylesheet to convert CPD's XML format into HTML.
🎉 Language Related Changes
For more information on the languages, see the Detailed Release Notes for PMD 7.
New: CPD support for Apache Velocity Template Language (VTL)
This is now done and CPD supports Apache Velocity Template language for detecting copy and paste.
It is shipped in the module pmd-velocity
.
New: CPD support for Coco
designed specifically for building event-driven software. It is shipped in the new
module pmd-coco
.
New: CPD support for Julia
in the new module pmd-julia
.
New: CPD support for TypeScript
with the rest of the JavaScript support in the module pmd-javascript
.
New: Java 21 and 22 Support
that are supported now:
you'll need to enable it via the environment variable PMD_JAVA_OPTS
and select the new language
version 22-preview
:
export PMD_JAVA_OPTS=--enable-preview
pmd check --use-version java-22-preview ...
"20-preview" are no longer available.
New: Kotlin support
is now considered stable.
Peter Paul Bakker (@stokpop)
New: Swift support
Matías Fraga (@matifraga),
Tomás De Lucca (@tomidelucca)
Changed: Apex Support: Replaced Jorje with fully open source front-end
and generate an AST. This library is however a binary-blob provided as part of the
Salesforce Extensions for VS Code, and it is closed-source.
library prevented that PMD Apex could be used at all.
This project provides the grammar for a ANTLR based parser.
This project translates the ANTLR parse tree into an AST, that is similar to the AST Jorje provided.
Note: This is not an official Google product.
These are documented in the Migration Guide for PMD 7: Apex AST.
With the new Apex parser, the new language constructs like
User Mode Database Operations
and the new Null Coalescing Operator ??
can be parsed now. PMD should be able to parse Apex code up to version 60.0 (Spring '24).
Edward Klimoshenko (@eklimo)
Changed: CPP can now ignore identifiers in sequences (CPD)
--ignore-sequences
.
--ignore-literal-sequences
, only
literals were ignored. The new option additionally ignores identifiers as well in sequences.
Changed: Groovy Support (CPD)
CPD-ON
/CPD-OFF
comment pairs.
Changed: HTML support
is now considered stable.
Changed: JavaScript support
Changed: Language versions
minimumLanguageVersion
and
maximumLanguageVersion
attributes.
Changed: Rule properties
IntProperty
and StringProperty
have been removed. Please use
PropertyFactory
to create properties.
,
) as a delimiter. The previous default was a
pipe character (|
). The delimiter is not configurable anymore. If needed, the comma can be escaped
with a backslash.
min
and max
attributes in property definitions in the XML are now optional and can appear separately
or be omitted.
Changed: Velocity Template Language (VTL)
package names have been renamed to "velocity".
category/vm/...
➡️ category/velocity/...
Changed: Visualforce
used the abbreviation "vf", while the maven module used the longer name "visualforce". This has been
solved by renaming the language module to its full name "visualforce". The java packages have
been renamed as well.
category/vf/security.xml
➡️ category/visualforce/security.xml
🌟 New and changed rules
New Rules
OperationWithHighCostInLoop
finds Schema class methods called in a loop, which is a
potential performance issue.
UnusedMethod
finds unused methods in your code.
UnnecessaryBoxing
reports boxing and unboxing conversions that may be made implicit.
UseExplicitTypes
reports usages of var
keyword, which was introduced with Java 10.
FunctionNameTooShort
finds functions with a too short name.
OverrideBothEqualsAndHashcode
finds classes with only
either equals
or hashCode
overridden, but not both. This leads to unexpected behavior once instances
of such classes are used in collections (Lists, HashMaps, ...).
ForceCast
flags all force casts, making sure you are
defensively considering all types. Having the application crash shouldn't be an option.
ForceTry
flags all force tries, making sure you are
defensively handling exceptions. Having the application crash shouldn't be an option.
ProhibitedInterfaceBuilder
flags any usage of interface
builder. Interface builder files are prone to merge conflicts, and are impossible to code review, so larger
teams usually try to avoid it or reduce its usage.
UnavailableFunction
flags any function throwing
a fatalError
not marked as @available(*, unavailable)
to ensure no calls are actually performed in
the codebase.
MissingEncoding
finds XML files without explicit encoding.
Other changes
can be found in the Detailed Release Notes for PMD 7.
🚨 API
have a clear separation between a well-defined API and the implementation, which is internal.
This should help us in future development.
of the changes listed here, see Detailed Release Notes for PMD 7.
💥 Compatibility and migration notes
Migration Guide for PMD 7.
🐛 Fixed Issues
See Detailed Release Notes for PMD 7 for the
complete list of fixed issues.
✨ External Contributions
@219sansim, @aaronhurst-google, @anastasiia-koba, @AndreyBozhko, @bergander, @ciufudean, @cyw3, @dague1,
@Debamoy, @eklimo, @ethauvin, @JerritEic, @joaodinissf, @kenji21, @krdabrowski, @lbovet, @lsoncini,
@LynnBroe, @marcindabrowski, @matifraga, @mohan-chinnappan-n, @mohui1999, @nawforce, @nirvikpatel,
@nwcm, @oleksandr-shvets, @pguyot, @PimvanderLoos, @rcorfieldffdc, @sfdcsteve, @shai-bennathan, @tomidelucca,
@tprouvot, @wener-tiobe.
full list of PRs.
📈 Stats