PMD v6.23.0 Release Notes
Release Date: 2020-04-24 // almost 4 years ago-
24-April-2020 - 6.23.0
The PMD team is pleased to announce PMD 6.23.0.
๐ This is a minor release.
Table Of Contents
๐ New and noteworthy
PMD adopts Contributor Code of Conduct
To facilitate healthy and constructive community behavior PMD adopts
Contributor Convenant as its code of
conduct.๐ Please note that this project is released with a Contributor Code of Conduct.
By participating in this project you agree to abide by its terms.You can find the code of conduct in the file code_of_conduct.md
in our repository.๐ Performance improvements for XPath 2.0 rules
๐ XPath rules written with XPath 2.0 now support conversion to a rulechain rule, which
๐ improves their performance. The rulechain is a mechanism that allows several rules
to be executed in a single tree traversal. Conversion to the rulechain is possible if
your XPath expression looks like//someNode/... | //someOtherNode/... | ...
, that
is, a union of one or more path expressions that start with//
. Instead of traversing
the whole tree once per path expression (and per rule), a single traversal executes all
rules in your ruleset as needed.This conversion is performed automatically and cannot be disabled. The conversion should
not change the result of your rules , if it does, please report a bug at https://github.com/pmd/pmd/issues๐ Note that XPath 1.0 support, the default XPath version, is deprecated since PMD 6.22.0.
โฌ๏ธ We highly recommend that you upgrade your rules to XPath 2.0. Please refer to the migration guide.Javascript improvements for ES6
๐ PMD uses the Rhino library to parse Javascript.
0๏ธโฃ The default version has been set toES6
, so that some ECMAScript 2015 features are
๐ supported. E.g.let
statements andfor-of
loops are now parsed. However Rhino does
๐ not support all features.๐ New JSON renderer
๐ PMD now supports a JSON renderer (use it with
-f json
on the CLI).
๐ See the documentation and example๐ New Rules
The new Apex rule
FieldDeclarationsShouldBeAtStart
(apex-codestyle
)
helps to ensure that field declarations are always at the beginning of a class.The new Apex rule
UnusedLocalVariable
(apex-bestpractices
) detects unused
local variables.๐ Fixed Issues
- apex-design
- #2358: [apex] Invalid Apex in Cognitive Complexity tests
- ๐ apex-security
- core
- doc
- java
- #2378: [java] AbstractJUnitRule has bad performance on large code bases
- java-bestpractices
- #2398: [java] AbstractClassWithoutAbstractMethod false negative with inner abstract classes
- ๐ java-codestyle
- java-design
- #2390: [java] AbstractClassWithoutAnyMethod: missing violation for nested classes
- java-errorprone
- #2402: [java] CloseResource possible false positive with Primitive Streams
- java-multithreading
- #2313: [java] Documenation for DoNotUseThreads is outdated
- javascript
- javascript-errorprone
- #384: [javascript] Trailing commas not detected on French default locale
API Changes
๐ Deprecated APIs
Internal API
๐ Those APIs are not intended to be used by clients, and will be hidden or removed with PMD 7.0.0.
๐ You can identify them with the@InternalApi
annotation. You'll also get a deprecation warning.- ๐
AbstractXPathRuleQuery
- ๐
JaxenXPathRuleQuery
- ๐
SaxonXPathRuleQuery
- ๐
XPathRuleQuery
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 Apex , Javascript , PL/SQL , Scala and Visualforce ASTs:- ๐ Manual instantiation of nodes. Constructors of node classes are deprecated and
๐ markedInternalApi
. Nodes should only be obtained from the parser,
which for rules, means that they 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. The base classes are internal API
and will be hidden in version 7.0.0. 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. - ๐ The implementation classes of
Parser
(egVfParser
) are deprecated and should not be used directly.
๐ UseLanguageVersionHandler#getParser
instead. - ๐ The implementation classes of
TokenManager
(egVfTokenManager
) are deprecated and should not be used outside of our implementation.
This also affects CPD-only modules.
๐ These deprecations are added to the following language modules in this release.
๐ Please look at the package documentation to find out the full list of deprecations.- ๐ฆ Apex:
net.sourceforge.pmd.lang.apex.ast
- ๐ฆ Javascript:
net.sourceforge.pmd.lang.ecmascript.ast
- ๐ฆ PL/SQL:
net.sourceforge.pmd.lang.plsql.ast
- ๐ฆ Scala:
net.sourceforge.pmd.lang.scala.ast
- ๐ฆ Visualforce:
net.sourceforge.pmd.lang.vf.ast
๐ These deprecations have already been rolled out in a previous version for the
following languages:- ๐ฆ Java:
net.sourceforge.pmd.lang.java.ast
- ๐ฆ Java Server Pages:
net.sourceforge.pmd.lang.jsp.ast
- ๐ฆ Velocity Template Language:
net.sourceforge.pmd.lang.vm.ast
๐ฆ Outside of these packages, these changes also concern the following TokenManager
๐ฆ implementations, and their corresponding Parser if it exists (in the same package):- ๐
CppTokenManager
- ๐
JavaTokenManager
- ๐
Ecmascript5TokenManager
- ๐
JspTokenManager
- ๐
MatlabTokenManager
- ๐
ModelicaTokenManager
- ๐
ObjectiveCTokenManager
- ๐
PLSQLTokenManager
- ๐
PythonTokenManager
- ๐
VfTokenManager
- ๐
VmTokenManager
In the Java AST the following attributes are deprecated and will issue a warning when used in XPath rules:
- ๐
ASTAdditiveExpression#getImage
- usegetOperator()
instead - ๐
ASTVariableDeclaratorId#getImage
- usegetName()
instead - ๐
ASTVariableDeclaratorId#getVariableName
- usegetName()
instead
For removal
- ๐
Parser#getTokenManager
- ๐
TokenManager#setFileName
- ๐
AbstractTokenManager#setFileName
- ๐
AbstractTokenManager#getFileName
- ๐
AntlrToken#getType
- usegetKind()
instead. - ๐
ImmutableLanguage
- ๐คก
MockRule
- ๐
Node#getFirstParentOfAnyType
- ๐
Node#getAsDocument
- ๐
AbstractNode#hasDescendantOfAnyType
- ๐
ASTRecordDeclaration#getComponentList
- ๐ Multiple fields, constructors and methods in
XPathRule
. See javadoc for details.
External Contributions
- โก๏ธ #2312: [apex] Update ApexCRUDViolation Rule - Joshua S Arquilevich
- ๐ #2314: [doc] maven integration - Add version to plugin - Pham Hai Trung
- #2353: [plsql] xmlforest with optional AS - Piotr Szymanski
- ๐ #2383: [apex] Fix invalid apex in documentation - Gwilym Kuiper
- #2395: [apex] New Rule: Unused local variables - Gwilym Kuiper
- #2396: [apex] New rule: field declarations should be at start - Gwilym Kuiper
- ๐ #2397: [apex] fixed WITH SECURITY_ENFORCED regex to recognise line break characters - Kieran Black
- ๐ #2401: [doc] Update DoNotUseThreads rule documentation - Saikat Sengupta
- #2403: [java] #2402 fix false-positives on Primitive Streams - Bernd Farka
- ๐ #2409: [java] ClassNamingConventions suggests to add Util for class containing only static constants, fixes #1164 - Binu R J
- #2411: [java] Fix UseAssertEqualsInsteadOfAssertTrue Example - Moritz Scheve
- ๐ #2423: [core] Fix Checkstyle OperatorWrap in AbstractTokenizer - Harsh Kukreja
- ๐ป #2432: [core] Close ZIP data sources even if a runtime exception or error is thrown - Gonzalo Exequiel Ibars Ingman
Stats
- 237 commits
- 64 closed tickets & PRs
- ๐ Days since last release: 42
- apex-design