31 August 2020
The PMD team is pleased to announce PMD 6.27.0.
This is a minor release.
This release of PMD brings support for Java 15. PMD can parse Text Blocks which have been promoted to be a standard language feature of Java.
PMD also supports Pattern Matching for instanceof, Records, and Sealed Classes.
Note: The Pattern Matching for instanceof, Records, and Sealed Classes are all preview language features of OpenJDK 15
and are not enabled by default. In order to
analyze a project with PMD that uses these language features, you’ll need to enable it via the environment
variable PMD_JAVA_OPTS
and select the new language version 15-preview
:
export PMD_JAVA_OPTS=--enable-preview
./run.sh pmd -language java -version 15-preview ...
Note: Support for Java 13 preview language features have been removed. The version “13-preview” is no longer available.
In the past, tab characters in source files has been handled differently in different languages by PMD. For instance in Java, tab characters had a width of 8 columns, while C# used only 1 column. Visualforce instead used 4 columns.
This has been unified now so that tab characters are consistently now always 1 column wide.
This however might be a incompatible change, if you’re using the properties “BeginColumn” or “EndColumn” additionally to “BeginLine” and “EndLine” of a Token/AST node in order to highlight where a rule violation occurred in the source file. If you have logic there that deals with tab characters, you most likely can remove this logic now, since tab characters are now just “normal” characters in terms of string processing.
See also [all] Ensure PMD/CPD uses tab width of 1 for tabs consistently #2656.
This PMD release ships a new version of the pmd-designer. For the changes, see PMD Designer Changelog.
AvoidReassigningCatchVariables
(java-bestpractices
) finds
cases where the variable of the caught exception is reassigned. This practice is surprising and prevents
further evolution of the code like multi-catch.The Java rule CloseResource
(java-errorprone
) has a new property
closeNotInFinally
. With this property set to true
the rule will also find calls to close a
resource, which are not in a finally-block of a try-statement. If a resource is not closed within a
finally block, it might not be closed at all in case of exceptions.
As this new detection would yield many new violations, it is disabled by default. It might be enabled in a later version of PMD.
DataflowAnomalyAnalysis
(java-errorprone
)
is deprecated in favour of UnusedAssignment
(java-bestpractices
),
which was introduced in PMD 6.26.0.language
attribute will be required on all rule
elements that declare a new rule. Some base rule classes set the language implicitly in their
constructor, and so this is not required in all cases for the rule to work. But this
behavior will be discontinued in PMD 7, so missing language
attributes are now
reported as a forward compatibility warning.Rule#getParserOptions
Parser#getParserOptions
AbstractParser
RuleContext#removeAttribute
RuleContext#getAttribute
RuleContext#setAttribute
ApexParserOptions
ASTThrowStatement#getFirstClassOrInterfaceTypeImage
EcmascriptParserOptions
EcmascriptXPathRule
XmlParserOptions
XmlXPathRule
Properties of AbstractXmlRule
net.sourceforge.pmd.Report.ReadableDuration
Many methods of net.sourceforge.pmd.Report
. They are replaced by accessors
that produce a List. For example, iterator()
(and implementing Iterable) and isEmpty()
are both
replaced by getViolations()
.
ASTJspDeclarations
ASTJspDocument
ScalaParserVisitorAdapter#zero
ScalaParserVisitorAdapter#combine
ApexParserVisitorReducedAdapter
TypeHelper
is deprecated in
favor of TypeTestUtil
, which has the
same functionality, but a slightly changed API.net.sourceforge.pmd.lang.java.symboltable
are deprecated as internal API.char foo = '\0';
- Mykhailo Palahuta