|
| 1 | +--- |
| 2 | +layout: post |
| 3 | +title: PMD 6.23.0 released |
| 4 | +--- |
| 5 | + |
| 6 | +## 24-April-2020 - 6.23.0 |
| 7 | + |
| 8 | +The PMD team is pleased to announce PMD 6.23.0. |
| 9 | + |
| 10 | +This is a minor release. |
| 11 | + |
| 12 | +### Table Of Contents |
| 13 | + |
| 14 | +* [New and noteworthy](#new-and-noteworthy) |
| 15 | + * [PMD adopts Contributor Code of Conduct](#pmd-adopts-contributor-code-of-conduct) |
| 16 | + * [Performance improvements for XPath 2.0 rules](#performance-improvements-for-xpath-2.0-rules) |
| 17 | + * [Javascript improvements for ES6](#javascript-improvements-for-es6) |
| 18 | + * [New JSON renderer](#new-json-renderer) |
| 19 | + * [New Rules](#new-rules) |
| 20 | +* [Fixed Issues](#fixed-issues) |
| 21 | +* [API Changes](#api-changes) |
| 22 | + * [Deprecated APIs](#deprecated-apis) |
| 23 | + * [Internal API](#internal-api) |
| 24 | + * [In ASTs](#in-asts) |
| 25 | + * [For removal](#for-removal) |
| 26 | +* [External Contributions](#external-contributions) |
| 27 | +* [Stats](#stats) |
| 28 | + |
| 29 | +### New and noteworthy |
| 30 | + |
| 31 | +#### PMD adopts Contributor Code of Conduct |
| 32 | + |
| 33 | +To facilitate healthy and constructive community behavior PMD adopts |
| 34 | +[Contributor Convenant](https://www.contributor-covenant.org/) as its code of |
| 35 | +conduct. |
| 36 | + |
| 37 | +Please note that this project is released with a Contributor Code of Conduct. |
| 38 | +By participating in this project you agree to abide by its terms. |
| 39 | + |
| 40 | +You can find the code of conduct in the file [code_of_conduct.md](https://github.com/pmd/pmd/blob/master/code_of_conduct.md) |
| 41 | +in our repository. |
| 42 | + |
| 43 | +#### Performance improvements for XPath 2.0 rules |
| 44 | + |
| 45 | +XPath rules written with XPath 2.0 now support conversion to a rulechain rule, which |
| 46 | +improves their performance. The rulechain is a mechanism that allows several rules |
| 47 | +to be executed in a single tree traversal. Conversion to the rulechain is possible if |
| 48 | +your XPath expression looks like `//someNode/... | //someOtherNode/... | ...`, that |
| 49 | +is, a union of one or more path expressions that start with `//`. Instead of traversing |
| 50 | +the whole tree once per path expression (and per rule), a single traversal executes all |
| 51 | +rules in your ruleset as needed. |
| 52 | + |
| 53 | +This conversion is performed automatically and cannot be disabled. *The conversion should |
| 54 | +not change the result of your rules*, if it does, please report a bug at https://github.com/pmd/pmd/issues |
| 55 | + |
| 56 | +Note that XPath 1.0 support, the default XPath version, is deprecated since PMD 6.22.0. |
| 57 | +**We highly recommend that you upgrade your rules to XPath 2.0**. Please refer to the [migration guide](https://pmd.github.io/latest/pmd_userdocs_extending_writing_xpath_rules.html#migrating-from-10-to-20). |
| 58 | + |
| 59 | +#### Javascript improvements for ES6 |
| 60 | + |
| 61 | +PMD uses the [Rhino](https://github.com/mozilla/rhino) library to parse Javascript. |
| 62 | +The default version has been set to `ES6`, so that some ECMAScript 2015 features are |
| 63 | +supported. E.g. `let` statements and `for-of` loops are now parsed. However Rhino does |
| 64 | +not support all features. |
| 65 | + |
| 66 | +#### New JSON renderer |
| 67 | + |
| 68 | +PMD now supports a JSON renderer (use it with `-f json` on the CLI). |
| 69 | +See [the documentation and example](https://pmd.github.io/latest/pmd_userdocs_report_formats.html#json) |
| 70 | + |
| 71 | +#### New Rules |
| 72 | + |
| 73 | +* The new Apex rule [`FieldDeclarationsShouldBeAtStart`](https://pmd.github.io/pmd-6.23.0/pmd_rules_apex_codestyle.html#fielddeclarationsshouldbeatstart) (`apex-codestyle`) |
| 74 | + helps to ensure that field declarations are always at the beginning of a class. |
| 75 | + |
| 76 | +* The new Apex rule [`UnusedLocalVariable`](https://pmd.github.io/pmd-6.23.0/pmd_rules_apex_bestpractices.html#unusedlocalvariable) (`apex-bestpractices`) detects unused |
| 77 | + local variables. |
| 78 | + |
| 79 | +### Fixed Issues |
| 80 | + |
| 81 | +* apex-design |
| 82 | + * [#2358](https://github.com/pmd/pmd/issues/2358): \[apex] Invalid Apex in Cognitive Complexity tests |
| 83 | +* apex-security |
| 84 | + * [#2210](https://github.com/pmd/pmd/issues/2210): \[apex] ApexCRUDViolation: Support WITH SECURITY_ENFORCED |
| 85 | + * [#2399](https://github.com/pmd/pmd/issues/2399): \[apex] ApexCRUDViolation: false positive with security enforced with line break |
| 86 | +* core |
| 87 | + * [#1286](https://github.com/pmd/pmd/issues/1286): \[core] Export Supporting JSON Format |
| 88 | + * [#2019](https://github.com/pmd/pmd/issues/2019): \[core] Insufficient deprecation warnings for XPath attributes |
| 89 | + * [#2357](https://github.com/pmd/pmd/issues/2357): Add code of conduct: Contributor Covenant |
| 90 | + * [#2426](https://github.com/pmd/pmd/issues/2426): \[core] CodeClimate renderer links are dead |
| 91 | + * [#2432](https://github.com/pmd/pmd/pull/2432): \[core] Close ZIP data sources even if a runtime exception or error is thrown |
| 92 | +* doc |
| 93 | + * [#2355](https://github.com/pmd/pmd/issues/2355): \[doc] Improve documentation about incremental analysis |
| 94 | + * [#2356](https://github.com/pmd/pmd/issues/2356): \[doc] Add missing doc about pmd.github.io |
| 95 | + * [#2412](https://github.com/pmd/pmd/issues/2412): \[core] HTMLRenderer doesn't render links to source files |
| 96 | + * [#2413](https://github.com/pmd/pmd/issues/2413): \[doc] Improve documentation about the available renderers (PMD/CPD) |
| 97 | +* java |
| 98 | + * [#2378](https://github.com/pmd/pmd/issues/2378): \[java] AbstractJUnitRule has bad performance on large code bases |
| 99 | +* java-bestpractices |
| 100 | + * [#2398](https://github.com/pmd/pmd/issues/2398): \[java] AbstractClassWithoutAbstractMethod false negative with inner abstract classes |
| 101 | +* java-codestyle |
| 102 | + * [#1164](https://github.com/pmd/pmd/issues/1164): \[java] ClassNamingConventions suggests to add Util for class containing only static constants |
| 103 | + * [#1723](https://github.com/pmd/pmd/issues/1723): \[java] UseDiamondOperator false-positive inside lambda |
| 104 | +* java-design |
| 105 | + * [#2390](https://github.com/pmd/pmd/issues/2390): \[java] AbstractClassWithoutAnyMethod: missing violation for nested classes |
| 106 | +* java-errorprone |
| 107 | + * [#2402](https://github.com/pmd/pmd/issues/2402): \[java] CloseResource possible false positive with Primitive Streams |
| 108 | +* java-multithreading |
| 109 | + * [#2313](https://github.com/pmd/pmd/issues/2313): \[java] Documenation for DoNotUseThreads is outdated |
| 110 | +* javascript |
| 111 | + * [#1235](https://github.com/pmd/pmd/issues/1235): \[javascript] Use of let results in an Empty Statement in the AST |
| 112 | + * [#2379](https://github.com/pmd/pmd/issues/2379): \[javascript] Support for-of loop |
| 113 | +* javascript-errorprone |
| 114 | + * [#384](https://github.com/pmd/pmd/issues/384): \[javascript] Trailing commas not detected on French default locale |
| 115 | + |
| 116 | +### API Changes |
| 117 | + |
| 118 | +#### Deprecated APIs |
| 119 | + |
| 120 | +##### Internal API |
| 121 | + |
| 122 | +Those APIs are not intended to be used by clients, and will be hidden or removed with PMD 7.0.0. |
| 123 | +You can identify them with the `@InternalApi` annotation. You'll also get a deprecation warning. |
| 124 | + |
| 125 | +* <a href="https://docs.pmd-code.org/apidocs/pmd-core/6.23.0/net/sourceforge/pmd/lang/rule/xpath/AbstractXPathRuleQuery.html#"><code>AbstractXPathRuleQuery</code></a> |
| 126 | +* <a href="https://docs.pmd-code.org/apidocs/pmd-core/6.23.0/net/sourceforge/pmd/lang/rule/xpath/JaxenXPathRuleQuery.html#"><code>JaxenXPathRuleQuery</code></a> |
| 127 | +* <a href="https://docs.pmd-code.org/apidocs/pmd-core/6.23.0/net/sourceforge/pmd/lang/rule/xpath/SaxonXPathRuleQuery.html#"><code>SaxonXPathRuleQuery</code></a> |
| 128 | +* <a href="https://docs.pmd-code.org/apidocs/pmd-core/6.23.0/net/sourceforge/pmd/lang/rule/xpath/XPathRuleQuery.html#"><code>XPathRuleQuery</code></a> |
| 129 | + |
| 130 | +##### In ASTs |
| 131 | + |
| 132 | +As part of the changes we'd like to do to AST classes for 7.0.0, we would like to |
| 133 | +hide some methods and constructors that rule writers should not have access to. |
| 134 | +The following usages are now deprecated in the **Apex**, **Javascript**, **PL/SQL**, **Scala** and **Visualforce** ASTs: |
| 135 | + |
| 136 | +* Manual instantiation of nodes. **Constructors of node classes are deprecated** and |
| 137 | + marked <a href="https://docs.pmd-code.org/apidocs/pmd-core/6.23.0/net/sourceforge/pmd/annotation/InternalApi.html#"><code>InternalApi</code></a>. Nodes should only be obtained from the parser, |
| 138 | + which for rules, means that they never need to instantiate node themselves. |
| 139 | + Those constructors will be made package private with 7.0.0. |
| 140 | +* **Subclassing of abstract node classes, or usage of their type**. The base classes are internal API |
| 141 | + and will be hidden in version 7.0.0. You should not couple your code to them. |
| 142 | + * In the meantime you should use interfaces like <a href="https://docs.pmd-code.org/apidocs/pmd-visualforce/6.23.0/net/sourceforge/pmd/lang/vf/ast/VfNode.html#"><code>VfNode</code></a> or |
| 143 | + <a href="https://docs.pmd-code.org/apidocs/pmd-core/6.23.0/net/sourceforge/pmd/lang/ast/Node.html#"><code>Node</code></a>, or the other published interfaces in this package, |
| 144 | + to refer to nodes generically. |
| 145 | + * Concrete node classes will **be made final** with 7.0.0. |
| 146 | +* Setters found in any node class or interface. **Rules should consider the AST immutable**. |
| 147 | + We will make those setters package private with 7.0.0. |
| 148 | +* The implementation classes of <a href="https://docs.pmd-code.org/apidocs/pmd-core/6.23.0/net/sourceforge/pmd/lang/Parser.html#"><code>Parser</code></a> (eg <a href="https://docs.pmd-code.org/apidocs/pmd-visualforce/6.23.0/net/sourceforge/pmd/lang/vf/VfParser.html#"><code>VfParser</code></a>) are deprecated and should not be used directly. |
| 149 | + Use <a href="https://docs.pmd-code.org/apidocs/pmd-core/6.23.0/net/sourceforge/pmd/lang/LanguageVersionHandler.html#getParser(ParserOptions)"><code>LanguageVersionHandler#getParser</code></a> instead. |
| 150 | +* The implementation classes of <a href="https://docs.pmd-code.org/apidocs/pmd-core/6.23.0/net/sourceforge/pmd/lang/TokenManager.html#"><code>TokenManager</code></a> (eg <a href="https://docs.pmd-code.org/apidocs/pmd-visualforce/6.23.0/net/sourceforge/pmd/lang/vf/VfTokenManager.html#"><code>VfTokenManager</code></a>) are deprecated and should not be used outside of our implementation. |
| 151 | + **This also affects CPD-only modules**. |
| 152 | + |
| 153 | +These deprecations are added to the following language modules in this release. |
| 154 | +Please look at the package documentation to find out the full list of deprecations. |
| 155 | +* Apex: **<a href="https://docs.pmd-code.org/apidocs/pmd-apex/6.23.0/net/sourceforge/pmd/lang/apex/ast/package-summary.html#"><code>net.sourceforge.pmd.lang.apex.ast</code></a>** |
| 156 | +* Javascript: **<a href="https://docs.pmd-code.org/apidocs/pmd-javascript/6.23.0/net/sourceforge/pmd/lang/ecmascript/ast/package-summary.html#"><code>net.sourceforge.pmd.lang.ecmascript.ast</code></a>** |
| 157 | +* PL/SQL: **<a href="https://docs.pmd-code.org/apidocs/pmd-plsql/6.23.0/net/sourceforge/pmd/lang/plsql/ast/package-summary.html#"><code>net.sourceforge.pmd.lang.plsql.ast</code></a>** |
| 158 | +* Scala: **<a href="https://docs.pmd-code.org/apidocs/pmd-scala/6.23.0/net/sourceforge/pmd/lang/scala/ast/package-summary.html#"><code>net.sourceforge.pmd.lang.scala.ast</code></a>** |
| 159 | +* Visualforce: **<a href="https://docs.pmd-code.org/apidocs/pmd-visualforce/6.23.0/net/sourceforge/pmd/lang/vf/ast/package-summary.html#"><code>net.sourceforge.pmd.lang.vf.ast</code></a>** |
| 160 | + |
| 161 | +These deprecations have already been rolled out in a previous version for the |
| 162 | +following languages: |
| 163 | +* Java: <a href="https://docs.pmd-code.org/apidocs/pmd-java/6.23.0/net/sourceforge/pmd/lang/java/ast/package-summary.html#"><code>net.sourceforge.pmd.lang.java.ast</code></a> |
| 164 | +* Java Server Pages: <a href="https://docs.pmd-code.org/apidocs/pmd-jsp/6.23.0/net/sourceforge/pmd/lang/jsp/ast/package-summary.html#"><code>net.sourceforge.pmd.lang.jsp.ast</code></a> |
| 165 | +* Velocity Template Language: <a href="https://docs.pmd-code.org/apidocs/pmd-vm/6.23.0/net/sourceforge/pmd/lang/vm/ast/package-summary.html#"><code>net.sourceforge.pmd.lang.vm.ast</code></a> |
| 166 | + |
| 167 | +Outside of these packages, these changes also concern the following TokenManager |
| 168 | +implementations, and their corresponding Parser if it exists (in the same package): |
| 169 | + |
| 170 | +* <a href="https://docs.pmd-code.org/apidocs/pmd-cpp/6.23.0/net/sourceforge/pmd/lang/cpp/CppTokenManager.html#"><code>CppTokenManager</code></a> |
| 171 | +* <a href="https://docs.pmd-code.org/apidocs/pmd-java/6.23.0/net/sourceforge/pmd/lang/java/JavaTokenManager.html#"><code>JavaTokenManager</code></a> |
| 172 | +* <a href="https://docs.pmd-code.org/apidocs/pmd-javascript/6.23.0/net/sourceforge/pmd/lang/ecmascript5/Ecmascript5TokenManager.html#"><code>Ecmascript5TokenManager</code></a> |
| 173 | +* <a href="https://docs.pmd-code.org/apidocs/pmd-jsp/6.23.0/net/sourceforge/pmd/lang/jsp/JspTokenManager.html#"><code>JspTokenManager</code></a> |
| 174 | +* <a href="https://docs.pmd-code.org/apidocs/pmd-matlab/6.23.0/net/sourceforge/pmd/lang/matlab/MatlabTokenManager.html#"><code>MatlabTokenManager</code></a> |
| 175 | +* <a href="https://docs.pmd-code.org/apidocs/pmd-modelica/6.23.0/net/sourceforge/pmd/lang/modelica/ModelicaTokenManager.html#"><code>ModelicaTokenManager</code></a> |
| 176 | +* <a href="https://docs.pmd-code.org/apidocs/pmd-objectivec/6.23.0/net/sourceforge/pmd/lang/objectivec/ObjectiveCTokenManager.html#"><code>ObjectiveCTokenManager</code></a> |
| 177 | +* <a href="https://docs.pmd-code.org/apidocs/pmd-plsql/6.23.0/net/sourceforge/pmd/lang/plsql/PLSQLTokenManager.html#"><code>PLSQLTokenManager</code></a> |
| 178 | +* <a href="https://docs.pmd-code.org/apidocs/pmd-python/6.23.0/net/sourceforge/pmd/lang/python/PythonTokenManager.html#"><code>PythonTokenManager</code></a> |
| 179 | +* <a href="https://docs.pmd-code.org/apidocs/pmd-visualforce/6.23.0/net/sourceforge/pmd/lang/vf/VfTokenManager.html#"><code>VfTokenManager</code></a> |
| 180 | +* <a href="https://docs.pmd-code.org/apidocs/pmd-vm/6.23.0/net/sourceforge/pmd/lang/vm/VmTokenManager.html#"><code>VmTokenManager</code></a> |
| 181 | + |
| 182 | + |
| 183 | +In the **Java AST** the following attributes are deprecated and will issue a warning when used in XPath rules: |
| 184 | + |
| 185 | +* <a href="https://docs.pmd-code.org/apidocs/pmd-java/6.23.0/net/sourceforge/pmd/lang/java/ast/ASTAdditiveExpression.html#getImage()"><code>ASTAdditiveExpression#getImage</code></a> - use `getOperator()` instead |
| 186 | +* <a href="https://docs.pmd-code.org/apidocs/pmd-java/6.23.0/net/sourceforge/pmd/lang/java/ast/ASTVariableDeclaratorId.html#getImage()"><code>ASTVariableDeclaratorId#getImage</code></a> - use `getName()` instead |
| 187 | +* <a href="https://docs.pmd-code.org/apidocs/pmd-java/6.23.0/net/sourceforge/pmd/lang/java/ast/ASTVariableDeclaratorId.html#getVariableName()"><code>ASTVariableDeclaratorId#getVariableName</code></a> - use `getName()` instead |
| 188 | + |
| 189 | +##### For removal |
| 190 | + |
| 191 | +* <a href="https://docs.pmd-code.org/apidocs/pmd-core/6.23.0/net/sourceforge/pmd/lang/Parser.html#getTokenManager(java.lang.String,java.io.Reader)"><code>Parser#getTokenManager</code></a> |
| 192 | +* <a href="https://docs.pmd-code.org/apidocs/pmd-core/6.23.0/net/sourceforge/pmd/lang/TokenManager.html#setFileName(java.lang.String)"><code>TokenManager#setFileName</code></a> |
| 193 | +* <a href="https://docs.pmd-code.org/apidocs/pmd-core/6.23.0/net/sourceforge/pmd/lang/ast/AbstractTokenManager.html#setFileName(java.lang.String)"><code>AbstractTokenManager#setFileName</code></a> |
| 194 | +* <a href="https://docs.pmd-code.org/apidocs/pmd-core/6.23.0/net/sourceforge/pmd/lang/ast/AbstractTokenManager.html#getFileName(java.lang.String)"><code>AbstractTokenManager#getFileName</code></a> |
| 195 | +* <a href="https://docs.pmd-code.org/apidocs/pmd-core/6.23.0/net/sourceforge/pmd/cpd/token/AntlrToken.html#getType()"><code>AntlrToken#getType</code></a> - use `getKind()` instead. |
| 196 | +* <a href="https://docs.pmd-code.org/apidocs/pmd-core/6.23.0/net/sourceforge/pmd/lang/rule/ImmutableLanguage.html#"><code>ImmutableLanguage</code></a> |
| 197 | +* <a href="https://docs.pmd-code.org/apidocs/pmd-core/6.23.0/net/sourceforge/pmd/lang/rule/MockRule.html#"><code>MockRule</code></a> |
| 198 | +* <a href="https://docs.pmd-code.org/apidocs/pmd-core/6.23.0/net/sourceforge/pmd/lang/ast/Node.html#getFirstParentOfAnyType(java.lang.Class[])"><code>Node#getFirstParentOfAnyType</code></a> |
| 199 | +* <a href="https://docs.pmd-code.org/apidocs/pmd-core/6.23.0/net/sourceforge/pmd/lang/ast/Node.html#getAsDocument()"><code>Node#getAsDocument</code></a> |
| 200 | +* <a href="https://docs.pmd-code.org/apidocs/pmd-core/6.23.0/net/sourceforge/pmd/lang/ast/AbstractNode.html#hasDescendantOfAnyType(java.lang.Class[])"><code>AbstractNode#hasDescendantOfAnyType</code></a> |
| 201 | +* <a href="https://docs.pmd-code.org/apidocs/pmd-java/6.23.0/net/sourceforge/pmd/lang/java/ast/ASTRecordDeclaration.html#getComponentList()"><code>ASTRecordDeclaration#getComponentList</code></a> |
| 202 | +* Multiple fields, constructors and methods in <a href="https://docs.pmd-code.org/apidocs/pmd-core/6.23.0/net/sourceforge/pmd/lang/rule/XPathRule.html#"><code>XPathRule</code></a>. See javadoc for details. |
| 203 | + |
| 204 | +### External Contributions |
| 205 | + |
| 206 | +* [#2312](https://github.com/pmd/pmd/pull/2312): \[apex] Update ApexCRUDViolation Rule - [Joshua S Arquilevich](https://github.com/jarquile) |
| 207 | +* [#2314](https://github.com/pmd/pmd/pull/2314): \[doc] maven integration - Add version to plugin - [Pham Hai Trung](https://github.com/gpbp) |
| 208 | +* [#2353](https://github.com/pmd/pmd/pull/2353): \[plsql] xmlforest with optional AS - [Piotr Szymanski](https://github.com/szyman23) |
| 209 | +* [#2383](https://github.com/pmd/pmd/pull/2383): \[apex] Fix invalid apex in documentation - [Gwilym Kuiper](https://github.com/gwilymatgearset) |
| 210 | +* [#2395](https://github.com/pmd/pmd/pull/2395): \[apex] New Rule: Unused local variables - [Gwilym Kuiper](https://github.com/gwilymatgearset) |
| 211 | +* [#2396](https://github.com/pmd/pmd/pull/2396): \[apex] New rule: field declarations should be at start - [Gwilym Kuiper](https://github.com/gwilymatgearset) |
| 212 | +* [#2397](https://github.com/pmd/pmd/pull/2397): \[apex] fixed WITH SECURITY_ENFORCED regex to recognise line break characters - [Kieran Black](https://github.com/kieranlblack) |
| 213 | +* [#2401](https://github.com/pmd/pmd/pull/2401): \[doc] Update DoNotUseThreads rule documentation - [Saikat Sengupta](https://github.com/s4ik4t) |
| 214 | +* [#2403](https://github.com/pmd/pmd/pull/2403): \[java] #2402 fix false-positives on Primitive Streams - [Bernd Farka](https://github.com/BerndFarkaDyna) |
| 215 | +* [#2409](https://github.com/pmd/pmd/pull/2409): \[java] ClassNamingConventions suggests to add Util for class containing only static constants, fixes #1164 - [Binu R J](https://github.com/binu-r) |
| 216 | +* [#2411](https://github.com/pmd/pmd/pull/2411): \[java] Fix UseAssertEqualsInsteadOfAssertTrue Example - [Moritz Scheve](https://github.com/Blightbuster) |
| 217 | +* [#2423](https://github.com/pmd/pmd/pull/2423): \[core] Fix Checkstyle OperatorWrap in AbstractTokenizer - [Harsh Kukreja](https://github.com/harsh-kukreja) |
| 218 | +* [#2432](https://github.com/pmd/pmd/pull/2432): \[core] Close ZIP data sources even if a runtime exception or error is thrown - [Gonzalo Exequiel Ibars Ingman](https://github.com/gibarsin) |
| 219 | + |
| 220 | +### Stats |
| 221 | +* 237 commits |
| 222 | +* 64 closed tickets & PRs |
| 223 | +* Days since last release: 42 |
0 commit comments