28 June 2024
The PMD team is pleased to announce PMD 7.3.0.
This is a minor release.
UseEnumCollections
reports usages for HashSet
and HashMap
when the keys are of an enum type. The specialized enum collections are more space- and time-efficient.The already deprecated PMD 6 compatibility module (pmd-compat6) has been removed. It was intended to be used with older versions of the maven-pmd-plugin, but since maven-pmd-plugin 3.22.0, PMD 7 is supported directly and this module is not needed anymore.
If you currently use this dependency (net.sourceforge.pmd:pmd-compat6
), remove it and upgrade maven-pmd-plugin
to the latest version (3.23.0 or newer).
See also Maven PMD Plugin.
There are some important changes:
pmd-cpd
contains the new attributes pmdVersion
, timestamp
and version
. The latter is
the schema version and is currently “1.0.0”.<error>
elements.See Report formats for CPD for an example.
The XML format should be compatible as only attributes and elements have been added. However, if you parse
the document with a namespace aware parser, you might encounter some issues like no elements being found.
In case the new format doesn’t work for you (e.g. namespaces, unexpected error elements), you can
go back using the old format with the renderer “xmlold” (XMLOldRenderer
). Note, that
this old renderer is deprecated and only there for compatibility reasons. Whatever tooling is used to
read the XML format should be updated.
New exit code 5 introduced. PMD and CPD will exit now by default with exit code 5, if any recoverable error (e.g. parsing exception, lexing exception or rule exception) occurred. PMD will still create a report with all detected violations or duplications if recoverable errors occurred. Such errors mean, that the report might be incomplete, as either violations or duplications for an entire file or for a specific rule are missing. These cases can be considered as false-negatives.
In any case, the root cause should be investigated. If it’s a problem in PMD itself, please create a bug report.
New CLI parameter --no-fail-on-error
to ignore such errors and not exit with code 5. By default,
a build with errors will now fail and with that parameter, the previous behavior can be restored.
This parameter is available for both PMD and CPD.
The CLI parameter --skip-lexical-errors
is deprecated. By default, lexical errors are skipped but the
build is failed. Use the new parameter --[no-]fail-on-error
instead to control whether to fail the build or not.
failOnError
. It controls, whether to fail the build if any recoverable error occurred.
By default, the build will fail. CPD will still create a report with all detected duplications, but the report might
be incomplete.skipLexicalError
in CPDTask is deprecated and ignored. Lexical errors are now always skipped.
Use the new parameter failOnError
instead to control whether to fail the build or not.CPDTask#setSkipLexicalErrors
: Use setFailOnError
instead to control, whether to ignore errors or fail the build.CPDConfiguration#isSkipLexicalErrors
and setSkipLexicalErrors
:
Use setFailOnError
to control whether to ignore errors or fail the build.net.sourceforge.pmd.cpd.XMLOldRenderer
(the CPD format “xmlold”).AntlrToken#AntlrToken
shouldn’t be used directly. Use AntlrTokenManager
instead.ASTResource#getStableName
and the corresponding attribute @StableName
.ASTRecordPattern#getVarId
This method was added here by mistake. Record
patterns don’t declare a pattern variable for the whole pattern, but rather for individual record
components, which can be accessed via getComponentPatterns
.PLSQLParserImpl
is deprecated now. It should have been package-private
because this is an implementation class that should not be used directly.ASTKEYWORD_UNRESERVED
is deprecated and is now removed from the AST.The already deprecated PMD 6 compatibility module (pmd-compat6) has been removed. See above for details.