28 May 2022
The PMD team is pleased to announce PMD 6.46.0.
This is a minor release.
The PMD CLI now allows repeating the --dir (-d) and --rulesets (-R) options,
as well as providing several space-separated arguments to either of them. For instance:
pmd -d src/main/java src/test/java -R rset1.xml -R rset2.xml
This also allows globs to be used on the CLI if your shell supports shell expansion. For instance, the above can be written
pmd -d src/*/java -R rset*.xml
Please use theses new forms instead of using comma-separated lists as argument to these options.
When executing CPD on C# sources, the option --ignore-annotations is now supported as well.
It ignores C# attributes when detecting duplicated code. This option can also be enabled via
the CPD GUI. See #3974 for details.
This release ships with 2 new Java rules.
EmptyControlStatement reports many instances of empty things, e.g. control statements whose
body is empty, as well as empty initializers.
EmptyControlStatement also works for empty for and do loops, while there were previously
no corresponding rules.
This new rule replaces the rules EmptyFinallyBlock, EmptyIfStmt, EmptyInitializer, EmptyStatementBlock, EmptySwitchStatements, EmptySynchronizedBlock, EmptyTryBlock, and EmptyWhileStmt.
<rule ref="category/java/codestyle.xml/EmptyControlStatement"/>
The rule is part of the quickstart.xml ruleset.
UnnecessarySemicolon reports semicolons that are unnecessary (so called “empty statements”
and “empty declarations”).
This new rule replaces the rule EmptyStatementNotInLoop.
<rule ref="category/java/codestyle.xml/UnnecessarySemicolon"/>
The rule is part of the quickstart.xml ruleset.
EmptyControlStatement merges their functionality:
EmptyStatementNotInLoop is deprecated and removed from the quickstart
ruleset. Use the new rule UnnecessarySemicolon instead.Ruleset references with the following formats are now deprecated and will produce a warning when used on the CLI or in a ruleset XML file:
<lang-name>-<ruleset-name>, eg java-basic, which resolves to rulesets/java/basic.xml600, which resolves to rulesets/releases/600.xmlUse the explicit forms of these references to be compatible with PMD 7.
toString is now deprecated. The format of this
method will remain the same until PMD 7. The deprecation is intended to steer users
away from relying on this format, as it may be changed in PMD 7.getInputPaths and
setInputPaths are now deprecated.
A new set of methods have been added, which use lists and do not rely on comma splitting.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.
CPDCommandLineInterface has been internalized. In order to execute CPD either
CPD#run or CPD#main
should be used.BaseCPDCLITest have been deprecated with replacements.Formatter#start,
Formatter#end, Formatter#getRenderer,
and Formatter#isNoOutputSupplied have been internalized.