30 June 2019
The PMD team is pleased to announce PMD 6.16.0.
This is a minor release.
This PMD release ships a new version of the pmd-designer. For the changes, see PMD Designer Changelog.
The grammar has been updated to support inline constraints in CREATE TABLE statements. Additionally, the CREATE TABLE statement may now be followed by physical properties and table properties. However, these properties are skipped over during parsing.
The CREATE VIEW statement now supports subquery views.
The EXTRACT function can now be parsed correctly. It is used to extract values from a specified datetime field. Also date time literals are parsed now correctly.
The CASE expression can now be properly used within SELECT statements.
Table aliases are now supported when specifying columns in INSERT INTO clauses.
The Java rule DoubleBraceInitialization
(java-bestpractices
)
detects non static initializers in anonymous classes also known as “double brace initialization”.
This can be problematic, since a new class file is generated and object holds a strong reference
to the surrounding class.
Note: This rule is also part of the Java quickstart ruleset (rulesets/java/quickstart.xml
).
The Java rule UnusedPrivateField
(java-bestpractices
) now ignores by
default fields, that are annotated with the Lombok experimental annotation @Delegate
. This can be
customized with the property ignoredAnnotations
.
The Java rule SingularField
(java-design
) now ignores by
default fields, that are annotated with the Lombok experimental annotation @Delegate
. This can be
customized with the property ignoredAnnotations
.
The Java rules UnsynchronizedStaticFormatter
and
UnsynchronizedStaticDateFormatter
(java-multithreading
)
now prefer synchronized blocks by default. They will raise a violation, if the synchronization is implemented
on the method level. To allow the old behavior, the new property allowMethodLevelSynchronization
can
be enabled.
The Java rule UseUtilityClass
(java-design
) has a new property ignoredAnnotations
.
By default, classes that are annotated with Lombok’s @UtilityClass
are ignored now.
The Java rule NonStaticInitializer
(java-errorprone
) does not report
non static initializers in anonymous classes anymore. For this use case, there is a new rule now:
DoubleBraceInitialization
(java-bestpractices
).
The Java rule CommentDefaultAccessModifier
(java-errorprone
) now by default searches
for any unclosed java.lang.AutoCloseable
resource. This includes now the standard java.io.*Stream
classes.
Previously only SQL-related resources were considered by this rule. The types can still be configured
via the types
property. Some resources do not need to be closed (e.g. ByteArrayOutputStream
). These
exceptions can be configured via the new property allowedResourceTypes
.
In order to restore the old behaviour, just remove the type java.lang.AutoCloseable
from the types
property and keep the remaining SQL-related classes.
AvoidFinalLocalVariable
(java-codestyle
) has been deprecated
and will be removed with PMD 7.0.0. The rule is controversial and also contradicts other existing
rules such as LocalVariableCouldBeFinal
. If the goal is to avoid defining
constants in a scope smaller than the class, then the rule AvoidDuplicateLiterals
should be used instead.Reminder: Please don’t use members marked with the annotation
InternalApi
, as they will likely be removed, hidden, or otherwise intentionally broken with 7.0.0.
As part of the changes we’d like to do to AST classes for 7.0.0, we would like to hide some methods and constructors that rule writers should not have access to. The following usages are now deprecated in the Java AST (with other languages to come):
InternalApi
. Nodes should only be obtained from the parser, which for rules, means that never need to instantiate node themselves. Those constructors will be made package private with 7.0.0.Please look at net.sourceforge.pmd.lang.java.ast
to find out the full list
of deprecations.