24 June 2017
The PMD team is pleased to announce PMD 5.8.0.
This is a minor release.
#### Java Type Resolution
As part of Google Summer of Code 2017, Bendegúz Nagy has been working on completing type resolution for Java. His progress so far has allowed to properly resolve, in addition to previously supported statements:
this
and super
, even when qualifiedthis.myObject.aField
), and properly handling inheritance / shadowingLambda parameter types where these are infered rather than explicit are still not supported. Expect future releases to do so.
As part of Google Summer of Code 2017, Clément Fournier has been working on a new metrics framework for object-oriented metrics.
The basic groundwork has been done already and with this release, including a first rule based on the metrics framework as a proof-of-concept: The rule CyclomaticComplexity, currently in the temporary ruleset java-metrics, uses the Cyclomatic Complexity metric to find overly complex code. This rule will eventually replace the existing three CyclomaticComplexity rules that are currently defined in the java-codesize ruleset (see also issue #445).
Since this work is still in progress, the metrics API (package net.sourceforge.pmd.lang.java.oom
)
is not finalized yet and is expected to change.
The Java rule UnnecessaryFinalModifier
(ruleset java-unnecessary) now also reports on private methods marked as final
.
Being private, such methods can’t be overriden, and therefore, the final keyword is redundant.
The Java rule PreserveStackTrace
(ruleset java-design) has been relaxed to support the builder pattern on thrown exception.
This change may introduce some false positives if using the exception in non-orthodox ways for things other than setting the
root cause of the exception. Contact us if you find any such scenarios.
The ruleset java-junit now properly detects JUnit5, and rules are being adapted to the changes on it’s API. This support is, however, still incomplete. Let us know of any uses we are still missing on the issue tracker
The Java rule EmptyTryBlock
(ruleset java-empty) now allows empty blocks when using try-with-resources.
The Java rule EmptyCatchBlock
(ruleset java-empty) now exposes a new property called allowExceptionNameRegex
.
This allow to setup a regular expression for names of exceptions you wish to ignore for this rule. For instance,
setting it to ^(ignored|expected)$
would ignore all empty catch blocks where the catched exception is named
either ignored
or expected
. The default ignores no exceptions, being backwards compatible.
CyclomaticComplexity
, StdCyclomaticComplexity
, ModifiedCyclomaticComplexity
(ruleset java-codesize) have been deprecated. They will be eventually replaced
by a new CyclomaticComplexity rule based on the metrics framework. See also issue #445.