28-May-2022 - 6.46.0
The PMD team is pleased to announce PMD 6.46.0.
This is a minor release.
New and noteworthy
CLI improvements
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.
C# Improvements
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.
New Rules
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
anddo
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.
Deprecated Rules
- The following Java rules are deprecated and removed from the quickstart ruleset, as the new rule
EmptyControlStatement
merges their functionality: - The Java rule
EmptyStatementNotInLoop
is deprecated and removed from the quickstart ruleset. Use the new ruleUnnecessarySemicolon
instead.
Fixed Issues
- cli
- #1445: [core] Allow CLI to take globs as parameters
- core
- cs (c#)
- #3974: [cs] Add option to ignore C# attributes (annotations)
- go
- #2752: [go] Error parsing unicode values
- html
- java
- #3423: [java] Error processing identifiers with Unicode
- java-bestpractices
- #3954: [java] NPE in UseCollectionIsEmptyRule when .size() is called in a record
- java-design
- #3874: [java] ImmutableField reports fields annotated with @Autowired (Spring) and @Mock (Mockito)
- java-errorprone
- #3096: [java] EmptyStatementNotInLoop FP in 6.30.0 with IfStatement
- java-performance
- javascript
- python
- #2604: [python] Support unicode identifiers
API Changes
Deprecated ruleset references
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>
, egjava-basic
, which resolves torulesets/java/basic.xml
- the internal release number, eg
600
, which resolves torulesets/releases/600.xml
Use the explicit forms of these references to be compatible with PMD 7.
Deprecated API
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
andsetInputPaths
are now deprecated. A new set of methods have been added, which use lists and do not rely on comma splitting.
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.
CPDCommandLineInterface
has been internalized. In order to execute CPD eitherCPD#run
orCPD#main
should be used.- Several members of
BaseCPDCLITest
have been deprecated with replacements. - The methods
Formatter#start
,Formatter#end
,Formatter#getRenderer
, andFormatter#isNoOutputSupplied
have been internalized.
External Contributions
- #3961: [java] Fix #3954 - NPE in UseCollectionIsEmptyRule with record - @flyhard
- #3964: [java] Fix #3874 - ImmutableField: fix mockito/spring false positives - @lukelukes
- #3974: [cs] Add option to ignore C# attributes (annotations) - @maikelsteneker
Stats
- 92 commits
- 30 closed tickets & PRs
- Days since last release: 28