26 March 2018
The PMD team is pleased to announce PMD 6.2.0.
This is a minor release.
The Rhino Library has been upgraded from version 1.7.7 to version 1.7.7.2.
Detailed changes for changed in Rhino can be found:
Both are bugfixing releases.
Some time ago, we added support for Incremental Analysis. On PMD 6.0.0, we started to add warns when not using it, as we strongly believe it’s a great improvement to our user’s experience as analysis time is greatly reduced; and in the future we plan to have it enabled by default. However, we realize some scenarios don’t benefit from it (ie: CI jobs), and having the warning logged can be noisy and cause confusion.
To this end, we have added a new flag to allow you to explicitly disable incremental analysis. On CLI, this is
the new -no-cache
flag. On Ant, there is a noCache
attribute for the <pmd>
task.
On both scenarios, disabling the cache takes precedence over setting a cache location.
The new Java rule MissingOverride
(category bestpractices
) detects overridden and implemented methods, which are not marked with the
@Override
annotation. Annotating overridden methods with @Override
ensures at compile time that
the method really overrides one, which helps refactoring and clarifies intent.
The new Java rule UnnecessaryAnnotationValueElement
(category codestyle
) detects annotations with a single element (value
) that explicitely names it.
That is, doing @SuppressWarnings(value = "unchecked")
would be flagged in favor of
@SuppressWarnings("unchecked")
.
The new Java rule ControlStatementBraces
(category codestyle
) enforces the presence of braces on control statements where they are optional.
Properties allow to customize which statements are required to have braces. This rule replaces the now
deprecated rules WhileLoopMustUseBraces
, ForLoopMustUseBraces
, IfStmtMustUseBraces
, and
IfElseStmtMustUseBraces
. More than covering the use cases of those rules, this rule also supports
do ... while
statements and case
labels of switch
statements (disabled by default).
The Java rule CommentContentRule
(java-documentation
) previously had the property wordsAreRegex
. But this
property never had been implemented and is removed now.
The Java rule UnusedPrivateField
(java-bestpractices
) now has a new ignoredAnnotations
property
that allows to configure annotations that imply the field should be ignored. By default @java.lang.Deprecated
and @javafx.fxml.FXML
are ignored.
The Java rule UnusedPrivateMethod
(java-bestpractices
) now has a new ignoredAnnotations
property
that allows to configure annotations that imply the method should be ignored. By default @java.lang.Deprecated
is ignored.
The Java rule ImmutableField
(java-design
) now has a new ignoredAnnotations
property
that allows to configure annotations that imply the method should be ignored. By default several lombok
annotations are ignored
The Java rule SingularField
(java-design
) now has a new ignoredAnnotations
property
that allows to configure annotations that imply the method should be ignored. By default several lombok
annotations are ignored
WhileLoopMustUseBraces
, ForLoopMustUseBraces
, IfStmtMustUseBraces
, and IfElseStmtMustUseBraces
are deprecated. They will be replaced by the new rule ControlStatementBraces
, in the category codestyle
.A new CLI switch, -no-cache
, disables incremental analysis and the related suggestion. This overrides the
-cache
option. The corresponding Ant task parameter is noCache
.
The static method PMDParameters.transformParametersIntoConfiguration(PMDParameters)
is now deprecated,
for removal in 7.0.0. The new instance method PMDParameters.toConfiguration()
replaces it.
The method ASTConstructorDeclaration.getParameters()
has been deprecated in favor of the new method
getFormalParameters()
. This method is available for both ASTConstructorDeclaration
and
ASTMethodDeclaration
.