Merge branch '7.0.x' into text-utils-comments
This commit is contained in:
File diff suppressed because it is too large
Load Diff
35
.ci/build.sh
35
.ci/build.sh
@ -28,22 +28,34 @@ function build() {
|
||||
pmd_ci_utils_determine_build_env pmd/pmd
|
||||
echo
|
||||
|
||||
if ! pmd_ci_utils_is_fork_or_pull_request; then
|
||||
if [ "${PMD_CI_BRANCH}" = "experimental-apex-parser" ]; then
|
||||
pmd_ci_log_group_start "Build with mvnw"
|
||||
./mvnw clean install --show-version --errors --batch-mode --no-transfer-progress "${PMD_MAVEN_EXTRA_OPTS[@]}"
|
||||
pmd_ci_log_group_end
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
if pmd_ci_utils_is_fork_or_pull_request; then
|
||||
pmd_ci_log_group_start "Build with mvnw"
|
||||
./mvnw clean install --show-version --errors --batch-mode --no-transfer-progress "${PMD_MAVEN_EXTRA_OPTS[@]}"
|
||||
pmd_ci_log_group_end
|
||||
|
||||
# Danger is executed only on the linux runner
|
||||
if [ "$(pmd_ci_utils_get_os)" = "linux" ]; then
|
||||
pmd_ci_log_group_start "Executing danger"
|
||||
regression_tester_setup_ci
|
||||
regression_tester_executeDanger
|
||||
pmd_ci_log_group_end
|
||||
# Execute danger and dogfood only for pull requests in our own repository
|
||||
if [[ "${PMD_CI_IS_FORK}" = "false" && -n "${PMD_CI_PULL_REQUEST_NUMBER}" ]]; then
|
||||
# Danger is executed only on the linux runner
|
||||
if [ "$(pmd_ci_utils_get_os)" = "linux" ]; then
|
||||
pmd_ci_log_group_start "Executing danger"
|
||||
regression_tester_setup_ci
|
||||
regression_tester_executeDanger
|
||||
pmd_ci_log_group_end
|
||||
|
||||
# also run dogfood for PRs (only on linux)
|
||||
pmd_ci_log_group_start "Executing PMD dogfood test with ${PMD_CI_MAVEN_PROJECT_VERSION}"
|
||||
pmd_ci_dogfood
|
||||
pmd_ci_log_group_end
|
||||
# also run dogfood for PRs (only on linux)
|
||||
pmd_ci_log_group_start "Executing PMD dogfood test with ${PMD_CI_MAVEN_PROJECT_VERSION}"
|
||||
pmd_ci_dogfood
|
||||
pmd_ci_log_group_end
|
||||
fi
|
||||
fi
|
||||
|
||||
exit 0
|
||||
@ -245,12 +257,15 @@ ${rendered_release_notes}"
|
||||
# Runs the dogfood ruleset with the currently built pmd against itself
|
||||
#
|
||||
function pmd_ci_dogfood() {
|
||||
local mpmdVersion=()
|
||||
./mvnw versions:set -DnewVersion="${PMD_CI_MAVEN_PROJECT_VERSION}-dogfood" -DgenerateBackupPoms=false
|
||||
sed -i 's/<version>[0-9]\{1,\}\.[0-9]\{1,\}\.[0-9]\{1,\}.*<\/version>\( *<!-- pmd.dogfood.version -->\)/<version>'"${PMD_CI_MAVEN_PROJECT_VERSION}"'<\/version>\1/' pom.xml
|
||||
if [ "${PMD_CI_MAVEN_PROJECT_VERSION}" = "7.0.0-SNAPSHOT" ]; then
|
||||
sed -i 's/pmd-dogfood-config\.xml/pmd-dogfood-config7.xml/' pom.xml
|
||||
mpmdVersion=(-Denforcer.skip=true -Dpmd.plugin.version=3.18.0-pmd7-SNAPSHOT)
|
||||
fi
|
||||
./mvnw verify --show-version --errors --batch-mode --no-transfer-progress "${PMD_MAVEN_EXTRA_OPTS[@]}" \
|
||||
"${mpmdVersion[@]}" \
|
||||
-DskipTests \
|
||||
-Dmaven.javadoc.skip=true \
|
||||
-Dmaven.source.skip=true \
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<projectlist xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="projectlist_1_1_0.xsd">
|
||||
xsi:noNamespaceSchemaLocation="projectlist_1_1_0.xsd">
|
||||
<description>Standard Projects</description>
|
||||
|
||||
<project>
|
||||
@ -40,6 +40,11 @@ mvn dependency:build-classpath -DincludeScope=test -Dmdep.outputFile=classpath.t
|
||||
<exclude-pattern>.*/build/generated-sources/.*</exclude-pattern>
|
||||
|
||||
<build-command><![CDATA[#!/usr/bin/env bash
|
||||
## Skip gradle execution
|
||||
if test -e classpath.txt; then
|
||||
exit
|
||||
fi
|
||||
|
||||
set -e
|
||||
|
||||
# Make sure to use java11. This is already installed by build.sh
|
||||
@ -129,11 +134,6 @@ index 6021fa574d..15d29ed699 100644
|
||||
EOF
|
||||
) | patch --strip=1
|
||||
|
||||
## Skip gradle execution
|
||||
if test -e classpath.txt; then
|
||||
exit
|
||||
fi
|
||||
|
||||
./gradlew --console=plain --build-cache --no-daemon --max-workers=4 build testClasses -x test -x javadoc -x api -x asciidoctor -x asciidoctorPdf
|
||||
./gradlew --console=plain --build-cache --no-daemon --max-workers=4 createSquishClasspath -q > classpath.txt
|
||||
]]></build-command>
|
||||
@ -151,23 +151,15 @@ fi
|
||||
<project>
|
||||
<name>Schedul-o-matic-9000</name>
|
||||
<type>git</type>
|
||||
<connection>https://github.com/pmd/Schedul-o-matic-9000</connection>
|
||||
<!--
|
||||
<connection>https://github.com/SalesforceLabs/Schedul-o-matic-9000</connection>
|
||||
Note: using forked repo from pmd, as original repo doesn't have any useful tags/branches
|
||||
-->
|
||||
<tag>pmd-regression-test</tag>
|
||||
<tag>6b1229ba43b38931fbbab5924bc9b9611d19a786</tag>
|
||||
</project>
|
||||
|
||||
<project>
|
||||
<name>fflib-apex-common</name>
|
||||
<type>git</type>
|
||||
<connection>https://github.com/pmd/fflib-apex-common</connection>
|
||||
<!--
|
||||
<connection>https://github.com/apex-enterprise-patterns/fflib-apex-common</connection>
|
||||
Note: using forked repo from pmd, as original repo doesn't have any useful tags/branches
|
||||
-->
|
||||
<tag>pmd-regression-test</tag>
|
||||
<tag>7e0891efb86d23de62811af56d87d0959082a322</tag>
|
||||
</project>
|
||||
|
||||
<project>
|
||||
@ -177,4 +169,12 @@ fi
|
||||
<tag>v2.3.0</tag>
|
||||
<src-subpath>samples</src-subpath>
|
||||
</project>
|
||||
|
||||
<project>
|
||||
<name>java-regression-tests</name>
|
||||
<type>git</type>
|
||||
<connection>https://github.com/pmd/java-regression-tests</connection>
|
||||
<tag>main</tag>
|
||||
<auxclasspath-command>realpath java-regression-tests-*.jar</auxclasspath-command>
|
||||
</project>
|
||||
</projectlist>
|
||||
|
@ -27,7 +27,7 @@ function git_repo_sync() {
|
||||
pmd_ci_log_group_start "Git Sync"
|
||||
git remote add pmd-sf "${PMD_SF_USER}@git.code.sf.net:/p/pmd/code"
|
||||
if [ -n "${PMD_CI_BRANCH}" ]; then
|
||||
git push pmd-sf "${PMD_CI_BRANCH}:${PMD_CI_BRANCH}"
|
||||
retry 5 git push pmd-sf "${PMD_CI_BRANCH}:${PMD_CI_BRANCH}"
|
||||
pmd_ci_log_success "Successfully pushed ${PMD_CI_BRANCH} to sourceforge"
|
||||
elif [ -n "${PMD_CI_TAG}" ]; then
|
||||
git push pmd-sf tag "${PMD_CI_TAG}"
|
||||
@ -39,6 +39,43 @@ function git_repo_sync() {
|
||||
pmd_ci_log_group_end
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# From: https://gist.github.com/sj26/88e1c6584397bb7c13bd11108a579746
|
||||
#
|
||||
# Retry a command up to a specific number of times until it exits successfully,
|
||||
# with exponential back off.
|
||||
#
|
||||
# $ retry 5 echo Hello
|
||||
# Hello
|
||||
#
|
||||
# $ retry 5 false
|
||||
# Retry 1/5 exited 1, retrying in 1 seconds...
|
||||
# Retry 2/5 exited 1, retrying in 2 seconds...
|
||||
# Retry 3/5 exited 1, retrying in 4 seconds...
|
||||
# Retry 4/5 exited 1, retrying in 8 seconds...
|
||||
# Retry 5/5 exited 1, no more retries left.
|
||||
#
|
||||
function retry {
|
||||
local retries=$1
|
||||
shift
|
||||
|
||||
local count=0
|
||||
until "$@"; do
|
||||
exit=$?
|
||||
wait=$((2 ** $count))
|
||||
count=$(($count + 1))
|
||||
if [ $count -lt $retries ]; then
|
||||
echo "Retry $count/$retries exited $exit, retrying in $wait seconds..."
|
||||
sleep $wait
|
||||
else
|
||||
echo "Retry $count/$retries exited $exit, no more retries left."
|
||||
return $exit
|
||||
fi
|
||||
done
|
||||
return 0
|
||||
}
|
||||
|
||||
git_repo_sync
|
||||
|
||||
exit 0
|
||||
|
@ -19,7 +19,7 @@ Please provide the rule name and a link to the rule documentation:
|
||||
|
||||
**Code Sample demonstrating the issue:**
|
||||
|
||||
```
|
||||
```java
|
||||
|
||||
```
|
||||
|
||||
|
@ -19,7 +19,7 @@ Please provide the rule name and a link to the rule documentation:
|
||||
|
||||
**Code Sample demonstrating the issue:**
|
||||
|
||||
```
|
||||
```java
|
||||
|
||||
```
|
||||
|
||||
|
2
.github/ISSUE_TEMPLATE/2new_rule.md
vendored
2
.github/ISSUE_TEMPLATE/2new_rule.md
vendored
@ -17,7 +17,7 @@ assignees: ''
|
||||
**Code Sample:** This should include code, that should be flagged by the rule. If possible, the "correct" code
|
||||
according to this new rule should also be demonstrated.
|
||||
|
||||
```
|
||||
```java
|
||||
|
||||
```
|
||||
|
||||
|
2
.github/ISSUE_TEMPLATE/4bug_report.md
vendored
2
.github/ISSUE_TEMPLATE/4bug_report.md
vendored
@ -25,7 +25,7 @@ A clear and concise description of what the bug is.
|
||||
|
||||
**Code Sample demonstrating the issue:**
|
||||
|
||||
```
|
||||
```java
|
||||
|
||||
```
|
||||
|
||||
|
11
.github/workflows/build.yml
vendored
11
.github/workflows/build.yml
vendored
@ -6,6 +6,7 @@ on:
|
||||
- main
|
||||
- master
|
||||
- pmd/7.0.x
|
||||
- experimental-apex-parser
|
||||
tags:
|
||||
- '**'
|
||||
pull_request:
|
||||
@ -14,9 +15,17 @@ on:
|
||||
- cron: '0 4 1 * *'
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read # to fetch code (actions/checkout)
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ${{ matrix.os }}
|
||||
permissions:
|
||||
# read to fetch code (actions/checkout)
|
||||
# write to push code to gh-pages, create releases
|
||||
# note: forked repositories will have maximum read access
|
||||
contents: write
|
||||
continue-on-error: false
|
||||
strategy:
|
||||
matrix:
|
||||
@ -46,7 +55,7 @@ jobs:
|
||||
run: |
|
||||
echo "LANG=en_US.UTF-8" >> $GITHUB_ENV
|
||||
echo "MAVEN_OPTS=-Dmaven.wagon.httpconnectionManager.ttlSeconds=180 -Dmaven.wagon.http.retryHandler.count=3 -DautoReleaseAfterClose=true -DstagingProgressTimeoutMinutes=30" >> $GITHUB_ENV
|
||||
echo "PMD_CI_SCRIPTS_URL=https://raw.githubusercontent.com/pmd/build-tools/17/scripts" >> $GITHUB_ENV
|
||||
echo "PMD_CI_SCRIPTS_URL=https://raw.githubusercontent.com/pmd/build-tools/18/scripts" >> $GITHUB_ENV
|
||||
- name: Check Environment
|
||||
shell: bash
|
||||
run: |
|
||||
|
5
.github/workflows/git-repo-sync.yml
vendored
5
.github/workflows/git-repo-sync.yml
vendored
@ -10,6 +10,9 @@ on:
|
||||
- '**'
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read # to fetch code (actions/checkout)
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
@ -22,7 +25,7 @@ jobs:
|
||||
shell: bash
|
||||
run: |
|
||||
echo "LANG=en_US.UTF-8" >> $GITHUB_ENV
|
||||
echo "PMD_CI_SCRIPTS_URL=https://raw.githubusercontent.com/pmd/build-tools/17/scripts" >> $GITHUB_ENV
|
||||
echo "PMD_CI_SCRIPTS_URL=https://raw.githubusercontent.com/pmd/build-tools/18/scripts" >> $GITHUB_ENV
|
||||
- name: Sync
|
||||
run: .ci/git-repo-sync.sh
|
||||
shell: bash
|
||||
|
2
.github/workflows/troubleshooting.yml
vendored
2
.github/workflows/troubleshooting.yml
vendored
@ -36,7 +36,7 @@ jobs:
|
||||
run: |
|
||||
echo "LANG=en_US.UTF-8" >> $GITHUB_ENV
|
||||
echo "MAVEN_OPTS=-Dmaven.wagon.httpconnectionManager.ttlSeconds=180 -Dmaven.wagon.http.retryHandler.count=3 -DstagingProgressTimeoutMinutes=30" >> $GITHUB_ENV
|
||||
echo "PMD_CI_SCRIPTS_URL=https://raw.githubusercontent.com/pmd/build-tools/17/scripts" >> $GITHUB_ENV
|
||||
echo "PMD_CI_SCRIPTS_URL=https://raw.githubusercontent.com/pmd/build-tools/18/scripts" >> $GITHUB_ENV
|
||||
- name: Check Environment
|
||||
shell: bash
|
||||
run: |
|
||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -21,3 +21,4 @@ node_modules
|
||||
|
||||
# rule docs are generated
|
||||
docs/pages/pmd/rules
|
||||
.history/*
|
4
.mvn/wrapper/maven-wrapper.properties
vendored
4
.mvn/wrapper/maven-wrapper.properties
vendored
@ -14,5 +14,5 @@
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.5/apache-maven-3.8.5-bin.zip
|
||||
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar
|
||||
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.6/apache-maven-3.8.6-bin.zip
|
||||
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar
|
||||
|
55
Gemfile.lock
55
Gemfile.lock
@ -1,8 +1,8 @@
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
addressable (2.8.0)
|
||||
public_suffix (>= 2.0.2, < 5.0)
|
||||
addressable (2.8.1)
|
||||
public_suffix (>= 2.0.2, < 6.0)
|
||||
claide (1.1.0)
|
||||
claide-plugins (0.9.2)
|
||||
cork
|
||||
@ -12,7 +12,7 @@ GEM
|
||||
concurrent-ruby (1.1.10)
|
||||
cork (0.3.0)
|
||||
colored2 (~> 3.1)
|
||||
danger (8.6.1)
|
||||
danger (9.1.0)
|
||||
claide (~> 1.0)
|
||||
claide-plugins (>= 0.9.2)
|
||||
colored2 (~> 3.1)
|
||||
@ -23,12 +23,12 @@ GEM
|
||||
kramdown (~> 2.3)
|
||||
kramdown-parser-gfm (~> 1.0)
|
||||
no_proxy_fix
|
||||
octokit (~> 4.7)
|
||||
octokit (~> 5.0)
|
||||
terminal-table (>= 1, < 4)
|
||||
differ (0.1.2)
|
||||
et-orbi (1.2.7)
|
||||
tzinfo
|
||||
faraday (1.10.0)
|
||||
faraday (1.10.2)
|
||||
faraday-em_http (~> 1.0)
|
||||
faraday-em_synchrony (~> 1.0)
|
||||
faraday-excon (~> 1.1)
|
||||
@ -43,64 +43,65 @@ GEM
|
||||
faraday-em_http (1.0.0)
|
||||
faraday-em_synchrony (1.0.0)
|
||||
faraday-excon (1.1.0)
|
||||
faraday-http-cache (2.2.0)
|
||||
faraday-http-cache (2.4.1)
|
||||
faraday (>= 0.8)
|
||||
faraday-httpclient (1.0.1)
|
||||
faraday-multipart (1.0.3)
|
||||
multipart-post (>= 1.2, < 3)
|
||||
faraday-multipart (1.0.4)
|
||||
multipart-post (~> 2)
|
||||
faraday-net_http (1.0.1)
|
||||
faraday-net_http_persistent (1.2.0)
|
||||
faraday-patron (1.0.0)
|
||||
faraday-rack (1.0.0)
|
||||
faraday-retry (1.0.3)
|
||||
fugit (1.5.3)
|
||||
fugit (1.7.2)
|
||||
et-orbi (~> 1, >= 1.2.7)
|
||||
raabro (~> 1.4)
|
||||
git (1.11.0)
|
||||
git (1.12.0)
|
||||
addressable (~> 2.8)
|
||||
rchardet (~> 1.8)
|
||||
kramdown (2.4.0)
|
||||
rexml
|
||||
kramdown-parser-gfm (1.1.0)
|
||||
kramdown (~> 2.0)
|
||||
liquid (5.3.0)
|
||||
liquid (5.4.0)
|
||||
logger-colors (1.0.0)
|
||||
mini_portile2 (2.8.0)
|
||||
multipart-post (2.1.1)
|
||||
multipart-post (2.2.3)
|
||||
nap (1.1.0)
|
||||
no_proxy_fix (0.1.2)
|
||||
nokogiri (1.13.4)
|
||||
nokogiri (1.13.9)
|
||||
mini_portile2 (~> 2.8.0)
|
||||
racc (~> 1.4)
|
||||
octokit (4.22.0)
|
||||
faraday (>= 0.9)
|
||||
sawyer (~> 0.8.0, >= 0.5.3)
|
||||
octokit (5.6.1)
|
||||
faraday (>= 1, < 3)
|
||||
sawyer (~> 0.9)
|
||||
open4 (1.3.4)
|
||||
pmdtester (1.4.1)
|
||||
pmdtester (1.5.3)
|
||||
differ (~> 0.1)
|
||||
liquid (~> 5.2)
|
||||
liquid (~> 5.4)
|
||||
logger-colors (~> 1.0)
|
||||
nokogiri (~> 1.13)
|
||||
rufus-scheduler (~> 3.8)
|
||||
slop (~> 4.6)
|
||||
public_suffix (4.0.7)
|
||||
slop (~> 4.9)
|
||||
public_suffix (5.0.0)
|
||||
raabro (1.4.0)
|
||||
racc (1.6.0)
|
||||
rchardet (1.8.0)
|
||||
rexml (3.2.5)
|
||||
rouge (3.28.0)
|
||||
rouge (4.0.0)
|
||||
ruby2_keywords (0.0.5)
|
||||
rufus-scheduler (3.8.1)
|
||||
rufus-scheduler (3.8.2)
|
||||
fugit (~> 1.1, >= 1.1.6)
|
||||
safe_yaml (1.0.5)
|
||||
sawyer (0.8.2)
|
||||
sawyer (0.9.2)
|
||||
addressable (>= 2.3.5)
|
||||
faraday (> 0.8, < 2.0)
|
||||
slop (4.9.2)
|
||||
faraday (>= 0.17.3, < 3)
|
||||
slop (4.9.3)
|
||||
terminal-table (3.0.2)
|
||||
unicode-display_width (>= 1.1.1, < 3)
|
||||
tzinfo (2.0.4)
|
||||
tzinfo (2.0.5)
|
||||
concurrent-ruby (~> 1.0)
|
||||
unicode-display_width (2.1.0)
|
||||
unicode-display_width (2.3.0)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
@ -17,7 +17,8 @@ It uses JavaCC and Antlr to parse source files into abstract syntax trees (AST)
|
||||
Rules can be written in Java or using a XPath query.
|
||||
|
||||
It supports Java, JavaScript, Salesforce.com Apex and Visualforce,
|
||||
Modelica, PLSQL, Apache Velocity, XML, XSL, Scala.
|
||||
Modelica, PLSQL, Apache Velocity, XML, XSL.
|
||||
Scala is supported, but there are currently no Scala rules available.
|
||||
|
||||
Additionally it includes **CPD**, the copy-paste-detector. CPD finds duplicated code in
|
||||
C/C++, C#, Dart, Fortran, Go, Groovy, Java, JavaScript, JSP, Kotlin, Lua, Matlab, Modelica,
|
||||
|
10
SPONSORS.md
Normal file
10
SPONSORS.md
Normal file
@ -0,0 +1,10 @@
|
||||
# PMD's sponsors
|
||||
|
||||
Many thanks to all our sponsors:
|
||||
|
||||
* [Matt Hargett](https://github.com/matthargett) (@matthargett)
|
||||
|
||||
If you also want to sponsor PMD, you have two options:
|
||||
|
||||
* [Sponsor @pmd on GitHub Sponsors](https://github.com/sponsors/pmd)
|
||||
* [PMD - Open Collective](https://opencollective.com/pmd)
|
@ -8,7 +8,7 @@
|
||||
- lang-name: matches the grammar name (eg "Swift")
|
||||
- lang-terse-name: uncapitalized package name (eg "swift")
|
||||
- node-prefix: prefix for generated AST nodes (eg "Sw")
|
||||
- root-node-name: name of the root node (eg "TopLevel"), will be made to implement RootNode
|
||||
- root-node-name: name of the root node without prefix (eg "TopLevel"), will be made to implement RootNode
|
||||
|
||||
See AntlrGeneratedParserBase
|
||||
|
||||
@ -31,9 +31,45 @@
|
||||
<property name="base-visitor-name" value="${lang-name}BaseVisitor"/>
|
||||
<property name="base-visitor-file" value="${target-package-dir}/${base-visitor-name}.java"/>
|
||||
|
||||
<property name="listener-name" value="${lang-name}Listener"/>
|
||||
<property name="listener-file" value="${target-package-dir}/${visitor-name}.java"/>
|
||||
|
||||
<property name="base-listener-name" value="${lang-name}BaseListener"/>
|
||||
<property name="base-listener-file" value="${target-package-dir}/${base-visitor-name}.java"/>
|
||||
|
||||
<property name="node-itf-name" value="${lang-name}Node"/>
|
||||
<property name="base-class-name" value="Abstract${lang-name}Node"/>
|
||||
|
||||
<condition property="rename-parser">
|
||||
<and>
|
||||
<not>
|
||||
<available file="${parser-file}"/>
|
||||
</not>
|
||||
<available file="${target-package-dir}/${lang-name}.java"/>
|
||||
</and>
|
||||
</condition>
|
||||
|
||||
<target name="rename-parser" description="Rename the parser to our conventional name if needed"
|
||||
if="rename-parser">
|
||||
<replace file="${target-package-dir}/${lang-name}.java">
|
||||
<replacefilter token="class ${lang-name} "
|
||||
value="class ${parser-name} "/>
|
||||
<replacefilter token="public ${lang-name}(TokenStream input)"
|
||||
value="public ${parser-name}(TokenStream input)"/>
|
||||
</replace>
|
||||
<replace dir="${target-package-dir}">
|
||||
<include name="${lang-name}.java"/>
|
||||
<include name="${visitor-name}.java"/>
|
||||
<include name="${base-visitor-name}.java"/>
|
||||
<include name="${listener-name}.java"/>
|
||||
<include name="${base-listener-name}.java"/>
|
||||
<replacefilter token="${lang-name}." value="${parser-name}."/>
|
||||
</replace>
|
||||
|
||||
<move file="${target-package-dir}/${lang-name}.java"
|
||||
tofile="${parser-file}"/>
|
||||
</target>
|
||||
|
||||
<target name="cpd-language" description="Adapt Antlr sources for CPD-only languages">
|
||||
<!-- We only need the Lexer file. -->
|
||||
<delete file="${parser-file}"/>
|
||||
@ -45,7 +81,7 @@
|
||||
</delete>
|
||||
</target>
|
||||
|
||||
<target name="pmd-language" description="Adapt Antlr sources for PMD languages">
|
||||
<target name="pmd-language" description="Adapt Antlr sources for PMD languages" depends="rename-parser">
|
||||
|
||||
<!-- Adapt parser. -->
|
||||
<replace file="${parser-file}">
|
||||
|
@ -72,6 +72,14 @@ export RELEASE_VERSION
|
||||
export DEVELOPMENT_VERSION
|
||||
export CURRENT_BRANCH
|
||||
|
||||
# check for SNAPSHOT version of pmd.build-tools.version
|
||||
BUILD_TOOLS_VERSION=$(./mvnw org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate -Dexpression=pmd.build-tools.version -q -DforceStdout)
|
||||
BUILD_TOOLS_VERSION_RELEASE=${BUILD_TOOLS_VERSION%-SNAPSHOT}
|
||||
if [ "${BUILD_TOOLS_VERSION}" != "${BUILD_TOOLS_VERSION_RELEASE}" ]; then
|
||||
echo "Error: version pmd.build-tools.version is ${BUILD_TOOLS_VERSION} - snapshot is not allowed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
RELEASE_RULESET="pmd-core/src/main/resources/rulesets/releases/${RELEASE_VERSION//\./}.xml"
|
||||
|
||||
echo "* Update date info in **docs/_config.yml**."
|
||||
@ -108,7 +116,7 @@ echo "* Days since last release: $(( ( $(date +%s) - $(git log --max-count=1 --f
|
||||
)
|
||||
|
||||
TEMP_RELEASE_NOTES=$(cat docs/pages/release_notes.md)
|
||||
TEMP_RELEASE_NOTES=${TEMP_RELEASE_NOTES/\{\% endtocmaker \%\}/$STATS$'\n'$'\n'\{\% endtocmaker \%\}$'\n'}
|
||||
TEMP_RELEASE_NOTES=${TEMP_RELEASE_NOTES/\{\% endtocmaker \%\}/${STATS//\&/\\\&}$'\n'$'\n'\{\% endtocmaker \%\}$'\n'}
|
||||
echo "${TEMP_RELEASE_NOTES}" > docs/pages/release_notes.md
|
||||
|
||||
echo
|
||||
|
@ -1,57 +1,38 @@
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
activesupport (6.0.4.8)
|
||||
activesupport (6.0.6)
|
||||
concurrent-ruby (~> 1.0, >= 1.0.2)
|
||||
i18n (>= 0.7, < 2)
|
||||
minitest (~> 5.1)
|
||||
tzinfo (~> 1.1)
|
||||
zeitwerk (~> 2.2, >= 2.2.2)
|
||||
addressable (2.8.0)
|
||||
public_suffix (>= 2.0.2, < 5.0)
|
||||
addressable (2.8.1)
|
||||
public_suffix (>= 2.0.2, < 6.0)
|
||||
coffee-script (2.4.1)
|
||||
coffee-script-source
|
||||
execjs
|
||||
coffee-script-source (1.11.1)
|
||||
colorator (1.1.0)
|
||||
commonmarker (0.23.4)
|
||||
commonmarker (0.23.6)
|
||||
concurrent-ruby (1.1.10)
|
||||
dnsruby (1.61.9)
|
||||
simpleidn (~> 0.1)
|
||||
em-websocket (0.5.3)
|
||||
eventmachine (>= 0.12.9)
|
||||
http_parser.rb (~> 0)
|
||||
ethon (0.15.0)
|
||||
ethon (0.16.0)
|
||||
ffi (>= 1.15.0)
|
||||
eventmachine (1.2.7)
|
||||
execjs (2.8.1)
|
||||
faraday (1.10.0)
|
||||
faraday-em_http (~> 1.0)
|
||||
faraday-em_synchrony (~> 1.0)
|
||||
faraday-excon (~> 1.1)
|
||||
faraday-httpclient (~> 1.0)
|
||||
faraday-multipart (~> 1.0)
|
||||
faraday-net_http (~> 1.0)
|
||||
faraday-net_http_persistent (~> 1.0)
|
||||
faraday-patron (~> 1.0)
|
||||
faraday-rack (~> 1.0)
|
||||
faraday-retry (~> 1.0)
|
||||
faraday (2.7.1)
|
||||
faraday-net_http (>= 2.0, < 3.1)
|
||||
ruby2_keywords (>= 0.0.4)
|
||||
faraday-em_http (1.0.0)
|
||||
faraday-em_synchrony (1.0.0)
|
||||
faraday-excon (1.1.0)
|
||||
faraday-httpclient (1.0.1)
|
||||
faraday-multipart (1.0.3)
|
||||
multipart-post (>= 1.2, < 3)
|
||||
faraday-net_http (1.0.1)
|
||||
faraday-net_http_persistent (1.2.0)
|
||||
faraday-patron (1.0.0)
|
||||
faraday-rack (1.0.0)
|
||||
faraday-retry (1.0.3)
|
||||
faraday-net_http (3.0.2)
|
||||
ffi (1.15.5)
|
||||
forwardable-extended (2.6.0)
|
||||
gemoji (3.0.1)
|
||||
github-pages (226)
|
||||
github-pages (227)
|
||||
github-pages-health-check (= 1.17.9)
|
||||
jekyll (= 3.9.2)
|
||||
jekyll-avatar (= 0.7.0)
|
||||
@ -93,7 +74,7 @@ GEM
|
||||
liquid (= 4.0.3)
|
||||
mercenary (~> 0.3)
|
||||
minima (= 2.5.1)
|
||||
nokogiri (>= 1.13.4, < 2.0)
|
||||
nokogiri (>= 1.13.6, < 2.0)
|
||||
rouge (= 3.26.0)
|
||||
terminal-table (~> 1.4)
|
||||
github-pages-health-check (1.17.9)
|
||||
@ -102,7 +83,7 @@ GEM
|
||||
octokit (~> 4.0)
|
||||
public_suffix (>= 3.0, < 5.0)
|
||||
typhoeus (~> 1.3)
|
||||
html-pipeline (2.14.1)
|
||||
html-pipeline (2.14.3)
|
||||
activesupport (>= 2)
|
||||
nokogiri (>= 1.4)
|
||||
http_parser.rb (0.8.0)
|
||||
@ -230,19 +211,18 @@ GEM
|
||||
jekyll (>= 3.5, < 5.0)
|
||||
jekyll-feed (~> 0.9)
|
||||
jekyll-seo-tag (~> 2.1)
|
||||
minitest (5.15.0)
|
||||
multipart-post (2.1.1)
|
||||
nokogiri (1.13.4)
|
||||
minitest (5.16.3)
|
||||
nokogiri (1.13.9)
|
||||
mini_portile2 (~> 2.8.0)
|
||||
racc (~> 1.4)
|
||||
octokit (4.22.0)
|
||||
faraday (>= 0.9)
|
||||
sawyer (~> 0.8.0, >= 0.5.3)
|
||||
octokit (4.25.1)
|
||||
faraday (>= 1, < 3)
|
||||
sawyer (~> 0.9)
|
||||
pathutil (0.16.2)
|
||||
forwardable-extended (~> 2.6)
|
||||
public_suffix (4.0.7)
|
||||
racc (1.6.0)
|
||||
rb-fsevent (0.11.1)
|
||||
rb-fsevent (0.11.2)
|
||||
rb-inotify (0.10.1)
|
||||
ffi (~> 1.0)
|
||||
rexml (3.2.5)
|
||||
@ -255,9 +235,9 @@ GEM
|
||||
sass-listen (4.0.0)
|
||||
rb-fsevent (~> 0.9, >= 0.9.4)
|
||||
rb-inotify (~> 0.9, >= 0.9.7)
|
||||
sawyer (0.8.2)
|
||||
sawyer (0.9.2)
|
||||
addressable (>= 2.3.5)
|
||||
faraday (> 0.8, < 2.0)
|
||||
faraday (>= 0.17.3, < 3)
|
||||
simpleidn (0.2.1)
|
||||
unf (~> 0.1.4)
|
||||
terminal-table (1.8.0)
|
||||
@ -265,13 +245,13 @@ GEM
|
||||
thread_safe (0.3.6)
|
||||
typhoeus (1.4.0)
|
||||
ethon (>= 0.9.0)
|
||||
tzinfo (1.2.9)
|
||||
tzinfo (1.2.10)
|
||||
thread_safe (~> 0.1)
|
||||
unf (0.1.4)
|
||||
unf_ext
|
||||
unf_ext (0.0.8.1)
|
||||
unf_ext (0.0.8.2)
|
||||
unicode-display_width (1.8.0)
|
||||
zeitwerk (2.5.4)
|
||||
zeitwerk (2.6.6)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
@ -2,7 +2,7 @@ repository: pmd/pmd
|
||||
|
||||
pmd:
|
||||
version: 7.0.0-SNAPSHOT
|
||||
previous_version: 6.45.0
|
||||
previous_version: 6.51.0
|
||||
date: ??-?????-2022
|
||||
release_type: major
|
||||
|
||||
|
@ -23,7 +23,7 @@ entries:
|
||||
output: web, pdf
|
||||
type: homepage
|
||||
- title: Release notes
|
||||
url: /pmd_release_notes.html
|
||||
url: /pmd_release_notes7.html
|
||||
output: web, pdf
|
||||
- title: PMD 7.0.0 development
|
||||
url: /pmd_next_major_development.html
|
||||
@ -58,6 +58,9 @@ entries:
|
||||
- title: PMD Report formats
|
||||
url: /pmd_userdocs_report_formats.html
|
||||
output: web, pdf
|
||||
- title: 3rd party rulesets
|
||||
output: web, pdf
|
||||
url: /pmd_userdocs_3rdpartyrulesets.html
|
||||
- title: null
|
||||
output: web, pdf
|
||||
subfolders:
|
||||
@ -244,6 +247,21 @@ entries:
|
||||
- title: Security
|
||||
output: web, pdf
|
||||
url: /pmd_rules_jsp_security.html
|
||||
- title: null
|
||||
output: web, pdf
|
||||
subfolders:
|
||||
- title: Kotlin Rules
|
||||
output: web, pdf
|
||||
subfolderitems:
|
||||
- title: Index
|
||||
output: web, pdf
|
||||
url: /pmd_rules_kotlin.html
|
||||
- title: Best Practices
|
||||
output: web, pdf
|
||||
url: /pmd_rules_kotlin_bestpractices.html
|
||||
- title: Error Prone
|
||||
output: web, pdf
|
||||
url: /pmd_rules_kotlin_errorprone.html
|
||||
- title: null
|
||||
output: web, pdf
|
||||
subfolders:
|
||||
@ -301,6 +319,15 @@ entries:
|
||||
- title: Security
|
||||
output: web, pdf
|
||||
url: /pmd_rules_vf_security.html
|
||||
- title: null
|
||||
output: web, pdf
|
||||
subfolders:
|
||||
- title: Scala Rules
|
||||
output: web, pdf
|
||||
subfolderitems:
|
||||
- title: Index
|
||||
output: web, pdf
|
||||
url: /pmd_rules_scala.html
|
||||
- title: null
|
||||
output: web, pdf
|
||||
subfolders:
|
||||
@ -334,6 +361,15 @@ entries:
|
||||
- title: Error Prone
|
||||
output: web, pdf
|
||||
url: /pmd_rules_vm_errorprone.html
|
||||
- title: null
|
||||
output: web, pdf
|
||||
subfolders:
|
||||
- title: WSDL Rules
|
||||
output: web, pdf
|
||||
subfolderitems:
|
||||
- title: Index
|
||||
output: web, pdf
|
||||
url: /pmd_rules_wsdl.html
|
||||
- title: null
|
||||
output: web, pdf
|
||||
subfolders:
|
||||
@ -367,21 +403,15 @@ entries:
|
||||
- title: Apex
|
||||
url: /pmd_languages_apex.html
|
||||
output: web, pdf
|
||||
- title: null
|
||||
- title: Java
|
||||
url: /pmd_languages_java.html
|
||||
output: web, pdf
|
||||
subfolders:
|
||||
- title: Java
|
||||
output: web, pdf
|
||||
subfolderitems:
|
||||
- title: Java Support
|
||||
url: /pmd_languages_java.html
|
||||
output: web, pdf
|
||||
- title: Java Versions
|
||||
url: /pmd_languages_java_versions.html
|
||||
output: web, pdf
|
||||
- title: JSP
|
||||
url: /pmd_languages_jsp.html
|
||||
output: web, pdf
|
||||
- title: Kotlin
|
||||
url: /pmd_languages_kotlin.html
|
||||
output: web, pdf
|
||||
- title: PLSQL
|
||||
url: /pmd_languages_plsql.html
|
||||
output: web, pdf
|
||||
@ -394,6 +424,9 @@ entries:
|
||||
- title: HTML
|
||||
url: /pmd_languages_html.html
|
||||
output: web, pdf
|
||||
- title: Gherkin
|
||||
url: /pmd_languages_gherkin.html
|
||||
output: web, pdf
|
||||
- title: Developer Documentation
|
||||
output: web, pdf
|
||||
folderitems:
|
||||
@ -481,6 +514,9 @@ entries:
|
||||
- title: Old release notes
|
||||
url: /pmd_release_notes_old.html
|
||||
output: web, pdf
|
||||
- title: Decisions
|
||||
url: /pmd_projectdocs_decisions.html
|
||||
output: web, pdf
|
||||
- title: null
|
||||
output: web, pdf
|
||||
subfolders:
|
||||
|
54
docs/_includes/cli_example.html
Normal file
54
docs/_includes/cli_example.html
Normal file
@ -0,0 +1,54 @@
|
||||
{% assign linux_cmd_blob = '' %}
|
||||
{% assign linux_split_cmds = include.linux | newline_to_br | strip_newlines | split: '<br />' %}
|
||||
{% assign raw_output = false %}
|
||||
{% for linux_raw_cmd in linux_split_cmds %}
|
||||
{% assign linux_cmd = linux_raw_cmd | strip | split: ' ' | first %}
|
||||
{% assign linux_tail = linux_raw_cmd | strip | remove_first: linux_cmd %}
|
||||
{% if linux_cmd == nil %}
|
||||
{% assign raw_output = true %}
|
||||
{% endif %}
|
||||
{% if raw_output %}
|
||||
{% capture linux_cmd_blob %}{{linux_cmd_blob}}{{linux_cmd}}{{linux_tail}}
|
||||
{% endcapture %}
|
||||
{% else %}
|
||||
{% capture linux_cmd_blob %}{{linux_cmd_blob}}<span class="gp">~ $ </span><span class="s2">{{linux_cmd}}</span>{{linux_tail}}
|
||||
{% endcapture %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
{% assign windows_cmd_blob = '' %}
|
||||
{% assign windows_split_cmds = include.windows | newline_to_br | strip_newlines | split: '<br />' %}
|
||||
{% assign raw_output = false %}
|
||||
{% for windows_raw_cmd in windows_split_cmds %}
|
||||
{% assign windows_cmd = windows_raw_cmd | strip | split: ' ' | first %}
|
||||
{% assign windows_tail = windows_raw_cmd | strip | remove_first: windows_cmd %}
|
||||
{% if windows_cmd == nil %}
|
||||
{% assign raw_output = true %}
|
||||
{% endif %}
|
||||
{% if raw_output == true %}
|
||||
{% capture windows_cmd_blob %}{{windows_cmd_blob}}{{windows_cmd}}{{windows_tail}}
|
||||
{% endcapture %}
|
||||
{% else %}
|
||||
{% capture windows_cmd_blob %}{{windows_cmd_blob}}<span class="gp">C:\> </span><span class="s2">{{windows_cmd}}</span>{{windows_tail}}
|
||||
{% endcapture %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
<div class="text-left">
|
||||
<ul class="nav nav-tabs" role="tablist">
|
||||
<li class="nav-item" role="presentation">
|
||||
<a class="nav-link active" id="linux-tab-{{include.id}}" data-toggle="tab" href="#linux-{{include.id}}" role="tab" aria-controls="linux" aria-selected="true">Linux / macOS</a>
|
||||
</li>
|
||||
<li class="nav-item" role="presentation">
|
||||
<a class="nav-link" id="windows-tab-{{include.id}}" data-toggle="tab" href="#windows-{{include.id}}" role="tab" aria-controls="windows" aria-selected="false">Windows</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div class="tab-content border">
|
||||
<div class="tab-pane fade show active" id="linux-{{include.id}}" role="tabpanel" aria-labelledby="linux-tab">
|
||||
<figure class="highlight"><pre><code class="language-bash" data-lang="bash">{{linux_cmd_blob}}</code></pre></figure>
|
||||
</div>
|
||||
<div class="tab-pane fade" id="windows-{{include.id}}" role="tabpanel" aria-labelledby="windows-tab">
|
||||
<figure class="highlight"><pre><code class="language-bash" data-lang="bash">{{windows_cmd_blob}}</code></pre></figure>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
@ -99,10 +99,10 @@ class JDocNamespaceDeclaration < Liquid::Tag
|
||||
private
|
||||
|
||||
JDOC_NAMESPACE_MAP = "jdoc_nspaces"
|
||||
RESERVED_NSPACES = ['apex', 'core', 'cpp', 'cs', 'dart', 'dist', 'doc', 'fortran', 'go', 'groovy', 'java',
|
||||
RESERVED_NSPACES = ['ant', 'apex', 'core', 'cpp', 'cs', 'dart', 'dist', 'doc', 'fortran', 'go', 'groovy', 'java',
|
||||
'javascript', 'jsp',
|
||||
'kotlin', 'lua', 'matlab', 'objectivec', 'perl', 'php', 'plsql', 'python', 'ruby', 'scala', 'swift',
|
||||
'test', 'ui',
|
||||
'test', 'test-schema', 'ui',
|
||||
'modelica', 'visualforce', 'vm', 'xml'].flat_map {|m| [m, "pmd-" + m]}
|
||||
|
||||
def self.make_base_namespaces
|
||||
|
@ -7,7 +7,7 @@ summary: >
|
||||
Welcome to the documentation site for PMD and CPD! <br/><br/>
|
||||
|
||||
|
||||
last_updated: August 2017
|
||||
last_updated: October 2022
|
||||
author: Jeff Jensen <jjensen@apache.org>, Andreas Dangel <andreas.dangel@adangel.org>,
|
||||
Clément Fournier <clement.fournier76@gmail.com>
|
||||
|
||||
@ -26,7 +26,7 @@ additional_js:
|
||||
|
||||
**PMD** is a static source code analyzer. It finds common programming flaws like
|
||||
unused variables, empty catch blocks, unnecessary object creation, and
|
||||
so forth. It's mainly concerned with **Java and Apex**, but **supports six other
|
||||
so forth. It's mainly concerned with **Java and Apex**, but **supports 14 other
|
||||
languages**.
|
||||
|
||||
PMD features many **built-in checks** (in PMD lingo, *rules*), which are documented
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
title: PMD Release Notes
|
||||
permalink: pmd_release_notes.html
|
||||
permalink: pmd_release_notes7.html
|
||||
keywords: changelog, release notes
|
||||
---
|
||||
|
||||
@ -19,15 +19,71 @@ This is a {{ site.pmd.release_type }} release.
|
||||
|
||||
### New and noteworthy
|
||||
|
||||
#### CLI improvements
|
||||
#### Revamped Command Line Interface
|
||||
|
||||
The PMD CLI has been enhanced with a progress bar, which interactively displays the
|
||||
PMD now ships with a unified Command Line Interface for both Linux/Unix and Windows. Instead of having a collection of scripts
|
||||
for the different utilities shipped with PMD, a single script `pmd` (`pmd.bat` for Windows) can now launch all
|
||||
utilities using subcommands, e.g. `pmd check`, `pmd designer`. All commands and options are thoroughly documented in the help,
|
||||
with full color support where available. Moreover, efforts were made to provide consistency in the usage of all PMD utilities.
|
||||
|
||||
```shell
|
||||
$ Usage: pmd [-hV] [COMMAND]
|
||||
-h, --help Show this help message and exit.
|
||||
-V, --version Print version information and exit.
|
||||
Commands:
|
||||
check The PMD standard source code analyzer
|
||||
cpd Copy/Paste Detector - find duplicate code
|
||||
designer The PMD visual rule designer
|
||||
cpd-gui GUI for the Copy/Paste Detector
|
||||
Warning: May not support the full CPD feature set
|
||||
ast-dump Experimental: dumps the AST of parsing source code
|
||||
Exit Codes:
|
||||
0 Succesful analysis, no violations found
|
||||
1 An unexpected error occurred during execution
|
||||
2 Usage error, please refer to the command help
|
||||
4 Successful analysis, at least 1 violation found
|
||||
```
|
||||
|
||||
For instance, where you previously would have run
|
||||
```shell
|
||||
run.sh pmd -d src -R ruleset.xml
|
||||
```
|
||||
you should now use
|
||||
```shell
|
||||
pmd check -d src -R ruleset.xml
|
||||
```
|
||||
or even better, omit using `-d` / `--dir` and simply pass the sources at the end of the parameter list
|
||||
|
||||
```shell
|
||||
pmd check -R ruleset.xml src
|
||||
```
|
||||
|
||||
Multiple source directories can passed, such as:
|
||||
```shell
|
||||
pmd check -R ruleset.xml src/main/java src/test/java
|
||||
```
|
||||
|
||||
And the exact same applies to CPD:
|
||||
```shell
|
||||
pmd cpd --minimum-tokens 100 src/main/java
|
||||
```
|
||||
|
||||
Additionally, the CLI for the `check` command has been enhanced with a progress bar, which interactively displays the
|
||||
current progress of the analysis.
|
||||
|
||||
TODO screenshot (take it right before releasing, because other changes to the CLI will occur until then)
|
||||
|
||||
This can be disabled with the `--no-progress` flag.
|
||||
|
||||
|
||||
Finally, we now provide a completion script for Bash/Zsh to further help daily usage.
|
||||
This script can be found under `shell/pmd-completion.sh` in the binary distribution.
|
||||
To use it, edit your `~/.bashrc` / `~/.zshrc` file and add the following line:
|
||||
|
||||
```
|
||||
source *path_to_pmd*/shell/pmd-completion.sh
|
||||
```
|
||||
|
||||
#### Full Antlr support
|
||||
|
||||
Languages backed by an Antlr grammar are now fully supported. This means, it's now possible not only to use Antlr grammars for CPD,
|
||||
@ -49,6 +105,26 @@ Given the full Antlr support, PMD now fully supports Swift. We are pleased to an
|
||||
* {% rule "swift/bestpractices/UnavailableFunction" %} (`swift-bestpractices`) flags any function throwing a `fatalError` not marked as
|
||||
`@available(*, unavailable)` to ensure no calls are actually performed in the codebase.
|
||||
|
||||
Contributors: [@lsoncini](https://github.com/lsoncini), [@matifraga](https://github.com/matifraga), [@tomidelucca](https://github.com/tomidelucca)
|
||||
|
||||
#### Kotlin support (experimental)
|
||||
|
||||
PMD now supports Kotlin as an additional language for analyzing source code. It is based on
|
||||
the official kotlin Antlr grammar. Java-based rules and XPath-based rules are supported.
|
||||
|
||||
Kotlin support has **experimental** stability level, meaning no compatibility should
|
||||
be expected between even incremental releases. Any functionality can be added, removed or changed without
|
||||
warning.
|
||||
|
||||
We are shipping the following rules:
|
||||
|
||||
* {% rule kotlin/bestpractices/FunctionNameTooShort %} (`kotlin-bestpractices`) finds functions with a too short name.
|
||||
* {% rule kotlin/errorprone/OverrideBothEqualsAndHashcode %} (`kotlin-errorprone`) finds classes with only either `equals`
|
||||
or `hashCode` overridden, but not both. This leads to unexpected behavior once instances of such classes
|
||||
are used in collections (Lists, HashMaps, ...).
|
||||
|
||||
Contributors: [@jborgers](https://github.com/jborgers), [@stokpop](https://github.com/stokpop)
|
||||
|
||||
#### XPath 3.1 support
|
||||
|
||||
Support for XPath versions 1.0, 1.0-compatibility was removed, support for XPath 2.0 is deprecated. The default (and only) supported XPath version is now XPath 3.1. This version of the XPath language is mostly identical to XPath 2.0. Notable changes:
|
||||
@ -161,14 +237,20 @@ The following previously deprecated rules have been finally removed:
|
||||
|
||||
### Fixed Issues
|
||||
|
||||
* miscellaneous
|
||||
* miscellaneous
|
||||
* [#896](https://github.com/pmd/pmd/issues/896): \[all] Use slf4j
|
||||
* [#1451](https://github.com/pmd/pmd/issues/1451): \[core] RulesetFactoryCompatibility stores the whole ruleset file in memory as a string
|
||||
* cli
|
||||
* ant
|
||||
* [#4080](https://github.com/pmd/pmd/issues/4080): \[ant] Split off Ant integration into a new submodule
|
||||
* core
|
||||
* [#2234](https://github.com/pmd/pmd/issues/2234): \[core] Consolidate PMD CLI into a single command
|
||||
* [#4035](https://github.com/pmd/pmd/issues/4035): \[core] ConcurrentModificationException in DefaultRuleViolationFactory
|
||||
* cli
|
||||
* [#3828](https://github.com/pmd/pmd/issues/3828): \[core] Progress reporting
|
||||
* apex-design
|
||||
* [#4079](https://github.com/pmd/pmd/issues/4079): \[cli] Split off CLI implementation into a pmd-cli submodule
|
||||
* apex-design
|
||||
* [#2667](https://github.com/pmd/pmd/issues/2667): \[apex] Integrate nawforce/ApexLink to build robust Unused rule
|
||||
* java-bestpractices
|
||||
* java-bestpractices
|
||||
* [#342](https://github.com/pmd/pmd/issues/342): \[java] AccessorMethodGeneration: Name clash with another public field not properly handled
|
||||
* [#755](https://github.com/pmd/pmd/issues/755): \[java] AccessorClassGeneration false positive for private constructors
|
||||
* [#770](https://github.com/pmd/pmd/issues/770): \[java] UnusedPrivateMethod yields false positive for counter-variant arguments
|
||||
@ -243,6 +325,8 @@ The following previously deprecated rules have been finally removed:
|
||||
* java-performance
|
||||
* [#1224](https://github.com/pmd/pmd/issues/1224): \[java] InefficientEmptyStringCheck false negative in anonymous class
|
||||
* [#2712](https://github.com/pmd/pmd/issues/2712): \[java] SimplifyStartsWith false-positive with AssertJ
|
||||
* kotlin
|
||||
* [#419](https://github.com/pmd/pmd/issues/419): \[kotlin] Add support for Kotlin
|
||||
|
||||
### API Changes
|
||||
|
||||
@ -260,6 +344,11 @@ The following previously deprecated rules have been finally removed:
|
||||
`net.sourceforge.pmd.lang.rule.xpath`, `net.sourceforge.pmd.lang.rule`, and various language-specific packages
|
||||
(which were made internal).
|
||||
|
||||
* The implementation of the Ant integration has been moved from the module `pmd-core` to a new module `pmd-ant`.
|
||||
This involves classes in package {% jdoc_package ant::ant %}. The ant CPDTask class `net.sourceforge.pmd.cpd.CPDTask`
|
||||
has been moved into the same package {% jdoc_package ant::ant %}. You'll need to update your taskdef entries in your
|
||||
build.xml files with the FQCN {% jdoc !!ant::ant.CPDTask %} if you use it anywhere.
|
||||
|
||||
#### Metrics framework
|
||||
|
||||
The metrics framework has been made simpler and more general.
|
||||
|
@ -246,6 +246,123 @@ 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.51.0
|
||||
|
||||
No changes.
|
||||
|
||||
#### 6.50.0
|
||||
|
||||
##### CPD CLI
|
||||
|
||||
* CPD now supports the `--ignore-literal-sequences` argument when analyzing Lua code.
|
||||
|
||||
#### 6.49.0
|
||||
|
||||
##### Deprecated API
|
||||
|
||||
* In order to reduce the dependency on Apex Jorje classes, the following methods have been deprecated.
|
||||
These methods all leaked internal Jorje enums. These enums have been replaced now by enums the
|
||||
PMD's AST package.
|
||||
* {% jdoc !!apex::lang.apex.ast.ASTAssignmentExpression#getOperator() %}
|
||||
* {% jdoc !!apex::lang.apex.ast.ASTBinaryExpression#getOperator() %}
|
||||
* {% jdoc !!apex::lang.apex.ast.ASTBooleanExpression#getOperator() %}
|
||||
* {% jdoc !!apex::lang.apex.ast.ASTPostfixExpression#getOperator() %}
|
||||
* {% jdoc !!apex::lang.apex.ast.ASTPrefixExpression#getOperator() %}
|
||||
|
||||
All these classes have now a new `getOp()` method. Existing code should be refactored to use this method instead.
|
||||
It returns the new enums, like {% jdoc apex::lang.apex.ast.AssignmentOperator %}, and avoids
|
||||
the dependency to Jorje.
|
||||
|
||||
#### 6.48.0
|
||||
|
||||
##### CPD CLI
|
||||
|
||||
* CPD has a new CLI option `--debug`. This option has the same behavior as in PMD. It enables more verbose
|
||||
logging output.
|
||||
|
||||
##### Rule Test Framework
|
||||
|
||||
* The module "pmd-test", which contains support classes to write rule tests, now **requires Java 8**. If you depend on
|
||||
this module for testing your own custom rules, you'll need to make sure to use at least Java 8.
|
||||
* The new module "pmd-test-schema" contains now the XSD schema and the code to parse the rule test XML files. The
|
||||
schema has been extracted in order to easily share it with other tools like the Rule Designer or IDE plugins.
|
||||
* Test schema changes:
|
||||
* The attribute `isRegressionTest` of `test-code` is deprecated. The new
|
||||
attribute `disabled` should be used instead for defining whether a rule test should be skipped or not.
|
||||
* The attributes `reinitializeRule` and `useAuxClasspath` of `test-code` are deprecated and assumed true.
|
||||
They will not be replaced.
|
||||
* The new attribute `focused` of `test-code` allows disabling all tests except the focused one temporarily.
|
||||
* More information about the rule test framework can be found in the documentation:
|
||||
[Testing your rules](pmd_userdocs_extending_testing.html)
|
||||
|
||||
##### Deprecated API
|
||||
|
||||
* The experimental Java AST class {% jdoc java::lang.java.ast.ASTGuardedPattern %} has been deprecated and
|
||||
will be removed. It was introduced for Java 17 and Java 18 Preview as part of pattern matching for switch,
|
||||
but it is no longer supported with Java 19 Preview.
|
||||
* The interface {% jdoc core::cpd.renderer.CPDRenderer %} is deprecated. For custom CPD renderers
|
||||
the new interface {% jdoc core::cpd.renderer.CPDReportRenderer %} should be used.
|
||||
* The class {% jdoc test::testframework.TestDescriptor %} is deprecated, replaced with {% jdoc test-schema::test.schema.RuleTestDescriptor %}.
|
||||
* Many methods of {% jdoc test::testframework.RuleTst %} have been deprecated as internal API.
|
||||
|
||||
##### Experimental APIs
|
||||
|
||||
* To support the Java preview language features "Pattern Matching for Switch" and "Record Patterns", the following
|
||||
AST nodes have been introduced as experimental:
|
||||
* {% jdoc java::lang.java.ast.ASTSwitchGuard %}
|
||||
* {% jdoc java::lang.java.ast.ASTRecordPattern %}
|
||||
* {% jdoc java::lang.java.ast.ASTComponentPatternList %}
|
||||
|
||||
##### 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::cpd.CPDConfiguration#setRenderer(net.sourceforge.pmd.cpd.Renderer) %}
|
||||
* {%jdoc !!core::cpd.CPDConfiguration#setCPDRenderer(net.sourceforge.pmd.cpd.renderer.CPDRenderer) %}
|
||||
* {%jdoc !!core::cpd.CPDConfiguration#getRenderer() %}
|
||||
* {%jdoc !!core::cpd.CPDConfiguration#getCPDRenderer() %}
|
||||
* {%jdoc !!core::cpd.CPDConfiguration#getRendererFromString(java.lang.String,java.lang.String) %}
|
||||
* {%jdoc !!core::cpd.CPDConfiguration#getCPDRendererFromString(java.lang.String,java.lang.String) %}
|
||||
* {%jdoc core::cpd.renderer.CPDRendererAdapter %}
|
||||
|
||||
#### 6.47.0
|
||||
|
||||
No changes.
|
||||
|
||||
#### 6.46.0
|
||||
|
||||
##### Deprecated ruleset references
|
||||
|
||||
Ruleset references with the following formats are now deprecated and will produce a warning
|
||||
when used on the CLI or in a ruleset XML file:
|
||||
- `<lang-name>-<ruleset-name>`, eg `java-basic`, which resolves to `rulesets/java/basic.xml`
|
||||
- the internal release number, eg `600`, which resolves to `rulesets/releases/600.xml`
|
||||
|
||||
Use the explicit forms of these references to be compatible with PMD 7.
|
||||
|
||||
##### Deprecated API
|
||||
|
||||
- {% jdoc core::RuleSetReferenceId#toString() %} is now deprecated. The format of this
|
||||
method will remain the same until PMD 7. The deprecation is intended to steer users
|
||||
away from relying on this format, as it may be changed in PMD 7.
|
||||
- {% jdoc core::PMDConfiguration#getInputPaths() %} and
|
||||
{% jdoc core::PMDConfiguration#setInputPaths(java.lang.String) %} are now deprecated.
|
||||
A new set of methods have been added, which use lists and do not rely on comma splitting.
|
||||
|
||||
##### 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::cpd.CPDCommandLineInterface %} has been internalized. In order to execute CPD either
|
||||
{% jdoc !!core::cpd.CPD#run(java.lang.String...) %} or {% jdoc !!core::cpd.CPD#main(java.lang.String[]) %}
|
||||
should be used.
|
||||
- Several members of {% jdoc test::cli.BaseCPDCLITest %} have been deprecated with replacements.
|
||||
- The methods {% jdoc !!core::ant.Formatter#start(java.lang.String) %},
|
||||
{% jdoc !!core::ant.Formatter#end(net.sourceforge.pmd.Report) %}, {% jdoc !!core::ant.Formatter#getRenderer() %},
|
||||
and {% jdoc !!core::ant.Formatter#isNoOutputSupplied() %} have been internalized.
|
||||
|
||||
#### 6.45.0
|
||||
|
||||
##### Experimental APIs
|
||||
@ -1468,18 +1585,18 @@ large projects, with many duplications, it was causing `OutOfMemoryError`s (see
|
||||
* The Java rules NcssConstructorCount (java-design), NcssMethodCount (java-design), and NcssTypeCount (java-design) have been
|
||||
deprecated. They will be replaced by the new rule {% rule java/design/NcssCount %} in the category `design`.
|
||||
|
||||
* The Java rule `LooseCoupling` in ruleset `java-typeresolution` is deprecated. Use the rule with the same name from category `bestpractices` instead.
|
||||
* The Java rule `LooseCoupling` in ruleset `java-typeresolution` is deprecated. Use the rule with the same name from category `bestpractices` instead.
|
||||
|
||||
* The Java rule `CloneMethodMustImplementCloneable` in ruleset `java-typeresolution` is deprecated. Use the rule with the same name from category `errorprone` instead.
|
||||
* The Java rule `CloneMethodMustImplementCloneable` in ruleset `java-typeresolution` is deprecated. Use the rule with the same name from category `errorprone` instead.
|
||||
|
||||
* The Java rule `UnusedImports` in ruleset `java-typeresolution` is deprecated. Use the rule with
|
||||
* The Java rule `UnusedImports` in ruleset `java-typeresolution` is deprecated. Use the rule with
|
||||
the same name from category `bestpractices` instead.
|
||||
|
||||
* The Java rule `SignatureDeclareThrowsException` in ruleset `java-typeresolution` is deprecated. Use the rule with the same name from category `design` instead.
|
||||
* The Java rule `SignatureDeclareThrowsException` in ruleset `java-typeresolution` is deprecated. Use the rule with the same name from category `design` instead.
|
||||
|
||||
* The Java rule `EmptyStaticInitializer` in ruleset `java-empty` is deprecated. Use the rule {% rule java/errorprone/EmptyInitializer %}, which covers both static and non-static empty initializers.`
|
||||
* The Java rule `EmptyStaticInitializer` in ruleset `java-empty` is deprecated. Use the rule {% rule java/errorprone/EmptyInitializer %}, which covers both static and non-static empty initializers.`
|
||||
|
||||
* The Java rules `GuardDebugLogging` (ruleset `java-logging-jakarta-commons`) and `GuardLogStatementJavaUtil`
|
||||
* The Java rules `GuardDebugLogging` (ruleset `java-logging-jakarta-commons`) and `GuardLogStatementJavaUtil`
|
||||
(ruleset `java-logging-java`) have been deprecated. Use the rule {% rule java/bestpractices/GuardLogStatement %}, which covers all cases regardless of the logging framework.
|
||||
|
||||
* The Java rule "java/multithreading/UnsynchronizedStaticDateFormatter" has been deprecated and
|
||||
@ -1490,20 +1607,20 @@ large projects, with many duplications, it was causing `OutOfMemoryError`s (see
|
||||
and [`PositionLiteralsFirstInCaseInsensitiveComparisons`](https://pmd.github.io/pmd-6.29.0/pmd_rules_java_bestpractices.html#positionliteralsfirstincaseinsensitivecomparisons) (ruleset `java-bestpractices`)
|
||||
have been deprecated in favor of the new rule {% rule "java/bestpractices/LiteralsFirstInComparisons" %}.
|
||||
|
||||
* The Java rule [`AvoidFinalLocalVariable`](https://pmd.github.io/pmd-6.16.0/pmd_rules_java_codestyle.html#avoidfinallocalvariable) (`java-codestyle`) has been deprecated
|
||||
* The Java rule [`AvoidFinalLocalVariable`](https://pmd.github.io/pmd-6.16.0/pmd_rules_java_codestyle.html#avoidfinallocalvariable) (`java-codestyle`) has been deprecated
|
||||
and will be removed with PMD 7.0.0. The rule is controversial and also contradicts other existing
|
||||
rules such as [`LocalVariableCouldBeFinal`](https://pmd.github.io/pmd-6.16.0/pmd_rules_java_codestyle.html#localvariablecouldbefinal). If the goal is to avoid defining
|
||||
constants in a scope smaller than the class, then the rule [`AvoidDuplicateLiterals`](https://pmd.github.io/pmd-6.16.0/pmd_rules_java_errorprone.html#avoidduplicateliterals)
|
||||
should be used instead.
|
||||
|
||||
* The Apex rule [`VariableNamingConventions`](https://pmd.github.io/pmd-6.15.0/pmd_rules_apex_codestyle.html#variablenamingconventions) (`apex-codestyle`) has been deprecated and
|
||||
* The Apex rule [`VariableNamingConventions`](https://pmd.github.io/pmd-6.15.0/pmd_rules_apex_codestyle.html#variablenamingconventions) (`apex-codestyle`) has been deprecated and
|
||||
will be removed with PMD 7.0.0. The rule is replaced by the more general rules
|
||||
[`FieldNamingConventions`](https://pmd.github.io/pmd-6.15.0/pmd_rules_apex_codestyle.html#fieldnamingconventions),
|
||||
[`FormalParameterNamingConventions`](https://pmd.github.io/pmd-6.15.0/pmd_rules_apex_codestyle.html#formalparameternamingconventions),
|
||||
[`LocalVariableNamingConventions`](https://pmd.github.io/pmd-6.15.0/pmd_rules_apex_codestyle.html#localvariablenamingconventions), and
|
||||
[`PropertyNamingConventions`](https://pmd.github.io/pmd-6.15.0/pmd_rules_apex_codestyle.html#propertynamingconventions).
|
||||
|
||||
* The Java rule [`LoggerIsNotStaticFinal`](https://pmd.github.io/pmd-6.15.0/pmd_rules_java_errorprone.html#loggerisnotstaticfinal) (`java-errorprone`) has been deprecated
|
||||
* The Java rule [`LoggerIsNotStaticFinal`](https://pmd.github.io/pmd-6.15.0/pmd_rules_java_errorprone.html#loggerisnotstaticfinal) (`java-errorprone`) has been deprecated
|
||||
and will be removed with PMD 7.0.0. The rule is replaced by [`ProperLogger`](https://pmd.github.io/pmd-6.15.0/pmd_rules_java_errorprone.html#properlogger).
|
||||
|
||||
* The Java rule [`DataflowAnomalyAnalysis`](https://pmd.github.io/pmd-6.27.0/pmd_rules_java_errorprone.html#dataflowanomalyanalysis) (`java-errorprone`)
|
||||
@ -1516,7 +1633,7 @@ large projects, with many duplications, it was causing `OutOfMemoryError`s (see
|
||||
* The Java rule `CloneThrowsCloneNotSupportedException` (java-errorprone) has been deprecated without
|
||||
replacement.
|
||||
|
||||
* The following Java rules are deprecated and removed from the quickstart ruleset,
|
||||
* The following Java rules are deprecated and removed from the quickstart ruleset,
|
||||
as the new rule {% rule java/bestpractices/SimplifiableTestAssertion %} merges
|
||||
their functionality:
|
||||
* `UseAssertEqualsInsteadOfAssertTrue` (java-bestpractices)
|
||||
@ -1529,7 +1646,7 @@ large projects, with many duplications, it was causing `OutOfMemoryError`s (see
|
||||
the quickstart ruleset, as the new rule {% rule java/errorprone/ReturnEmptyCollectionRatherThanNull %}
|
||||
supersedes it.
|
||||
|
||||
* The following Java rules are deprecated and removed from the quickstart ruleset,
|
||||
* The following Java rules are deprecated and removed from the quickstart ruleset,
|
||||
as the new rule {% rule java/bestpractices/PrimitiveWrapperInstantiation %} merges
|
||||
their functionality:
|
||||
* java/performance/BooleanInstantiation
|
||||
@ -1543,3 +1660,17 @@ large projects, with many duplications, it was causing `OutOfMemoryError`s (see
|
||||
as it finds only contrived cases of creating a primitive wrapper and unboxing it explicitly
|
||||
in the same expression. In PMD 7 this and more cases will be covered by a
|
||||
new rule `UnnecessaryBoxing`.
|
||||
|
||||
* Since 6.46.0: The following Java rules are deprecated and removed from the quickstart ruleset, as the new rule
|
||||
{% rule java/codestyle/EmptyControlStatement %} merges their functionality:
|
||||
* {% rule java/errorprone/EmptyFinallyBlock %}
|
||||
* {% rule java/errorprone/EmptyIfStmt %}
|
||||
* {% rule java/errorprone/EmptyInitializer %}
|
||||
* {% rule java/errorprone/EmptyStatementBlock %}
|
||||
* {% rule java/errorprone/EmptySwitchStatements %}
|
||||
* {% rule java/errorprone/EmptySynchronizedBlock %}
|
||||
* {% rule java/errorprone/EmptyTryBlock %}
|
||||
* {% rule java/errorprone/EmptyWhileStmt %}
|
||||
|
||||
* Since 6.46.0: The Java rule {% rule java/errorprone/EmptyStatementNotInLoop %} is deprecated and removed from the quickstart
|
||||
ruleset. Use the new rule {% rule java/codestyle/UnnecessarySemicolon %} instead.
|
||||
|
@ -9,37 +9,50 @@ permalink: pmd_devdocs_experimental_ast_dump.html
|
||||
## Command line usage
|
||||
|
||||
```shell
|
||||
$ run.sh ast-dump --help
|
||||
Usage: ast-dump [options]
|
||||
Options:
|
||||
--encoding, -e
|
||||
Encoding of the source file.
|
||||
Default: UTF-8
|
||||
--file
|
||||
The file to dump
|
||||
--format, -f
|
||||
The output format.
|
||||
Default: xml
|
||||
--help, -h
|
||||
Display usage.
|
||||
--language, -l
|
||||
Specify the language to use.
|
||||
Default: java
|
||||
--read-stdin, -i
|
||||
Read source from standard input
|
||||
Default: false
|
||||
-P
|
||||
Properties for the renderer.
|
||||
Syntax: -Pkey=value
|
||||
Default: {}
|
||||
|
||||
Available languages: apex ecmascript java jsp modelica plsql pom scala text vf vm wsdl xml xsl
|
||||
Available formats: xml XML format with the same structure as the one used in XPath
|
||||
+ Properties
|
||||
+ singleQuoteAttributes Use single quotes to delimit attribute values (default true)
|
||||
+ lineSeparator Line separator to use. The default is platform-specific. (default \n)
|
||||
+ renderProlog True to output a prolog (default true)
|
||||
+ renderCommonAttributes True to render attributes like BeginLine, EndLine, etc. (default false)
|
||||
$ pmd ast-dump --help
|
||||
Usage: pmd ast-dump [-Dhi] [-e=<encoding>] [-f=<format>] [--file=<file>]
|
||||
[-l=<language>] [-P=<String=String>]...
|
||||
Experimental: dumps the AST of parsing source code
|
||||
-D, -v, --debug, --verbose
|
||||
Debug mode.
|
||||
-e, --encoding=<encoding>
|
||||
Specifies the character set encoding of the source
|
||||
code files
|
||||
-f, --format=<format> The output format.
|
||||
Valid values: xml, text
|
||||
--file=<file> The file to parse and dump.
|
||||
-h, --help Show this help message and exit.
|
||||
-i, --read-stdin Read source from standard input.
|
||||
-l, --language=<language>
|
||||
The source code language.
|
||||
Valid values: apex, ecmascript, html, java, jsp,
|
||||
kotlin, modelica, plsql, pom, scala, swift, vf, vm,
|
||||
wsdl, xml, xsl
|
||||
-P=<String=String> Key-value pair defining a property for the report
|
||||
format.
|
||||
Supported values for each report format:
|
||||
xml:
|
||||
singleQuoteAttributes - Use single quotes to
|
||||
delimit attribute values
|
||||
Default: true
|
||||
lineSeparator - Line separator to use. The default
|
||||
is platform-specific. The values 'CR', 'CRLF',
|
||||
'LF', '\r', '\r\n' and '\n' can be used to
|
||||
represent a carriage return, line feed and their
|
||||
combination more easily.
|
||||
Default: \n
|
||||
renderProlog - True to output a prolog
|
||||
Default: true
|
||||
renderCommonAttributes - True to render attributes
|
||||
like BeginLine, EndLine, etc.
|
||||
Default: false
|
||||
text:
|
||||
onlyAsciiChars - Use only ASCII characters in the
|
||||
structure
|
||||
Default: false
|
||||
maxLevel - Max level on which to recurse. Negative
|
||||
means unbounded
|
||||
Default: -1
|
||||
```
|
||||
|
||||
## Example
|
||||
@ -50,12 +63,7 @@ public class Foo {
|
||||
int a;
|
||||
}
|
||||
|
||||
$ run.sh ast-dump --format xml --language java --file Foo.java > Foo.xml
|
||||
-------------------------------------------------------------------------------
|
||||
This command line utility is experimental. It might change at any time without
|
||||
prior notice.
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
$ pmd ast-dump --format xml --language java --file Foo.java > Foo.xml
|
||||
$ cat Foo.xml
|
||||
<?xml version='1.0' encoding='UTF-8' ?>
|
||||
<CompilationUnit Image='' PackageName='' declarationsAreInDefaultPackage='true'>
|
||||
|
@ -3,17 +3,54 @@ title: Adding PMD support for a new ANTLR grammar based language
|
||||
short_title: Adding a new language with ANTLR
|
||||
tags: [devdocs, extending]
|
||||
summary: "How to add a new language to PMD using ANTLR grammar."
|
||||
last_updated: July 21, 2019
|
||||
last_updated: October 2021
|
||||
sidebar: pmd_sidebar
|
||||
permalink: pmd_devdocs_major_adding_new_language_antlr.html
|
||||
folder: pmd/devdocs
|
||||
|
||||
# needs to be changed to branch master instead of pmd/7.0.x
|
||||
#
|
||||
# needs to be changed to branch master instead of pmd/7.0.x once pmd7 is released
|
||||
# https://github.com/pmd/pmd/blob/pmd/7.0.x -> https://github.com/pmd/pmd/blob/master
|
||||
#
|
||||
---
|
||||
|
||||
{% include callout.html type="warning" content="
|
||||
|
||||
## 1. Start with a new sub-module.
|
||||
**Before you start...**<br><br>
|
||||
|
||||
This is really a big contribution and can't be done with a drive by contribution. It requires dedicated passion
|
||||
and long commitment to implement support for a new language.<br><br>
|
||||
|
||||
This step by step guide is just a small intro to get the basics started and it's also not necessarily up-to-date
|
||||
or complete and you have to be able to fill in the blanks.<br><br>
|
||||
|
||||
Currently the Antlr integration has some basic limitations compared to JavaCC: The output of the
|
||||
Antlr parser generator is not an abstract syntax tree (AST) but a parse tree. As such, a parse tree is
|
||||
much more fine-grained than what a typical JavaCC grammar will produce. This means that the
|
||||
parse tree is much deeper and contains nodes down to the different token types.<br><br>
|
||||
|
||||
The Antlr nodes themselves don't have any attributes because they are on the wrong abstraction level.
|
||||
As they don't have attributes, there are no attributes that can be used in XPath based rules.<br><br>
|
||||
|
||||
In order to overcome these limitations, one would need to implement a post-processing step that transforms
|
||||
a parse tree into an abstract syntax tree and introducing real nodes on a higher abstraction level. This
|
||||
step is **not** described in this guide.<br><br>
|
||||
|
||||
After the basic support for a language is there, there are lots of missing features left. Typical features
|
||||
that can greatly improve rule writing are: symbol table, type resolution, call/data flow analysis.<br><br>
|
||||
|
||||
Symbol table keeps track of variables and their usages. Type resolution tries to find the actual class type
|
||||
of each used type, following along method calls (including overloaded and overwritten methods), allowing
|
||||
to query sub types and type hierarchy. This requires additional configuration of an auxiliary classpath.
|
||||
Call and data flow analysis keep track of the data as it is moving through different execution paths
|
||||
a program has.<br><br>
|
||||
|
||||
These features are out of scope of this guide. Type resolution and data flow are features that
|
||||
definitely don't come for free. It is much effort and requires perseverance to implement.<br><br>
|
||||
|
||||
" %}
|
||||
|
||||
## 1. Start with a new sub-module
|
||||
* See pmd-swift for examples.
|
||||
|
||||
## 2. Implement an AST parser for your language
|
||||
@ -24,7 +61,7 @@ folder: pmd/devdocs
|
||||
|
||||
## 3. Create AST node classes
|
||||
* The individual AST nodes are generated, but you need to define the common interface for them.
|
||||
* You need a need to define the supertype interface for all nodes of the language. For that, we provide
|
||||
* You need to define the supertype interface for all nodes of the language. For that, we provide
|
||||
[`AntlrNode`](https://github.com/pmd/pmd/blob/pmd/7.0.x/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/antlr4/AntlrNode.java).
|
||||
* See [`SwiftNode`](https://github.com/pmd/pmd/blob/pmd/7.0.x/pmd-swift/src/main/java/net/sourceforge/pmd/lang/swift/ast/SwiftNode.java)
|
||||
as an example.
|
||||
@ -52,7 +89,7 @@ folder: pmd/devdocs
|
||||
## 4. Generate your parser
|
||||
* Make sure, you have the property `<antlr4.visitor>true</antlr4.visitor>` in your `pom.xml` file.
|
||||
* This is just a matter of building the language module. ANTLR is called via ant, and this step is added
|
||||
to the phase `generate-sources`. So you can just call e.g. `./mvnw generate-source -pl pmd-swift` to
|
||||
to the phase `generate-sources`. So you can just call e.g. `./mvnw generate-sources -pl pmd-swift` to
|
||||
have the parser generated.
|
||||
* The generated code will be placed under `target/generated-sources/antlr4` and will not be committed to
|
||||
source control.
|
||||
|
@ -1,16 +1,40 @@
|
||||
---
|
||||
title: Adding PMD support for a new JAVACC grammar based language
|
||||
short_title: Adding a new language with JAVACC
|
||||
title: Adding PMD support for a new JavaCC grammar based language
|
||||
short_title: Adding a new language with JavaCC
|
||||
tags: [devdocs, extending]
|
||||
summary: "How to add a new language to PMD using JAVACC grammar."
|
||||
last_updated: October 5, 2019
|
||||
summary: "How to add a new language to PMD using JavaCC grammar."
|
||||
last_updated: October 2021
|
||||
sidebar: pmd_sidebar
|
||||
permalink: pmd_devdocs_major_adding_new_language_javacc.html
|
||||
folder: pmd/devdocs
|
||||
---
|
||||
|
||||
{% include callout.html type="warning" content="
|
||||
|
||||
## 1. Start with a new sub-module.
|
||||
**Before you start...**<br><br>
|
||||
|
||||
This is really a big contribution and can't be done with a drive by contribution. It requires dedicated passion
|
||||
and long commitment to implement support for a new language.<br><br>
|
||||
|
||||
This step by step guide is just a small intro to get the basics started and it's also not necessarily up-to-date
|
||||
or complete and you have to be able to fill in the blanks.<br><br>
|
||||
|
||||
After the basic support for a language is there, there are lots of missing features left. Typical features
|
||||
that can greatly improve rule writing are: symbol table, type resolution, call/data flow analysis.<br><br>
|
||||
|
||||
Symbol table keeps track of variables and their usages. Type resolution tries to find the actual class type
|
||||
of each used type, following along method calls (including overloaded and overwritten methods), allowing
|
||||
to query sub types and type hierarchy. This requires additional configuration of an auxiliary classpath.
|
||||
Call and data flow analysis keep track of the data as it is moving through different execution paths
|
||||
a program has.<br><br>
|
||||
|
||||
These features are out of scope of this guide. Type resolution and data flow are features that
|
||||
definitely don't come for free. It is much effort and requires perseverance to implement.<br><br>
|
||||
|
||||
" %}
|
||||
|
||||
|
||||
## 1. Start with a new sub-module
|
||||
* See pmd-java or pmd-vm for examples.
|
||||
|
||||
## 2. Implement an AST parser for your language
|
||||
|
@ -32,7 +32,7 @@ All you need to do is follow this few steps:
|
||||
}
|
||||
```
|
||||
|
||||
- For JavaCC grammars you should subclass [JavaCCTokenizer](https://github.com/pmd/pmd/blob/master/pmd-core/src/main/java/net/sourceforge/pmd/cpd/internal/JavaCCTokenizer.java) wich has many examples you could follow, you should also take the [Python implementation](https://github.com/pmd/pmd/blob/master/pmd-python/src/main/java/net/sourceforge/pmd/cpd/PythonTokenizer.java) as reference
|
||||
- For JavaCC grammars you should subclass [JavaCCTokenizer](https://github.com/pmd/pmd/blob/master/pmd-core/src/main/java/net/sourceforge/pmd/cpd/internal/JavaCCTokenizer.java) which has many examples you could follow, you should also take the [Python implementation](https://github.com/pmd/pmd/blob/master/pmd-python/src/main/java/net/sourceforge/pmd/cpd/PythonTokenizer.java) as reference
|
||||
- For any other scenario you can use [AnyTokenizer](https://github.com/pmd/pmd/blob/master/pmd-core/src/main/java/net/sourceforge/pmd/cpd/AnyTokenizer.java)
|
||||
|
||||
If you're using Antlr or JavaCC, update the pom.xml of your submodule to use the appropriate ant wrapper. See `pmd-go/pom.xml` and `pmd-python/pom.xml` for examples.
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user