1
0
forked from phoedos/pmd

Merge branch '7.0.x' into update-saxon-version

This commit is contained in:
Clément Fournier
2020-04-27 21:39:57 +02:00
28 changed files with 570 additions and 18203 deletions

@ -62,7 +62,11 @@ elif travis_isPush; then
sourceforge_uploadFile "${VERSION}" "pmd-dist/target/pmd-bin-${VERSION}.zip"
sourceforge_uploadFile "${VERSION}" "pmd-dist/target/pmd-src-${VERSION}.zip"
regression-tester_uploadBaseline
if [ "${TRAVIS_BRANCH}" != "java-grammar" ]; then
regression-tester_uploadBaseline
else
log_info "Skipping regression tester for branch ${TRAVIS_BRANCH}"
fi
else
# other build. Can happen during release: the commit with a non snapshot version is built, but not from the tag.

@ -1,6 +1,9 @@
source 'https://rubygems.org/'
gem 'pmdtester', :git => 'https://github.com/pmd/pmd-regression-tester.git'
# bleeding edge from git
#gem 'pmdtester', :git => 'https://github.com/pmd/pmd-regression-tester.git'
gem 'pmdtester', '~> 1.0'
gem 'danger', '~> 5.6', '>= 5.6'
# This group is only needed for rendering release notes

@ -1,13 +1,3 @@
GIT
remote: https://github.com/pmd/pmd-regression-tester.git
revision: 8e652477b3547d6c843864a2641389a4c61c383e
specs:
pmdtester (1.0.0.pre.SNAPSHOT)
differ
nokogiri (~> 1.8.2)
rufus-scheduler (~> 3.5, >= 3.5)
slop (~> 4.6.2)
GEM
remote: https://rubygems.org/
specs:
@ -19,7 +9,7 @@ GEM
nap
open4 (~> 1.3)
colored2 (3.1.2)
concurrent-ruby (1.1.5)
concurrent-ruby (1.1.6)
cork (0.3.0)
colored2 (~> 3.1)
danger (5.16.1)
@ -35,42 +25,50 @@ GEM
octokit (~> 4.7)
terminal-table (~> 1)
differ (0.1.2)
et-orbi (1.2.2)
et-orbi (1.2.4)
tzinfo
faraday (0.16.2)
faraday (0.17.3)
multipart-post (>= 1.2, < 3)
faraday-http-cache (1.3.1)
faraday (~> 0.8)
fugit (1.3.3)
fugit (1.3.4)
et-orbi (~> 1.1, >= 1.1.8)
raabro (~> 1.1)
git (1.5.0)
git (1.6.0)
rchardet (~> 1.8)
kramdown (1.17.0)
liquid (4.0.3)
mini_portile2 (2.3.0)
mini_portile2 (2.4.0)
multipart-post (2.1.1)
nap (1.1.0)
no_proxy_fix (0.1.2)
nokogiri (1.8.5)
mini_portile2 (~> 2.3.0)
octokit (4.14.0)
nokogiri (1.10.9)
mini_portile2 (~> 2.4.0)
octokit (4.18.0)
faraday (>= 0.9)
sawyer (~> 0.8.0, >= 0.5.3)
open4 (1.3.4)
public_suffix (4.0.1)
pmdtester (1.0.0)
differ (~> 0.1)
nokogiri (~> 1.8)
rufus-scheduler (~> 3.5)
slop (~> 4.6)
public_suffix (4.0.4)
raabro (1.1.6)
rouge (3.11.0)
rchardet (1.8.0)
rouge (3.18.0)
rufus-scheduler (3.6.0)
fugit (~> 1.1, >= 1.1.6)
safe_yaml (1.0.5)
sawyer (0.8.2)
addressable (>= 2.3.5)
faraday (> 0.8, < 2.0)
slop (4.6.2)
slop (4.8.1)
terminal-table (1.8.0)
unicode-display_width (~> 1.1, >= 1.1.1)
tzinfo (2.0.0)
tzinfo (2.0.2)
concurrent-ruby (~> 1.0)
unicode-display_width (1.6.0)
unicode-display_width (1.7.0)
PLATFORMS
ruby
@ -78,9 +76,9 @@ PLATFORMS
DEPENDENCIES
danger (~> 5.6, >= 5.6)
liquid (>= 4.0.0)
pmdtester!
pmdtester (~> 1.0)
rouge (>= 1.7, < 4)
safe_yaml (>= 1.0)
BUNDLED WITH
2.0.1
2.1.4

@ -78,6 +78,9 @@ RELEASE_RULESET="pmd-core/src/main/resources/rulesets/releases/${RELEASE_VERSION
echo "* Update date info in **docs/_config.yml**."
echo " date: $(date -u +%d-%B-%Y)"
echo
echo "* Update version info in **docs/_config.yml**."
echo " remove the SNAPSHOT from site.pmd.version"
echo
echo "* Ensure all the new rules are listed in the proper file:"
echo " ${RELEASE_RULESET}"
echo
@ -113,7 +116,10 @@ echo
echo "Updated stats in release notes:"
echo "$STATS"
echo
echo "Please verify docs/pages/release_notes.md"
echo
echo "Press enter to continue..."
read
# install bundles needed for rendering release notes
bundle install --with=release_notes_preprocessing --path vendor/bundle

@ -1,7 +1,7 @@
GEM
remote: https://rubygems.org/
specs:
activesupport (6.0.2.1)
activesupport (6.0.2.2)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
@ -26,7 +26,7 @@ GEM
ffi (>= 1.3.0)
eventmachine (1.2.7)
execjs (2.7.0)
faraday (1.0.0)
faraday (1.0.1)
multipart-post (>= 1.2, < 3)
ffi (1.12.2)
forwardable-extended (2.6.0)
@ -204,9 +204,9 @@ GEM
jekyll-seo-tag (~> 2.1)
minitest (5.14.0)
multipart-post (2.1.1)
nokogiri (1.10.8)
nokogiri (1.10.9)
mini_portile2 (~> 2.4.0)
octokit (4.16.0)
octokit (4.18.0)
faraday (>= 0.9)
sawyer (~> 0.8.0, >= 0.5.3)
pathutil (0.16.2)
@ -216,9 +216,9 @@ GEM
rb-inotify (0.10.1)
ffi (~> 1.0)
rouge (3.13.0)
ruby-enum (0.7.2)
ruby-enum (0.8.0)
i18n
rubyzip (2.2.0)
rubyzip (2.3.0)
safe_yaml (1.0.5)
sass (3.7.4)
sass-listen (~> 4.0.0)
@ -233,10 +233,10 @@ GEM
thread_safe (0.3.6)
typhoeus (1.3.1)
ethon (>= 0.9.0)
tzinfo (1.2.6)
tzinfo (1.2.7)
thread_safe (~> 0.1)
unicode-display_width (1.6.1)
zeitwerk (2.2.2)
unicode-display_width (1.7.0)
zeitwerk (2.3.0)
PLATFORMS
ruby

