??-June-2019 - 6.16.0
The PMD team is pleased to announce PMD 6.16.0.
This is a minor release.
New and noteworthy
PLSQL Grammar Updates
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.
New Rules
-
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
).
Modified Rules
-
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 propertyignoredAnnotations
. -
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 propertyignoredAnnotations
. -
The Java rules
UnsynchronizedStaticFormatter
andUnsynchronizedStaticDateFormatter
(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 propertyallowMethodLevelSynchronization
can be enabled. -
The Java rule
UseUtilityClass
(java-design
) has a new propertyignoredAnnotations
. 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
).
Fixed Issues
- apex
- #1664: [apex] False positive ApexSharingViolationsRule, unsupported Apex feature
- java
- #1848: [java] Local classes should preserve their modifiers
- java-bestpractices
- java-design
- #1094: [java] UseUtilityClass should be LombokAware
- java-errorprone
- #1853: [java] False positive for NonStaticInitializer in anonymous class
- java-multithreading
- plsql
API Changes
Deprecated APIs
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.
In ASTs
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):
- Manual instantiation of nodes. Constructors of node classes are deprecated and marked
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. - Subclassing of abstract node classes, or usage of their type. Version 7.0.0 will bring a new set of abstractions that will be public API, but the base classes are and will stay internal. You should not couple your code to them.
- Setters found in any node class or interface. Rules should consider the AST immutable. We will make those setters package private with 7.0.0.
Please look at net.sourceforge.pmd.lang.java.ast
to find out the full list
of deprecations.
External Contributions
- #1792: [java] Added lombok.experimental to AbstractLombokAwareRule - jakivey32
- #1808: [plsql] Fix PL/SQL Syntax errors - Hugo Araya Nash
- #1829: [java] Fix false negative in UnsynchronizedStaticFormatter - Srinivasan Venkatachalam
- #1847: [java] Regression in MethodReturnsInternalArray not handling enums - Artem
- #1863: [plsql] Add Table InlineConstraint - Hugo Araya Nash
- #1864: [plsql] Add support for Subquery Views - Hugo Araya Nash
- #1865: [plsql] Add Support for Extract Expression - Hugo Araya Nash
- #1874: [plsql] Add parenthesis equation support for Update - Hugo Araya Nash
- #1876: [plsql] Datetime support for queries - Hugo Araya Nash
- #1883: [plsql] Fix #1873 Expression list not working - Hugo Araya Nash
- #1884: [plsql] fix #1878 Support explicit INNER word for INNER JOIN - Hugo Araya Nash
- #1885: [plsql] Correct case expression - Hugo Araya Nash
- #1886: [plsql] Support table alias for Insert Clause - Hugo Araya Nash