@ -1,9 +1,9 @@
repository: pmd/pmd
pmd:
version: 6.23.0-SNAPSHOT
previous_version: 6.22.0
date: ??-??-2020
version: 6.24.0-SNAPSHOT
previous_version: 6.23.0
date: ??-May-2020
release_type: minor
# release types: major, minor, bugfix
@ -42,6 +42,9 @@ exclude:
- README.md
- Dockerfile
- build-docs.sh
- pdf-*.sh
- pdfconfigs/
- pdf/
feedback_subject_line: PMD Source Code Analyzer

@ -73,6 +73,94 @@ the breaking API changes will be performed in 7.0.0.
an API is tagged as `@Deprecated` or not in the latest minor release. During the development of 7.0.0,
we may decide to remove some APIs that were not tagged as deprecated, though we'll try to avoid it." %}
#### 6.23.0
##### 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.
* {% jdoc core::lang.rule.xpath.AbstractXPathRuleQuery %}
* {% jdoc core::lang.rule.xpath.JaxenXPathRuleQuery %}
* {% jdoc core::lang.rule.xpath.SaxonXPathRuleQuery %}
* {% jdoc core::lang.rule.xpath.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
marked {% jdoc core::annotation.InternalApi %}. 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.
* In the meantime you should use interfaces like {% jdoc visualforce::lang.vf.ast.VfNode %} or
{% jdoc core::lang.ast.Node %}, or the other published interfaces in this package,
to refer to nodes generically.
* Concrete node classes will **be made final** with 7.0.0.
* 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 {% jdoc core::lang.Parser %} (eg {% jdoc visualforce::lang.vf.VfParser %}) are deprecated and should not be used directly.
Use {% jdoc !!core::lang.LanguageVersionHandler#getParser(ParserOptions) %} instead.
* The implementation classes of {% jdoc core::lang.TokenManager %} (eg {% jdoc visualforce::lang.vf.VfTokenManager %}) 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: **{% jdoc_package apex::lang.apex.ast %}**
* Javascript: **{% jdoc_package javascript::lang.ecmascript.ast %}**
* PL/SQL: **{% jdoc_package plsql::lang.plsql.ast %}**
* Scala: **{% jdoc_package scala::lang.scala.ast %}**
* Visualforce: **{% jdoc_package visualforce::lang.vf.ast %}**
These deprecations have already been rolled out in a previous version for the
following languages:
* Java: {% jdoc_package java::lang.java.ast %}
* Java Server Pages: {% jdoc_package jsp::lang.jsp.ast %}
* Velocity Template Language: {% jdoc_package vm::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):
* {% jdoc cpp::lang.cpp.CppTokenManager %}
* {% jdoc java::lang.java.JavaTokenManager %}
* {% jdoc javascript::lang.ecmascript5.Ecmascript5TokenManager %}
* {% jdoc jsp::lang.jsp.JspTokenManager %}
* {% jdoc matlab::lang.matlab.MatlabTokenManager %}
* {% jdoc modelica::lang.modelica.ModelicaTokenManager %}
* {% jdoc objectivec::lang.objectivec.ObjectiveCTokenManager %}
* {% jdoc plsql::lang.plsql.PLSQLTokenManager %}
* {% jdoc python::lang.python.PythonTokenManager %}
* {% jdoc visualforce::lang.vf.VfTokenManager %}
* {% jdoc vm::lang.vm.VmTokenManager %}
In the **Java AST** the following attributes are deprecated and will issue a warning when used in XPath rules:
* {% jdoc !!java::lang.java.ast.ASTAdditiveExpression#getImage() %} - use `getOperator()` instead
* {% jdoc !!java::lang.java.ast.ASTVariableDeclaratorId#getImage() %} - use `getName()` instead
* {% jdoc !!java::lang.java.ast.ASTVariableDeclaratorId#getVariableName() %} - use `getName()` instead
###### For removal
* {% jdoc !!core::lang.Parser#getTokenManager(java.lang.String,java.io.Reader) %}
* {% jdoc !!core::lang.TokenManager#setFileName(java.lang.String) %}
* {% jdoc !!core::lang.ast.AbstractTokenManager#setFileName(java.lang.String) %}
* {% jdoc !!core::lang.ast.AbstractTokenManager#getFileName(java.lang.String) %}
* {% jdoc !!core::cpd.token.AntlrToken#getType() %} - use `getKind()` instead.
* {% jdoc core::lang.rule.ImmutableLanguage %}
* {% jdoc core::lang.rule.MockRule %}
* {% jdoc !!core::lang.ast.Node#getFirstParentOfAnyType(java.lang.Class[]) %}
* {% jdoc !!core::lang.ast.Node#getAsDocument() %}
* {% jdoc !!core::lang.ast.AbstractNode#hasDescendantOfAnyType(java.lang.Class[]) %}
* {% jdoc !!java::lang.java.ast.ASTRecordDeclaration#getComponentList() %}
* Multiple fields, constructors and methods in {% jdoc core::lang.rule.XPathRule %}. See javadoc for details.
#### 6.22.0
##### Deprecated APIs

@ -19,189 +19,11 @@ This is a {{ site.pmd.release_type }} release.
### New and noteworthy
#### PMD adopts Contributor Code of Conduct
To facilitate healthy and constructive community behavior PMD adopts
[Contributor Convenant](https://www.contributor-covenant.org/) 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](https://github.com/pmd/pmd/blob/master/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](https://pmd.github.io/latest/pmd_userdocs_extending_writing_xpath_rules.html#migrating-from-10-to-20).
#### Javascript improvements for ES6
PMD uses the [Rhino](https://github.com/mozilla/rhino) library to parse Javascript.
The default version has been set to `ES6`, so that some ECMAScript 2015 features are
supported. E.g. `let` statements and `for-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](https://pmd.github.io/latest/pmd_userdocs_report_formats.html#json)
#### New Rules
* The new Apex rule {% rule "apex/codestyle/FieldDeclarationsShouldBeAtStart" %} (`apex-codestyle`)
helps to ensure that field declarations are always at the beginning of a class.
* The new Apex rule {% rule "apex/bestpractices/UnusedLocalVariable" %} (`apex-bestpractices`) detects unused
local variables.
### Fixed Issues
* apex-design
* [#2358](https://github.com/pmd/pmd/issues/2358): \[apex] Invalid Apex in Cognitive Complexity tests
* apex-security
* [#2210](https://github.com/pmd/pmd/issues/2210): \[apex] ApexCRUDViolation: Support WITH SECURITY_ENFORCED
* [#2399](https://github.com/pmd/pmd/issues/2399): \[apex] ApexCRUDViolation: false positive with security enforced with line break
* core
* [#1286](https://github.com/pmd/pmd/issues/1286): \[core] Export Supporting JSON Format
* [#2019](https://github.com/pmd/pmd/issues/2019): \[core] Insufficient deprecation warnings for XPath attributes
* [#2357](https://github.com/pmd/pmd/issues/2357): Add code of conduct: Contributor Covenant
* [#2426](https://github.com/pmd/pmd/issues/2426): \[core] CodeClimate renderer links are dead
* doc
* [#2355](https://github.com/pmd/pmd/issues/2355): \[doc] Improve documentation about incremental analysis
* [#2356](https://github.com/pmd/pmd/issues/2356): \[doc] Add missing doc about pmd.github.io
* [#2412](https://github.com/pmd/pmd/issues/2412): \[core] HTMLRenderer doesn't render links to source files
* [#2413](https://github.com/pmd/pmd/issues/2413): \[doc] Improve documentation about the available renderers (PMD/CPD)
* java
* [#2378](https://github.com/pmd/pmd/issues/2378): \[java] AbstractJUnitRule has bad performance on large code bases
* java-bestpractices
* [#2398](https://github.com/pmd/pmd/issues/2398): \[java] AbstractClassWithoutAbstractMethod false negative with inner abstract classes
* java-codestyle
* [#1164](https://github.com/pmd/pmd/issues/1164): \[java] ClassNamingConventions suggests to add Util for class containing only static constants
* [#1723](https://github.com/pmd/pmd/issues/1723): \[java] UseDiamondOperator false-positive inside lambda
* java-design
* [#2390](https://github.com/pmd/pmd/issues/2390): \[java] AbstractClassWithoutAnyMethod: missing violation for nested classes
* java-errorprone
* [#2402](https://github.com/pmd/pmd/issues/2402): \[java] CloseResource possible false positive with Primitive Streams
* java-multithreading
* [#2313](https://github.com/pmd/pmd/issues/2313): \[java] Documenation for DoNotUseThreads is outdated
* javascript
* [#1235](https://github.com/pmd/pmd/issues/1235): \[javascript] Use of let results in an Empty Statement in the AST
* [#2379](https://github.com/pmd/pmd/issues/2379): \[javascript] Support for-of loop
* javascript-errorprone
* [#384](https://github.com/pmd/pmd/issues/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.
* {% jdoc core::lang.rule.xpath.AbstractXPathRuleQuery %}
* {% jdoc core::lang.rule.xpath.JaxenXPathRuleQuery %}
* {% jdoc core::lang.rule.xpath.SaxonXPathRuleQuery %}
* {% jdoc core::lang.rule.xpath.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
marked {% jdoc core::annotation.InternalApi %}. 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.
* In the meantime you should use interfaces like {% jdoc visualforce::lang.vf.ast.VfNode %} or
{% jdoc core::lang.ast.Node %}, or the other published interfaces in this package,
to refer to nodes generically.
* Concrete node classes will **be made final** with 7.0.0.
* 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 {% jdoc core::lang.Parser %} (eg {% jdoc visualforce::lang.vf.VfParser %}) are deprecated and should not be used directly.
Use {% jdoc !!core::lang.LanguageVersionHandler#getParser(ParserOptions) %} instead.
* The implementation classes of {% jdoc core::lang.TokenManager %} (eg {% jdoc visualforce::lang.vf.VfTokenManager %}) 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: **{% jdoc_package apex::lang.apex.ast %}**
* Javascript: **{% jdoc_package javascript::lang.ecmascript.ast %}**
* PL/SQL: **{% jdoc_package plsql::lang.plsql.ast %}**
* Scala: **{% jdoc_package scala::lang.scala.ast %}**
* Visualforce: **{% jdoc_package visualforce::lang.vf.ast %}**
These deprecations have already been rolled out in a previous version for the
following languages:
* Java: {% jdoc_package java::lang.java.ast %}
* Java Server Pages: {% jdoc_package jsp::lang.jsp.ast %}
* Velocity Template Language: {% jdoc_package vm::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):
* {% jdoc cpp::lang.cpp.CppTokenManager %}
* {% jdoc java::lang.java.JavaTokenManager %}
* {% jdoc javascript::lang.ecmascript5.Ecmascript5TokenManager %}
* {% jdoc jsp::lang.jsp.JspTokenManager %}
* {% jdoc matlab::lang.matlab.MatlabTokenManager %}
* {% jdoc modelica::lang.modelica.ModelicaTokenManager %}
* {% jdoc objectivec::lang.objectivec.ObjectiveCTokenManager %}
* {% jdoc plsql::lang.plsql.PLSQLTokenManager %}
* {% jdoc python::lang.python.PythonTokenManager %}
* {% jdoc visualforce::lang.vf.VfTokenManager %}
* {% jdoc vm::lang.vm.VmTokenManager %}
In the **Java AST** the following attributes are deprecated and will issue a warning when used in XPath rules:
* {% jdoc !!java::lang.java.ast.ASTAdditiveExpression#getImage() %} - use `getOperator()` instead
* {% jdoc !!java::lang.java.ast.ASTVariableDeclaratorId#getImage() %} - use `getName()` instead
* {% jdoc !!java::lang.java.ast.ASTVariableDeclaratorId#getVariableName() %} - use `getName()` instead
##### For removal
* {% jdoc !!core::lang.Parser#getTokenManager(java.lang.String,java.io.Reader) %}
* {% jdoc !!core::lang.TokenManager#setFileName(java.lang.String) %}
* {% jdoc !!core::lang.ast.AbstractTokenManager#setFileName(java.lang.String) %}
* {% jdoc !!core::lang.ast.AbstractTokenManager#getFileName(java.lang.String) %}
* {% jdoc !!core::cpd.token.AntlrToken#getType() %} - use `getKind()` instead.
* {% jdoc core::lang.rule.ImmutableLanguage %}
* {% jdoc core::lang.rule.MockRule %}
* {% jdoc !!java::lang.java.ast.ASTRecordDeclaration#getComponentList() %}
* Multiple fields, constructors and methods in {% jdoc core::lang.rule.XPathRule %}. See javadoc for details.
### External Contributions
* [#2312](https://github.com/pmd/pmd/pull/2312): \[apex] Update ApexCRUDViolation Rule - [Joshua S Arquilevich](https://github.com/jarquile)
* [#2314](https://github.com/pmd/pmd/pull/2314): \[doc] maven integration - Add version to plugin - [Pham Hai Trung](https://github.com/gpbp)
* [#2353](https://github.com/pmd/pmd/pull/2353): \[plsql] xmlforest with optional AS - [Piotr Szymanski](https://github.com/szyman23)
* [#2383](https://github.com/pmd/pmd/pull/2383): \[apex] Fix invalid apex in documentation - [Gwilym Kuiper](https://github.com/gwilymatgearset)
* [#2395](https://github.com/pmd/pmd/pull/2395): \[apex] New Rule: Unused local variables - [Gwilym Kuiper](https://github.com/gwilymatgearset)
* [#2396](https://github.com/pmd/pmd/pull/2396): \[apex] New rule: field declarations should be at start - [Gwilym Kuiper](https://github.com/gwilymatgearset)
* [#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)
* [#2401](https://github.com/pmd/pmd/pull/2401): \[doc] Update DoNotUseThreads rule documentation - [Saikat Sengupta](https://github.com/s4ik4t)
* [#2403](https://github.com/pmd/pmd/pull/2403): \[java] #2402 fix false-positives on Primitive Streams - [Bernd Farka](https://github.com/BerndFarkaDyna)
* [#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)
* [#2411](https://github.com/pmd/pmd/pull/2411): \[java] Fix UseAssertEqualsInsteadOfAssertTrue Example - [Moritz Scheve](https://github.com/Blightbuster)
* [#2423](https://github.com/pmd/pmd/pull/2423): \[core] Fix Checkstyle OperatorWrap in AbstractTokenizer - [Harsh Kukreja](https://github.com/harsh-kukreja)
{% endtocmaker %}

@ -5,6 +5,225 @@ permalink: pmd_release_notes_old.html
Previous versions of PMD can be downloaded here: https://github.com/pmd/pmd/releases
## 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](#new-and-noteworthy)
* [PMD adopts Contributor Code of Conduct](#pmd-adopts-contributor-code-of-conduct)
* [Performance improvements for XPath 2.0 rules](#performance-improvements-for-xpath-2.0-rules)
* [Javascript improvements for ES6](#javascript-improvements-for-es6)
* [New JSON renderer](#new-json-renderer)
* [New Rules](#new-rules)
* [Fixed Issues](#fixed-issues)
* [API Changes](#api-changes)
* [Deprecated APIs](#deprecated-apis)
* [Internal API](#internal-api)
* [In ASTs](#in-asts)
* [For removal](#for-removal)
* [External Contributions](#external-contributions)
* [Stats](#stats)
### New and noteworthy
#### PMD adopts Contributor Code of Conduct
To facilitate healthy and constructive community behavior PMD adopts
[Contributor Convenant](https://www.contributor-covenant.org/) 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](https://github.com/pmd/pmd/blob/master/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](https://pmd.github.io/latest/pmd_userdocs_extending_writing_xpath_rules.html#migrating-from-10-to-20).
#### Javascript improvements for ES6
PMD uses the [Rhino](https://github.com/mozilla/rhino) library to parse Javascript.
The default version has been set to `ES6`, so that some ECMAScript 2015 features are
supported. E.g. `let` statements and `for-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](https://pmd.github.io/latest/pmd_userdocs_report_formats.html#json)
#### New Rules
* The new Apex rule [`FieldDeclarationsShouldBeAtStart`](https://pmd.github.io/pmd-6.23.0/pmd_rules_apex_codestyle.html#fielddeclarationsshouldbeatstart) (`apex-codestyle`)
helps to ensure that field declarations are always at the beginning of a class.
* The new Apex rule [`UnusedLocalVariable`](https://pmd.github.io/pmd-6.23.0/pmd_rules_apex_bestpractices.html#unusedlocalvariable) (`apex-bestpractices`) detects unused
local variables.
### Fixed Issues
* apex-design
* [#2358](https://github.com/pmd/pmd/issues/2358): \[apex] Invalid Apex in Cognitive Complexity tests
* apex-security
* [#2210](https://github.com/pmd/pmd/issues/2210): \[apex] ApexCRUDViolation: Support WITH SECURITY_ENFORCED
* [#2399](https://github.com/pmd/pmd/issues/2399): \[apex] ApexCRUDViolation: false positive with security enforced with line break
* core
* [#1286](https://github.com/pmd/pmd/issues/1286): \[core] Export Supporting JSON Format
* [#2019](https://github.com/pmd/pmd/issues/2019): \[core] Insufficient deprecation warnings for XPath attributes
* [#2357](https://github.com/pmd/pmd/issues/2357): Add code of conduct: Contributor Covenant
* [#2426](https://github.com/pmd/pmd/issues/2426): \[core] CodeClimate renderer links are dead
* [#2432](https://github.com/pmd/pmd/pull/2432): \[core] Close ZIP data sources even if a runtime exception or error is thrown
* doc
* [#2355](https://github.com/pmd/pmd/issues/2355): \[doc] Improve documentation about incremental analysis
* [#2356](https://github.com/pmd/pmd/issues/2356): \[doc] Add missing doc about pmd.github.io
* [#2412](https://github.com/pmd/pmd/issues/2412): \[core] HTMLRenderer doesn't render links to source files
* [#2413](https://github.com/pmd/pmd/issues/2413): \[doc] Improve documentation about the available renderers (PMD/CPD)
* java
* [#2378](https://github.com/pmd/pmd/issues/2378): \[java] AbstractJUnitRule has bad performance on large code bases
* java-bestpractices
* [#2398](https://github.com/pmd/pmd/issues/2398): \[java] AbstractClassWithoutAbstractMethod false negative with inner abstract classes
* java-codestyle
* [#1164](https://github.com/pmd/pmd/issues/1164): \[java] ClassNamingConventions suggests to add Util for class containing only static constants
* [#1723](https://github.com/pmd/pmd/issues/1723): \[java] UseDiamondOperator false-positive inside lambda
* java-design
* [#2390](https://github.com/pmd/pmd/issues/2390): \[java] AbstractClassWithoutAnyMethod: missing violation for nested classes
* java-errorprone
* [#2402](https://github.com/pmd/pmd/issues/2402): \[java] CloseResource possible false positive with Primitive Streams
* java-multithreading
* [#2313](https://github.com/pmd/pmd/issues/2313): \[java] Documenation for DoNotUseThreads is outdated
* javascript
* [#1235](https://github.com/pmd/pmd/issues/1235): \[javascript] Use of let results in an Empty Statement in the AST
* [#2379](https://github.com/pmd/pmd/issues/2379): \[javascript] Support for-of loop
* javascript-errorprone
* [#384](https://github.com/pmd/pmd/issues/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.
* <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>
* <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>
* <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>
* <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>
##### 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
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,
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.
* 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
<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,
to refer to nodes generically.
* Concrete node classes will **be made final** with 7.0.0.
* 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 <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.
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.
* 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.
**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: **<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>**
* 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>**
* 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>**
* 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>**
* 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>**
These deprecations have already been rolled out in a previous version for the
following languages:
* 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>
* 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>
* 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>
Outside of these packages, these changes also concern the following TokenManager
implementations, and their corresponding Parser if it exists (in the same package):
* <a href="https://docs.pmd-code.org/apidocs/pmd-cpp/6.23.0/net/sourceforge/pmd/lang/cpp/CppTokenManager.html#"><code>CppTokenManager</code></a>
* <a href="https://docs.pmd-code.org/apidocs/pmd-java/6.23.0/net/sourceforge/pmd/lang/java/JavaTokenManager.html#"><code>JavaTokenManager</code></a>
* <a href="https://docs.pmd-code.org/apidocs/pmd-javascript/6.23.0/net/sourceforge/pmd/lang/ecmascript5/Ecmascript5TokenManager.html#"><code>Ecmascript5TokenManager</code></a>
* <a href="https://docs.pmd-code.org/apidocs/pmd-jsp/6.23.0/net/sourceforge/pmd/lang/jsp/JspTokenManager.html#"><code>JspTokenManager</code></a>
* <a href="https://docs.pmd-code.org/apidocs/pmd-matlab/6.23.0/net/sourceforge/pmd/lang/matlab/MatlabTokenManager.html#"><code>MatlabTokenManager</code></a>
* <a href="https://docs.pmd-code.org/apidocs/pmd-modelica/6.23.0/net/sourceforge/pmd/lang/modelica/ModelicaTokenManager.html#"><code>ModelicaTokenManager</code></a>
* <a href="https://docs.pmd-code.org/apidocs/pmd-objectivec/6.23.0/net/sourceforge/pmd/lang/objectivec/ObjectiveCTokenManager.html#"><code>ObjectiveCTokenManager</code></a>
* <a href="https://docs.pmd-code.org/apidocs/pmd-plsql/6.23.0/net/sourceforge/pmd/lang/plsql/PLSQLTokenManager.html#"><code>PLSQLTokenManager</code></a>
* <a href="https://docs.pmd-code.org/apidocs/pmd-python/6.23.0/net/sourceforge/pmd/lang/python/PythonTokenManager.html#"><code>PythonTokenManager</code></a>
* <a href="https://docs.pmd-code.org/apidocs/pmd-visualforce/6.23.0/net/sourceforge/pmd/lang/vf/VfTokenManager.html#"><code>VfTokenManager</code></a>
* <a href="https://docs.pmd-code.org/apidocs/pmd-vm/6.23.0/net/sourceforge/pmd/lang/vm/VmTokenManager.html#"><code>VmTokenManager</code></a>
In the **Java AST** the following attributes are deprecated and will issue a warning when used in XPath rules:
* <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
* <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
* <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
##### For removal
* <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>
* <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>
* <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>
* <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>
* <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.
* <a href="https://docs.pmd-code.org/apidocs/pmd-core/6.23.0/net/sourceforge/pmd/lang/rule/ImmutableLanguage.html#"><code>ImmutableLanguage</code></a>
* <a href="https://docs.pmd-code.org/apidocs/pmd-core/6.23.0/net/sourceforge/pmd/lang/rule/MockRule.html#"><code>MockRule</code></a>
* <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>
* <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>
* <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>
* <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>
* 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.
### External Contributions
* [#2312](https://github.com/pmd/pmd/pull/2312): \[apex] Update ApexCRUDViolation Rule - [Joshua S Arquilevich](https://github.com/jarquile)
* [#2314](https://github.com/pmd/pmd/pull/2314): \[doc] maven integration - Add version to plugin - [Pham Hai Trung](https://github.com/gpbp)
* [#2353](https://github.com/pmd/pmd/pull/2353): \[plsql] xmlforest with optional AS - [Piotr Szymanski](https://github.com/szyman23)
* [#2383](https://github.com/pmd/pmd/pull/2383): \[apex] Fix invalid apex in documentation - [Gwilym Kuiper](https://github.com/gwilymatgearset)
* [#2395](https://github.com/pmd/pmd/pull/2395): \[apex] New Rule: Unused local variables - [Gwilym Kuiper](https://github.com/gwilymatgearset)
* [#2396](https://github.com/pmd/pmd/pull/2396): \[apex] New rule: field declarations should be at start - [Gwilym Kuiper](https://github.com/gwilymatgearset)
* [#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)
* [#2401](https://github.com/pmd/pmd/pull/2401): \[doc] Update DoNotUseThreads rule documentation - [Saikat Sengupta](https://github.com/s4ik4t)
* [#2403](https://github.com/pmd/pmd/pull/2403): \[java] #2402 fix false-positives on Primitive Streams - [Bernd Farka](https://github.com/BerndFarkaDyna)
* [#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)
* [#2411](https://github.com/pmd/pmd/pull/2411): \[java] Fix UseAssertEqualsInsteadOfAssertTrue Example - [Moritz Scheve](https://github.com/Blightbuster)
* [#2423](https://github.com/pmd/pmd/pull/2423): \[core] Fix Checkstyle OperatorWrap in AbstractTokenizer - [Harsh Kukreja](https://github.com/harsh-kukreja)
* [#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)
### Stats
* 237 commits
* 64 closed tickets & PRs
* Days since last release: 42
## 12-March-2020 - 6.22.0
The PMD team is pleased to announce PMD 6.22.0.

@ -1 +0,0 @@
. pdf-mydoc.sh; . pdf-product1.sh; . pdf-product2.sh;

@ -1,14 +0,0 @@
# Note that .sh scripts work only on Mac. If you're on Windows, install Git Bash and use that as your client.
echo 'Killing all Jekyll instances'
kill -9 $(ps aux | grep '[j]ekyll' | awk '{print $2}')
clear
echo "Building PDF-friendly HTML site for Mydoc ...";
bundle exec jekyll serve --detach --config _config.yml,pdfconfigs/config_mydoc_pdf.yml;
echo "done";
echo "Building the PDF ...";
prince --javascript --input-list=_site/pdfconfigs/prince-list.txt -o pdf/mydoc.pdf;
echo "done";

@ -1,11 +0,0 @@
echo 'Killing all Jekyll instances'
kill -9 $(ps aux | grep '[j]ekyll' | awk '{print $2}')
clear
echo "Building PDF-friendly HTML site for Product1 ...";
jekyll serve --detach --config _config.yml,pdfconfigs/config_product1_pdf.yml;
echo "done";
echo "Building the PDF ...";
prince --javascript --input-list=_site/pdfconfigs/prince-list.txt -o pdf/product1.pdf;
echo "done";

@ -1,11 +0,0 @@
echo 'Killing all Jekyll instances'
kill -9 $(ps aux | grep '[j]ekyll' | awk '{print $2}')
clear
echo "Building PDF-friendly HTML site for Product2 ...";
jekyll serve --detach --config _config.yml,pdfconfigs/config_product2_pdf.yml;
echo "done";
echo "Building the PDF ...";
prince --javascript --input-list=_site/pdfconfigs/prince-list.txt -o pdf/product2.pdf;
echo "done";

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

@ -1,18 +0,0 @@
destination: _site/
url: "http://127.0.0.1:4010"
baseurl: "/mydoc-pdf"
port: 4010
output: pdf
product: mydoc
print_title: Jekyll theme for documentation — mydoc product
print_subtitle: version 5.0
output: pdf
defaults:
-
scope:
path: ""
type: "pages"
values:
layout: "page_print"
comments: true
search: true

@ -1,18 +0,0 @@
destination: _site/
url: "http://127.0.0.1:4011"
baseurl: "/product1-pdf"
port: 4011
output: pdf
product: product1
print_title: Product 1 documentation
print_subtitle: version 1.0
output: pdf
defaults:
-
scope:
path: ""
type: "pages"
values:
layout: "page_print"
comments: true
search: true

@ -1,18 +0,0 @@
destination: _site/
url: "http://127.0.0.1:4012"
baseurl: "/product2-pdf"
port: 4012
output: pdf
product: product2
print_title: Product 2 documentation
print_subtitle: version 1.0
output: pdf
defaults:
-
scope:
path: ""
type: "pages"
values:
layout: "page_print"
comments: true
search: true

@ -196,6 +196,7 @@
<rule ref="category/apex/codestyle.xml/OneDeclarationPerLine">
<priority>3</priority>
</rule>
<!-- <rule ref="category/apex/codestyle.xml/FieldDeclarationsShouldBeAtStart"/> -->
<!-- DOCUMENTATION -->
<rule ref="category/apex/documentation.xml/ApexDoc" message="Document classes, methods, and properties that are public or global.">
@ -206,4 +207,6 @@
<rule ref="category/apex/bestpractices.xml/DebugsShouldUseLoggingLevel">
<priority>3</priority>
</rule>
<!-- <rule ref="category/apex/bestpractices.xml/UnusedLocalVariable"/> -->
</ruleset>

@ -287,7 +287,13 @@ public abstract class AbstractNode implements Node {
* Returns true if this node has a descendant of any type among the provided types.
*
* @param types Types to test
*
* @deprecated This is implemented inefficiently, with PMD 7 Node streams
* will provide a better alternative. We cannot ensure binary compatibility
* because the methods on 7.0 expect at least one class type, by requiring
* one Class parameter before the varargs (Effective Java 2nd ed., Item 42).
*/
@Deprecated
public final boolean hasDescendantOfAnyType(final Class<? extends Node>... types) {
// TODO consider implementing that with a single traversal!
// -> this is done if you use node streams

@ -38,6 +38,8 @@ import net.sourceforge.pmd.util.DataMap.DataKey;
* {@link #getXPathNodeName()}, {@link #getXPathAttributesIterator()}
* <li>Location metadata: eg {@link #getBeginLine()}, {@link #getBeginColumn()}
* </ul>
* Additionally, the {@linkplain #getUserMap() user data map} is an extensibility
* mechanism with which any client can independently associate values to AST nodes.
*
* <p>Every language implementation must publish a sub-interface of Node
* which serves as a supertype for all nodes of that language (e.g.
@ -299,7 +301,11 @@ public interface Node {
* @param parentTypes Types to look for
* @param <T> Most specific common type of the parameters
* @return The first parent with a matching type. Returns null if there is no such parent
*
* @deprecated This method causes an unchecked warning at call sites.
* PMD 7 will provide a way to do the same thing without the warning.
*/
@Deprecated
default <T extends Node> T getFirstParentOfAnyType(Class<? extends T>... parentTypes) {
return ancestors().map(it -> {
for (final Class<? extends T> c : parentTypes) {
@ -435,7 +441,17 @@ public interface Node {
* Get a DOM Document which contains Elements and Attributes representative of this Node and it's children.
* Essentially a DOM tree representation of the Node AST, thereby allowing tools which can operate upon DOM to also
* indirectly operate on the AST.
*
* @deprecated Converting a tree to a DOM is not a standard use case.
* The implementation rethrows a {@link ParserConfigurationException}
* as a {@link RuntimeException}, but a caller should handle
* it if he really wants to do this. Another problem is that
* this is available on any node, yet only the root node of
* a tree corresponds really to a document. The conversion
* is easy to implement anyway, and does not have to be part
* of this API.
*/
@Deprecated
default Document getAsDocument() {
try {
final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();

@ -110,27 +110,29 @@ public abstract class AbstractPMDProcessor {
// this is done manually without a try-with-resources
public void processFiles(RuleSetFactory ruleSetFactory, List<DataSource> files, RuleContext ctx,
List<Renderer> renderers) {
final RuleSets rs = createRuleSets(ruleSetFactory, ctx.getReport());
configuration.getAnalysisCache().checkValidity(rs, configuration.getClassLoader());
final SourceCodeProcessor processor = new SourceCodeProcessor(configuration);
try {
final RuleSets rs = createRuleSets(ruleSetFactory, ctx.getReport());
configuration.getAnalysisCache().checkValidity(rs, configuration.getClassLoader());
final SourceCodeProcessor processor = new SourceCodeProcessor(configuration);
for (final DataSource dataSource : files) {
// this is the real, canonical and absolute filename (not shortened)
String realFileName = dataSource.getNiceFileName(false, null);
for (final DataSource dataSource : files) {
// this is the real, canonical and absolute filename (not shortened)
String realFileName = dataSource.getNiceFileName(false, null);
runAnalysis(new PmdRunnable(dataSource, realFileName, renderers, ctx, rs, processor));
}
runAnalysis(new PmdRunnable(dataSource, realFileName, renderers, ctx, rs, processor));
}
// render base report first - general errors
renderReports(renderers, ctx.getReport());
// render base report first - general errors
renderReports(renderers, ctx.getReport());
// then add analysis results per file
collectReports(renderers);
// in case we analyzed files within Zip Files/Jars, we need to close them after
// the analysis is finished
for (DataSource dataSource : files) {
IOUtils.closeQuietly(dataSource);
// then add analysis results per file
collectReports(renderers);
} finally {
// in case we analyzed files within Zip Files/Jars, we need to close them after
// the analysis is finished
for (DataSource dataSource : files) {
IOUtils.closeQuietly(dataSource);
}
}
}

@ -7,6 +7,7 @@ package net.sourceforge.pmd.lang.ecmascript.ast;
import org.mozilla.javascript.ast.AstNode;
import net.sourceforge.pmd.lang.ast.Node;
import net.sourceforge.pmd.lang.ast.NodeStream;
public interface EcmascriptNode<T extends AstNode> extends Node {
@ -31,6 +32,13 @@ public interface EcmascriptNode<T extends AstNode> extends Node {
@Deprecated
T getNode();
@Override
default NodeStream<? extends EcmascriptNode<?>> children() {
return (NodeStream) Node.super.children();
}
/**
* Get the JsDoc associated with the given node. If there is no JsDoc on
* this node, it may be associated with a parent node, on more

@ -5,103 +5,207 @@
package net.sourceforge.pmd.lang.ecmascript.ast;
public interface EcmascriptParserVisitor {
Object visit(EcmascriptNode<?> node, Object data);
Object visit(ASTArrayComprehension node, Object data);
default Object visit(EcmascriptNode<?> node, Object data) {
for (EcmascriptNode<?> child : node.children()) {
child.jjtAccept(this, data);
}
return data;
}
Object visit(ASTArrayComprehensionLoop node, Object data);
default Object visit(ASTArrayComprehension node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
Object visit(ASTArrayLiteral node, Object data);
default Object visit(ASTArrayComprehensionLoop node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
Object visit(ASTAssignment node, Object data);
default Object visit(ASTArrayLiteral node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
Object visit(ASTAstRoot node, Object data);
default Object visit(ASTAssignment node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
Object visit(ASTBlock node, Object data);
default Object visit(ASTAstRoot node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
Object visit(ASTBreakStatement node, Object data);
default Object visit(ASTBlock node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
Object visit(ASTCatchClause node, Object data);
default Object visit(ASTBreakStatement node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
Object visit(ASTComment node, Object data);
default Object visit(ASTCatchClause node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
Object visit(ASTConditionalExpression node, Object data);
default Object visit(ASTComment node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
Object visit(ASTContinueStatement node, Object data);
default Object visit(ASTConditionalExpression node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
Object visit(ASTDoLoop node, Object data);
default Object visit(ASTContinueStatement node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
Object visit(ASTElementGet node, Object data);
default Object visit(ASTDoLoop node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
Object visit(ASTEmptyExpression node, Object data);
default Object visit(ASTElementGet node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
Object visit(ASTExpressionStatement node, Object data);
default Object visit(ASTEmptyExpression node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
Object visit(ASTForInLoop node, Object data);
default Object visit(ASTExpressionStatement node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
Object visit(ASTForLoop node, Object data);
default Object visit(ASTForInLoop node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
Object visit(ASTFunctionCall node, Object data);
default Object visit(ASTForLoop node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
Object visit(ASTFunctionNode node, Object data);
default Object visit(ASTFunctionCall node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
Object visit(ASTIfStatement node, Object data);
default Object visit(ASTFunctionNode node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
Object visit(ASTInfixExpression node, Object data);
default Object visit(ASTIfStatement node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
Object visit(ASTKeywordLiteral node, Object data);
default Object visit(ASTInfixExpression node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
Object visit(ASTLabel node, Object data);
default Object visit(ASTKeywordLiteral node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
Object visit(ASTLabeledStatement node, Object data);
default Object visit(ASTLabel node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
Object visit(ASTLetNode node, Object data);
default Object visit(ASTLabeledStatement node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
Object visit(ASTName node, Object data);
default Object visit(ASTLetNode node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
Object visit(ASTNewExpression node, Object data);
default Object visit(ASTName node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
Object visit(ASTNumberLiteral node, Object data);
default Object visit(ASTNewExpression node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
Object visit(ASTObjectLiteral node, Object data);
default Object visit(ASTNumberLiteral node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
Object visit(ASTObjectProperty node, Object data);
default Object visit(ASTObjectLiteral node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
Object visit(ASTParenthesizedExpression node, Object data);
default Object visit(ASTObjectProperty node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
Object visit(ASTPropertyGet node, Object data);
default Object visit(ASTParenthesizedExpression node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
Object visit(ASTRegExpLiteral node, Object data);
default Object visit(ASTPropertyGet node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
Object visit(ASTReturnStatement node, Object data);
default Object visit(ASTRegExpLiteral node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
Object visit(ASTScope node, Object data);
default Object visit(ASTReturnStatement node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
Object visit(ASTStringLiteral node, Object data);
default Object visit(ASTScope node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
Object visit(ASTSwitchCase node, Object data);
default Object visit(ASTStringLiteral node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
Object visit(ASTSwitchStatement node, Object data);
default Object visit(ASTSwitchCase node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
Object visit(ASTThrowStatement node, Object data);
default Object visit(ASTSwitchStatement node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
Object visit(ASTTryStatement node, Object data);
default Object visit(ASTThrowStatement node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
Object visit(ASTUnaryExpression node, Object data);
default Object visit(ASTTryStatement node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
Object visit(ASTVariableDeclaration node, Object data);
default Object visit(ASTUnaryExpression node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
Object visit(ASTVariableInitializer node, Object data);
default Object visit(ASTVariableDeclaration node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
Object visit(ASTWhileLoop node, Object data);
default Object visit(ASTVariableInitializer node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
Object visit(ASTWithStatement node, Object data);
default Object visit(ASTWhileLoop node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
Object visit(ASTXmlDotQuery node, Object data);
default Object visit(ASTWithStatement node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
Object visit(ASTXmlExpression node, Object data);
default Object visit(ASTXmlDotQuery node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
Object visit(ASTXmlMemberGet node, Object data);
default Object visit(ASTXmlExpression node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
Object visit(ASTXmlString node, Object data);
default Object visit(ASTXmlMemberGet node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
default Object visit(ASTXmlString node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
}

@ -6,254 +6,4 @@ package net.sourceforge.pmd.lang.ecmascript.ast;
public class EcmascriptParserVisitorAdapter implements EcmascriptParserVisitor {
@Override
public Object visit(EcmascriptNode<?> node, Object data) {
node.childrenAccept(this, data);
return null;
}
@Override
public Object visit(ASTArrayComprehension node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
@Override
public Object visit(ASTArrayComprehensionLoop node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
@Override
public Object visit(ASTArrayLiteral node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
@Override
public Object visit(ASTAssignment node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
@Override
public Object visit(ASTAstRoot node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
@Override
public Object visit(ASTBlock node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
@Override
public Object visit(ASTBreakStatement node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
@Override
public Object visit(ASTCatchClause node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
@Override
public Object visit(ASTComment node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
@Override
public Object visit(ASTConditionalExpression node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
@Override
public Object visit(ASTContinueStatement node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
@Override
public Object visit(ASTDoLoop node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
@Override
public Object visit(ASTElementGet node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
@Override
public Object visit(ASTEmptyExpression node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
@Override
public Object visit(ASTExpressionStatement node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
@Override
public Object visit(ASTForInLoop node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
@Override
public Object visit(ASTForLoop node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
@Override
public Object visit(ASTFunctionCall node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
@Override
public Object visit(ASTFunctionNode node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
@Override
public Object visit(ASTIfStatement node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
@Override
public Object visit(ASTInfixExpression node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
@Override
public Object visit(ASTKeywordLiteral node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
@Override
public Object visit(ASTLabel node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
@Override
public Object visit(ASTLabeledStatement node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
@Override
public Object visit(ASTLetNode node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
@Override
public Object visit(ASTName node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
@Override
public Object visit(ASTNewExpression node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
@Override
public Object visit(ASTNumberLiteral node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
@Override
public Object visit(ASTObjectLiteral node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
@Override
public Object visit(ASTObjectProperty node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
@Override
public Object visit(ASTParenthesizedExpression node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
@Override
public Object visit(ASTPropertyGet node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
@Override
public Object visit(ASTRegExpLiteral node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
@Override
public Object visit(ASTReturnStatement node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
@Override
public Object visit(ASTScope node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
@Override
public Object visit(ASTStringLiteral node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
@Override
public Object visit(ASTSwitchCase node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
@Override
public Object visit(ASTSwitchStatement node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
@Override
public Object visit(ASTThrowStatement node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
@Override
public Object visit(ASTTryStatement node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
@Override
public Object visit(ASTUnaryExpression node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
@Override
public Object visit(ASTVariableDeclaration node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
@Override
public Object visit(ASTVariableInitializer node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
@Override
public Object visit(ASTWhileLoop node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
@Override
public Object visit(ASTWithStatement node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
@Override
public Object visit(ASTXmlDotQuery node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
@Override
public Object visit(ASTXmlExpression node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
@Override
public Object visit(ASTXmlMemberGet node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
@Override
public Object visit(ASTXmlString node, Object data) {
return visit((EcmascriptNode<?>) node, data);
}
}

@ -107,7 +107,7 @@
<pmd.build-tools.version>6</pmd.build-tools.version>
<pmd-designer.version>6.21.0</pmd-designer.version>
<pmd-designer.version>6.24.0-SNAPSHOT</pmd-designer.version>
<javacc.jar>${settings.localRepository}/net/java/dev/javacc/javacc/${javacc.version}/javacc-${javacc.version}.jar</javacc.jar>
<javacc.outputDirectory>${project.build.directory}/generated-sources/javacc</javacc.outputDirectory>
<javacc.ant.wrapper>${project.basedir}/../javacc-wrapper.xml</javacc.ant.wrapper>
@ -376,12 +376,12 @@
<dependency>
<groupId>net.sourceforge.pmd</groupId>
<artifactId>pmd-core</artifactId>
<version>6.22.0</version>
<version>6.23.0</version>
</dependency>
<dependency>
<groupId>net.sourceforge.pmd</groupId>
<artifactId>pmd-java</artifactId>
<version>6.22.0</version>
<version>6.23.0</version>
</dependency>
<!-- This contains the dogfood ruleset -->
<dependency>