Merge branch '7.0.x' into remove-xml-dom-rule
This commit is contained in:
commit
434df63f2c
93 files changed
+3076
-993
No files matched your search
@@ -183,6 +183,10 @@ function pmd_ci_build_and_upload_doc() {
|
||||
pmd_code_removeJavadoc "${VERSION}-SNAPSHOT"
|
||||
|
||||
# updating github release text
|
||||
rm -f .bundle/config
|
||||
bundle config set --local path vendor/bundle
|
||||
bundle config set --local with release_notes_preprocessing
|
||||
bundle install
|
||||
# renders, and skips the first 6 lines - the Jekyll front-matter
|
||||
local rendered_release_notes=$(bundle exec .ci/render_release_notes.rb docs/pages/release_notes.md | tail -n +6)
|
||||
local release_name="PMD ${VERSION} ($(date -u +%d-%B-%Y))"
|
||||
|
||||
@@ -32,6 +32,8 @@ mvn dependency:build-classpath -DincludeScope=test -Dmdep.outputFile=classpath.t
|
||||
<connection>https://github.com/spring-projects/spring-framework</connection>
|
||||
<tag>v5.0.6.RELEASE</tag>
|
||||
|
||||
<exclude-pattern>.*/build/generated-sources/.*</exclude-pattern>
|
||||
|
||||
<build-command><![CDATA[#!/usr/bin/env bash
|
||||
if test -e classpath.txt; then
|
||||
exit
|
||||
@@ -86,7 +88,7 @@ export PATH=$JAVA_HOME/bin:$PATH
|
||||
EOF
|
||||
) | patch
|
||||
|
||||
./gradlew build -x javadoc -x dokka -x asciidoctor -x test -x testNG -x api -x distZip
|
||||
./gradlew build testClasses -x javadoc -x dokka -x asciidoctor -x test -x testNG -x api -x distZip
|
||||
./gradlew createSquishClasspath -q > classpath.txt
|
||||
]]></build-command>
|
||||
<auxclasspath-command>cat classpath.txt</auxclasspath-command>
|
||||
|
||||
@@ -32,93 +32,55 @@ function regression_tester_setup_ci() {
|
||||
}
|
||||
|
||||
#
|
||||
# Generate a new baseline and upload it to sourceforge
|
||||
#
|
||||
# Note: this function always succeeds, even if the upload fails.
|
||||
# In that case, just a error logging is provided.
|
||||
# Generate a new baseline and upload it to pmd-code.org
|
||||
#
|
||||
function regression_tester_uploadBaseline() {
|
||||
log_debug "$FUNCNAME branch=${PMD_CI_BRANCH}"
|
||||
local targetUrl="https://sourceforge.net/projects/pmd/files/pmd-regression-tester/"
|
||||
local pmdcodeUrl="https://pmd-code.org/pmd-regression-tester/"
|
||||
local baseline_branch="${PMD_CI_BRANCH:-$PMD_CI_TAG}"
|
||||
log_debug "$FUNCNAME branch=${baseline_branch}"
|
||||
|
||||
local errexitstate="$(shopt -po errexit)"
|
||||
set +e # disable errexit
|
||||
(
|
||||
# This handler is called if any command fails
|
||||
function upload_failed() {
|
||||
log_error "Error while uploading ${BRANCH_FILENAME}-baseline.zip to pmd-code.org!"
|
||||
log_error "Please upload manually: ${pmdcodeUrl}"
|
||||
#log_error "Error while uploading ${BRANCH_FILENAME}-baseline.zip to sourceforge!"
|
||||
#log_error "Please upload manually: ${targetUrl}"
|
||||
}
|
||||
|
||||
# exit subshell after trap
|
||||
set -e
|
||||
trap upload_failed ERR
|
||||
|
||||
log_info "Generating and uploading baseline for pmdtester..."
|
||||
cd ..
|
||||
bundle config --local gemfile pmd/Gemfile
|
||||
bundle exec pmdtester \
|
||||
--mode single \
|
||||
--local-git-repo ./pmd \
|
||||
--patch-branch ${PMD_CI_BRANCH} \
|
||||
--patch-config ./pmd/.ci/files/all-java.xml \
|
||||
--list-of-project ./pmd/.ci/files/project-list.xml --html-flag \
|
||||
--error-recovery
|
||||
cd target/reports
|
||||
BRANCH_FILENAME="${PMD_CI_BRANCH/\//_}"
|
||||
zip -q -r ${BRANCH_FILENAME}-baseline.zip ${BRANCH_FILENAME}/
|
||||
# ssh-key for pmd-code.org is setup already by pmd_ci_setup_ssh
|
||||
scp ${BRANCH_FILENAME}-baseline.zip pmd@pmd-code.org:/httpdocs/pmd-regression-tester/
|
||||
log_success "Successfully uploaded ${BRANCH_FILENAME}-baseline.zip to ${pmdcodeUrl}"
|
||||
#../../pmd/.ci/travis_wait "rsync -avh ${BRANCH_FILENAME}-baseline.zip ${PMD_SF_USER}@web.sourceforge.net:/home/frs/project/pmd/pmd-regression-tester/"
|
||||
#log_success "Successfully uploaded ${BRANCH_FILENAME}-baseline.zip to ${targetUrl}"
|
||||
)
|
||||
# restore errexit state
|
||||
eval "$errexitstate"
|
||||
log_info "Generating and uploading baseline for pmdtester (${baseline_branch})..."
|
||||
pushd ..
|
||||
rm -f .bundle/config
|
||||
bundle config set --local gemfile pmd/Gemfile
|
||||
bundle exec pmdtester \
|
||||
--mode single \
|
||||
--local-git-repo ./pmd \
|
||||
--patch-branch ${baseline_branch} \
|
||||
--patch-config ./pmd/.ci/files/all-java.xml \
|
||||
--list-of-project ./pmd/.ci/files/project-list.xml --html-flag \
|
||||
--error-recovery
|
||||
pushd target/reports
|
||||
BRANCH_FILENAME="${baseline_branch/\//_}"
|
||||
zip -q -r ${BRANCH_FILENAME}-baseline.zip ${BRANCH_FILENAME}/
|
||||
# ssh-key for pmd-code.org is setup already by pmd_ci_setup_ssh
|
||||
scp ${BRANCH_FILENAME}-baseline.zip pmd@pmd-code.org:/httpdocs/pmd-regression-tester/
|
||||
log_success "Successfully uploaded ${BRANCH_FILENAME}-baseline.zip to ${pmdcodeUrl}"
|
||||
popd
|
||||
popd
|
||||
}
|
||||
|
||||
#
|
||||
# Execute danger, which executes pmd-regression-tester (via Dangerfile).
|
||||
#
|
||||
# Note: this function always succeeds, even if the danger fails.
|
||||
# In that case, just a error logging is provided.
|
||||
#
|
||||
function regression_tester_executeDanger() {
|
||||
log_debug "$FUNCNAME"
|
||||
|
||||
local errexitstate="$(shopt -po errexit)"
|
||||
set +e # disable errexit
|
||||
(
|
||||
# This handler is called if any command fails
|
||||
function danger_failed() {
|
||||
log_error "Error while executing danger/pmd-regression-tester"
|
||||
}
|
||||
# Create a corresponding remote branch locally
|
||||
if ! git show-ref --verify --quiet refs/heads/${PMD_CI_BRANCH}; then
|
||||
git fetch --no-tags --depth=1 origin +refs/heads/${PMD_CI_BRANCH}:refs/remotes/origin/${PMD_CI_BRANCH}
|
||||
git branch ${PMD_CI_BRANCH} origin/${PMD_CI_BRANCH}
|
||||
log_debug "Created local branch ${PMD_CI_BRANCH}"
|
||||
fi
|
||||
# Fetch more commits of the PR for danger and regression tester
|
||||
git fetch --no-tags --depth=50 origin +$(git rev-parse HEAD^2):
|
||||
# Fetch more commits from master branch for regression tester
|
||||
if [[ "${PMD_CI_BRANCH}" != "master" ]]; then
|
||||
git fetch --no-tags --depth=50 origin +master:
|
||||
git branch master origin/master
|
||||
fi
|
||||
|
||||
# exit subshell after trap
|
||||
set -e
|
||||
trap danger_failed ERR
|
||||
|
||||
# Create a corresponding remote branch locally
|
||||
if ! git show-ref --verify --quiet refs/heads/${PMD_CI_BRANCH}; then
|
||||
git fetch --no-tags --depth=1 origin +refs/heads/${PMD_CI_BRANCH}:refs/remotes/origin/${PMD_CI_BRANCH}
|
||||
git branch ${PMD_CI_BRANCH} origin/${PMD_CI_BRANCH}
|
||||
log_debug "Created local branch ${PMD_CI_BRANCH}"
|
||||
fi
|
||||
# Fetch more commits of the PR for danger and regression tester
|
||||
git fetch --no-tags --depth=50 origin +$(git rev-parse HEAD^2):
|
||||
# Fetch more commits from master branch for regression tester
|
||||
if [[ "${PMD_CI_BRANCH}" != "master" ]]; then
|
||||
git fetch --no-tags --depth=50 origin +master:
|
||||
git branch master origin/master
|
||||
fi
|
||||
|
||||
log_info "Running danger on branch ${PMD_CI_BRANCH}"
|
||||
bundle exec danger --verbose
|
||||
log_success "Executing danger successfully"
|
||||
)
|
||||
# restore errexit state
|
||||
eval "$errexitstate"
|
||||
log_info "Running danger on branch ${PMD_CI_BRANCH}"
|
||||
bundle exec danger --verbose
|
||||
log_success "Executed danger successfully"
|
||||
}
|
||||
@@ -6,7 +6,7 @@ jobs:
|
||||
build:
|
||||
runs-on: ${{ matrix.os }}
|
||||
continue-on-error: false
|
||||
timeout-minutes: 30
|
||||
timeout-minutes: 60
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ ubuntu-latest, windows-latest, macos-latest ]
|
||||
|
||||
+1
-1
@@ -45,7 +45,7 @@ There are various channels, on which you can ask questions:
|
||||
|
||||
* On [StackOverflow](https://stackoverflow.com/questions/tagged/pmd): Make sure, to tag your question with "pmd".
|
||||
|
||||
* Create a issue for your question at <https://github.com/pmd/pmd/issues>.
|
||||
* Create a new discussion for your question at <https://github.com/pmd/pmd/discussions>.
|
||||
|
||||
* Ask your question on Gitter <https://gitter.im/pmd/pmd>.
|
||||
|
||||
|
||||
+3
-2
@@ -87,8 +87,9 @@ def upload_report
|
||||
`tar -cf #{tar_filename} diff1/ diff2/`
|
||||
report_url = `curl -u #{ENV['PMD_CI_CHUNK_TOKEN']} -T #{tar_filename} https://chunk.io`
|
||||
if $?.success?
|
||||
@logger.info "Successfully uploaded #{tar_filename} to chunk.io"
|
||||
report_url.chomp
|
||||
report_url.chomp!
|
||||
@logger.info "Successfully uploaded #{tar_filename} to #{report_url}"
|
||||
report_url
|
||||
else
|
||||
@logger.error "Error while uploading #{tar_filename} to chunk.io: #{report_url}"
|
||||
warn("Uploading the diff report failed, this message is mainly used to remind the maintainers of PMD.")
|
||||
|
||||
@@ -3,7 +3,7 @@ source 'https://rubygems.org/'
|
||||
# bleeding edge from git
|
||||
#gem 'pmdtester', :git => 'https://github.com/pmd/pmd-regression-tester.git'
|
||||
|
||||
gem 'pmdtester', '~> 1.1'
|
||||
gem 'pmdtester', '~> 1'
|
||||
gem 'danger', '~> 5.6', '>= 5.6'
|
||||
|
||||
# This group is only needed for rendering release notes
|
||||
|
||||
+15
-13
@@ -31,36 +31,38 @@ GEM
|
||||
multipart-post (>= 1.2, < 3)
|
||||
faraday-http-cache (1.3.1)
|
||||
faraday (~> 0.8)
|
||||
fugit (1.4.1)
|
||||
fugit (1.4.2)
|
||||
et-orbi (~> 1.1, >= 1.1.8)
|
||||
raabro (~> 1.4)
|
||||
git (1.7.0)
|
||||
git (1.8.1)
|
||||
rchardet (~> 1.8)
|
||||
kramdown (1.17.0)
|
||||
liquid (4.0.3)
|
||||
liquid (5.0.0)
|
||||
logger-colors (1.0.0)
|
||||
mini_portile2 (2.4.0)
|
||||
mini_portile2 (2.5.0)
|
||||
multipart-post (2.1.1)
|
||||
nap (1.1.0)
|
||||
no_proxy_fix (0.1.2)
|
||||
nokogiri (1.10.10)
|
||||
mini_portile2 (~> 2.4.0)
|
||||
octokit (4.19.0)
|
||||
nokogiri (1.11.1)
|
||||
mini_portile2 (~> 2.5.0)
|
||||
racc (~> 1.4)
|
||||
octokit (4.20.0)
|
||||
faraday (>= 0.9)
|
||||
sawyer (~> 0.8.0, >= 0.5.3)
|
||||
open4 (1.3.4)
|
||||
pmdtester (1.1.0)
|
||||
pmdtester (1.1.1)
|
||||
differ (~> 0.1)
|
||||
liquid (>= 4.0)
|
||||
logger-colors (~> 1.0)
|
||||
nokogiri (~> 1.8)
|
||||
nokogiri (>= 1.11.0.rc4)
|
||||
rufus-scheduler (~> 3.5)
|
||||
slop (~> 4.6)
|
||||
public_suffix (4.0.6)
|
||||
raabro (1.4.0)
|
||||
racc (1.5.2)
|
||||
rchardet (1.8.0)
|
||||
rouge (3.25.0)
|
||||
rufus-scheduler (3.6.0)
|
||||
rouge (3.26.0)
|
||||
rufus-scheduler (3.7.0)
|
||||
fugit (~> 1.1, >= 1.1.6)
|
||||
safe_yaml (1.0.5)
|
||||
sawyer (0.8.2)
|
||||
@@ -69,7 +71,7 @@ GEM
|
||||
slop (4.8.2)
|
||||
terminal-table (1.8.0)
|
||||
unicode-display_width (~> 1.1, >= 1.1.1)
|
||||
tzinfo (2.0.3)
|
||||
tzinfo (2.0.4)
|
||||
concurrent-ruby (~> 1.0)
|
||||
unicode-display_width (1.7.0)
|
||||
|
||||
@@ -79,7 +81,7 @@ PLATFORMS
|
||||
DEPENDENCIES
|
||||
danger (~> 5.6, >= 5.6)
|
||||
liquid (>= 4.0.0)
|
||||
pmdtester (~> 1.1)
|
||||
pmdtester (~> 1)
|
||||
rouge (>= 1.7, < 4)
|
||||
safe_yaml (>= 1.0)
|
||||
|
||||
|
||||
@@ -22,10 +22,12 @@ Objective-C, Perl, PHP, PLSQL, Python, Ruby, Salesforce.com Apex, Scala, Swift,
|
||||
|
||||
## Support
|
||||
|
||||
* How do I? -- Ask a question on [StackOverflow](https://stackoverflow.com/questions/tagged/pmd).
|
||||
* I got this error, why? -- Ask a question on [StackOverflow](https://stackoverflow.com/questions/tagged/pmd).
|
||||
* How do I? -- Ask a question on [StackOverflow](https://stackoverflow.com/questions/tagged/pmd)
|
||||
or on [discussions](https://github.com/pmd/pmd/discussions).
|
||||
* I got this error, why? -- Ask a question on [StackOverflow](https://stackoverflow.com/questions/tagged/pmd)
|
||||
or on [discussions](https://github.com/pmd/pmd/discussions).
|
||||
* I got this error and I'm sure it's a bug -- file an [issue](https://github.com/pmd/pmd/issues).
|
||||
* I have an idea/request/question -- file an [issue](https://github.com/pmd/pmd/issues).
|
||||
* I have an idea/request/question -- create a new [discussion](https://github.com/pmd/pmd/discussions).
|
||||
* I have a quick question -- ask on our [Gitter chat](https://gitter.im/pmd/pmd).
|
||||
* Where's your documentation? -- <https://pmd.github.io/latest/>
|
||||
|
||||
|
||||
+37
-30
@@ -1,7 +1,7 @@
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
activesupport (6.0.3.2)
|
||||
activesupport (6.0.3.4)
|
||||
concurrent-ruby (~> 1.0, >= 1.0.2)
|
||||
i18n (>= 0.7, < 2)
|
||||
minitest (~> 5.1)
|
||||
@@ -17,37 +17,40 @@ GEM
|
||||
commonmarker (0.17.13)
|
||||
ruby-enum (~> 0.5)
|
||||
concurrent-ruby (1.1.7)
|
||||
dnsruby (1.61.4)
|
||||
dnsruby (1.61.5)
|
||||
simpleidn (~> 0.1)
|
||||
em-websocket (0.5.1)
|
||||
em-websocket (0.5.2)
|
||||
eventmachine (>= 0.12.9)
|
||||
http_parser.rb (~> 0.6.0)
|
||||
ethon (0.12.0)
|
||||
ffi (>= 1.3.0)
|
||||
eventmachine (1.2.7)
|
||||
execjs (2.7.0)
|
||||
faraday (1.0.1)
|
||||
faraday (1.3.0)
|
||||
faraday-net_http (~> 1.0)
|
||||
multipart-post (>= 1.2, < 3)
|
||||
ffi (1.13.1)
|
||||
ruby2_keywords
|
||||
faraday-net_http (1.0.0)
|
||||
ffi (1.14.2)
|
||||
forwardable-extended (2.6.0)
|
||||
gemoji (3.0.1)
|
||||
github-pages (207)
|
||||
github-pages (209)
|
||||
github-pages-health-check (= 1.16.1)
|
||||
jekyll (= 3.9.0)
|
||||
jekyll-avatar (= 0.7.0)
|
||||
jekyll-coffeescript (= 1.1.1)
|
||||
jekyll-commonmark-ghpages (= 0.1.6)
|
||||
jekyll-default-layout (= 0.1.4)
|
||||
jekyll-feed (= 0.13.0)
|
||||
jekyll-feed (= 0.15.1)
|
||||
jekyll-gist (= 1.5.0)
|
||||
jekyll-github-metadata (= 2.13.0)
|
||||
jekyll-mentions (= 1.5.1)
|
||||
jekyll-mentions (= 1.6.0)
|
||||
jekyll-optional-front-matter (= 0.3.2)
|
||||
jekyll-paginate (= 1.1.0)
|
||||
jekyll-readme-index (= 0.3.0)
|
||||
jekyll-redirect-from (= 0.15.0)
|
||||
jekyll-redirect-from (= 0.16.0)
|
||||
jekyll-relative-links (= 0.6.1)
|
||||
jekyll-remote-theme (= 0.4.1)
|
||||
jekyll-remote-theme (= 0.4.2)
|
||||
jekyll-sass-converter (= 1.5.2)
|
||||
jekyll-seo-tag (= 2.6.1)
|
||||
jekyll-sitemap (= 1.4.0)
|
||||
@@ -55,7 +58,7 @@ GEM
|
||||
jekyll-theme-architect (= 0.1.1)
|
||||
jekyll-theme-cayman (= 0.1.1)
|
||||
jekyll-theme-dinky (= 0.1.1)
|
||||
jekyll-theme-hacker (= 0.1.1)
|
||||
jekyll-theme-hacker (= 0.1.2)
|
||||
jekyll-theme-leap-day (= 0.1.1)
|
||||
jekyll-theme-merlot (= 0.1.1)
|
||||
jekyll-theme-midnight (= 0.1.1)
|
||||
@@ -66,14 +69,14 @@ GEM
|
||||
jekyll-theme-tactile (= 0.1.1)
|
||||
jekyll-theme-time-machine (= 0.1.1)
|
||||
jekyll-titles-from-headings (= 0.5.3)
|
||||
jemoji (= 0.11.1)
|
||||
jemoji (= 0.12.0)
|
||||
kramdown (= 2.3.0)
|
||||
kramdown-parser-gfm (= 1.1.0)
|
||||
liquid (= 4.0.3)
|
||||
mercenary (~> 0.3)
|
||||
minima (= 2.5.1)
|
||||
nokogiri (>= 1.10.4, < 2.0)
|
||||
rouge (= 3.19.0)
|
||||
rouge (= 3.23.0)
|
||||
terminal-table (~> 1.4)
|
||||
github-pages-health-check (1.16.1)
|
||||
addressable (~> 2.3)
|
||||
@@ -114,14 +117,14 @@ GEM
|
||||
rouge (>= 2.0, < 4.0)
|
||||
jekyll-default-layout (0.1.4)
|
||||
jekyll (~> 3.0)
|
||||
jekyll-feed (0.13.0)
|
||||
jekyll-feed (0.15.1)
|
||||
jekyll (>= 3.7, < 5.0)
|
||||
jekyll-gist (1.5.0)
|
||||
octokit (~> 4.2)
|
||||
jekyll-github-metadata (2.13.0)
|
||||
jekyll (>= 3.4, < 5.0)
|
||||
octokit (~> 4.0, != 4.4.0)
|
||||
jekyll-mentions (1.5.1)
|
||||
jekyll-mentions (1.6.0)
|
||||
html-pipeline (~> 2.3)
|
||||
jekyll (>= 3.7, < 5.0)
|
||||
jekyll-optional-front-matter (0.3.2)
|
||||
@@ -129,14 +132,15 @@ GEM
|
||||
jekyll-paginate (1.1.0)
|
||||
jekyll-readme-index (0.3.0)
|
||||
jekyll (>= 3.0, < 5.0)
|
||||
jekyll-redirect-from (0.15.0)
|
||||
jekyll-redirect-from (0.16.0)
|
||||
jekyll (>= 3.3, < 5.0)
|
||||
jekyll-relative-links (0.6.1)
|
||||
jekyll (>= 3.3, < 5.0)
|
||||
jekyll-remote-theme (0.4.1)
|
||||
jekyll-remote-theme (0.4.2)
|
||||
addressable (~> 2.0)
|
||||
jekyll (>= 3.5, < 5.0)
|
||||
rubyzip (>= 1.3.0)
|
||||
jekyll-sass-converter (>= 1.0, <= 3.0.0, != 2.0.0)
|
||||
rubyzip (>= 1.3.0, < 3.0)
|
||||
jekyll-sass-converter (1.5.2)
|
||||
sass (~> 3.4)
|
||||
jekyll-seo-tag (2.6.1)
|
||||
@@ -153,8 +157,8 @@ GEM
|
||||
jekyll-theme-dinky (0.1.1)
|
||||
jekyll (~> 3.5)
|
||||
jekyll-seo-tag (~> 2.0)
|
||||
jekyll-theme-hacker (0.1.1)
|
||||
jekyll (~> 3.5)
|
||||
jekyll-theme-hacker (0.1.2)
|
||||
jekyll (> 3.5, < 5.0)
|
||||
jekyll-seo-tag (~> 2.0)
|
||||
jekyll-theme-leap-day (0.1.1)
|
||||
jekyll (~> 3.5)
|
||||
@@ -188,7 +192,7 @@ GEM
|
||||
jekyll (>= 3.3, < 5.0)
|
||||
jekyll-watch (2.2.1)
|
||||
listen (~> 3.0)
|
||||
jemoji (0.11.1)
|
||||
jemoji (0.12.0)
|
||||
gemoji (~> 3.0)
|
||||
html-pipeline (~> 2.2)
|
||||
jekyll (>= 3.0, < 5.0)
|
||||
@@ -197,32 +201,35 @@ GEM
|
||||
kramdown-parser-gfm (1.1.0)
|
||||
kramdown (~> 2.0)
|
||||
liquid (4.0.3)
|
||||
listen (3.2.1)
|
||||
listen (3.4.0)
|
||||
rb-fsevent (~> 0.10, >= 0.10.3)
|
||||
rb-inotify (~> 0.9, >= 0.9.10)
|
||||
mercenary (0.3.6)
|
||||
mini_portile2 (2.4.0)
|
||||
mini_portile2 (2.5.0)
|
||||
minima (2.5.1)
|
||||
jekyll (>= 3.5, < 5.0)
|
||||
jekyll-feed (~> 0.9)
|
||||
jekyll-seo-tag (~> 2.1)
|
||||
minitest (5.14.1)
|
||||
minitest (5.14.3)
|
||||
multipart-post (2.1.1)
|
||||
nokogiri (1.10.10)
|
||||
mini_portile2 (~> 2.4.0)
|
||||
octokit (4.18.0)
|
||||
nokogiri (1.11.1)
|
||||
mini_portile2 (~> 2.5.0)
|
||||
racc (~> 1.4)
|
||||
octokit (4.20.0)
|
||||
faraday (>= 0.9)
|
||||
sawyer (~> 0.8.0, >= 0.5.3)
|
||||
pathutil (0.16.2)
|
||||
forwardable-extended (~> 2.6)
|
||||
public_suffix (3.1.1)
|
||||
racc (1.5.2)
|
||||
rb-fsevent (0.10.4)
|
||||
rb-inotify (0.10.1)
|
||||
ffi (~> 1.0)
|
||||
rexml (3.2.4)
|
||||
rouge (3.19.0)
|
||||
rouge (3.23.0)
|
||||
ruby-enum (0.8.0)
|
||||
i18n
|
||||
ruby2_keywords (0.0.2)
|
||||
rubyzip (2.3.0)
|
||||
safe_yaml (1.0.5)
|
||||
sass (3.7.4)
|
||||
@@ -240,13 +247,13 @@ GEM
|
||||
thread_safe (0.3.6)
|
||||
typhoeus (1.4.0)
|
||||
ethon (>= 0.9.0)
|
||||
tzinfo (1.2.7)
|
||||
tzinfo (1.2.9)
|
||||
thread_safe (~> 0.1)
|
||||
unf (0.1.4)
|
||||
unf_ext
|
||||
unf_ext (0.0.7.7)
|
||||
unicode-display_width (1.7.0)
|
||||
zeitwerk (2.4.0)
|
||||
zeitwerk (2.4.2)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
@@ -118,6 +118,7 @@ The following previously deprecated rules have been finally removed:
|
||||
|
||||
* 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
|
||||
* [#807](https://github.com/pmd/pmd/issues/807): \[java] AccessorMethodGeneration false positive with overloads
|
||||
* [#1212](https://github.com/pmd/pmd/issues/1212): \[java] Don't raise JUnitTestContainsTooManyAsserts on JUnit 5's assertAll
|
||||
* [#1422](https://github.com/pmd/pmd/issues/1422): \[java] JUnitTestsShouldIncludeAssert false positive with inherited @Rule field
|
||||
|
||||
@@ -252,7 +252,7 @@ we may decide to remove some APIs that were not tagged as deprecated, though we'
|
||||
|
||||
###### Around RuleSet parsing
|
||||
|
||||
* {% jdoc core::RuleSetFactory %} and {% jdoc core::RuleSetFactoryUtils %} have been deprecated in favor of {% jdoc core::RuleSetLoader %}. This is easier to configure, and more maintainable than the multiple overloads of `RuleSetFactoryUtils`.
|
||||
* {% jdoc core::RuleSetFactory %} and {% jdoc core::RulesetsFactoryUtils %} have been deprecated in favor of {% jdoc core::RuleSetLoader %}. This is easier to configure, and more maintainable than the multiple overloads of `RulesetsFactoryUtils`.
|
||||
* Some static creation methods have been added to {% jdoc core::RuleSet %} for simple cases, eg {% jdoc core::RuleSet#forSingleRule(core::Rule) %}. These replace some counterparts in {% jdoc core::RuleSetFactory %}
|
||||
* Since {% jdoc core::RuleSets %} is also deprecated, many APIs that require a RuleSets instance now are deprecated, and have a counterpart that expects a `List<RuleSet>`.
|
||||
* {% jdoc core::RuleSetReferenceId %}, {% jdoc core::RuleSetReference %}, {% jdoc core::RuleSetFactoryCompatibility %} are deprecated. They are most likely not relevant outside of the implementation of pmd-core.
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
---
|
||||
title: Getting Help
|
||||
permalink: pmd_about_help.html
|
||||
author: Andreas Dangel <andreas.dangel@adangel.org>
|
||||
last_updated: September 2017
|
||||
author: Andreas Dangel <andreas.dangel@pmd-code.org>
|
||||
last_updated: January 2021
|
||||
---
|
||||
|
||||
There are numerous ways of getting help:
|
||||
@@ -13,7 +13,7 @@ There are numerous ways of getting help:
|
||||
|
||||
* If you found a bug, please create a new [github issue](https://github.com/pmd/pmd/issues).
|
||||
|
||||
* You can also ask questions in our [sourceforge forum](https://sourceforge.net/p/pmd/discussion/).
|
||||
* You can also ask questions on [github discussions](https://github.com/pmd/pmd/discussions).
|
||||
|
||||
* Or you can join the [Mailing List](https://lists.sourceforge.net/lists/listinfo/pmd-devel) or browse
|
||||
through the archives ([archive1](http://java-pmd.30631.n5.nabble.com/), [archive2](http://web.archive.org/web/20160715035623/http://blog.gmane.org:80/gmane.comp.java.audit.pmd.devel)).
|
||||
|
||||
@@ -119,7 +119,7 @@ Novice as much as advanced readers may want to [read on on Refactoring Guru](htt
|
||||
{% include custom/cli_option_row.html options="--ignore-literal-sequences"
|
||||
description="Ignore sequences of literals (common e.g. in list initializers)"
|
||||
default="false"
|
||||
languages="C#"
|
||||
languages="C#, C++"
|
||||
%}
|
||||
{% include custom/cli_option_row.html options="--ignore-usings"
|
||||
description="Ignore `using` directives in C# when comparing text"
|
||||
|
||||
@@ -19,11 +19,81 @@ This is a {{ site.pmd.release_type }} release.
|
||||
|
||||
### New and noteworthy
|
||||
|
||||
#### CPD
|
||||
|
||||
* The C++ module now supports the new option [`--ignore-literal-sequences`](https://pmd.github.io/latest/pmd_userdocs_cpd.html#-ignore-literal-sequences),
|
||||
which can be used to avoid detection of some uninteresting clones. This options has been
|
||||
introduced with PMD 6.30.0 for C# and is now available for C++ as well. See [#2963](https://github.com/pmd/pmd/pull/2963).
|
||||
|
||||
#### New Rules
|
||||
|
||||
* The new Apex rule {% rule "apex/errorprone/OverrideBothEqualsAndHashcode" %} brings the well known Java rule
|
||||
to Apex. In Apex the same principle applies: `equals` and `hashCode` should always be overridden
|
||||
together to ensure collection classes such as Maps and Sets work as expected.
|
||||
|
||||
* The new Visualforce rule {% rule "vf/security/VfHtmlStyleTagXss" %} checks for potential XSS problems
|
||||
when using `<style>` tags on Visualforce pages.
|
||||
|
||||
#### Deprecated rules
|
||||
|
||||
* java-performance
|
||||
* {% rule "java/performance/AvoidUsingShortType" %}: arithmetic on shorts is not significantly
|
||||
slower than on ints, whereas using shorts may provide significant memory savings in arrays.
|
||||
* {% rule "java/performance/SimplifyStartsWith" %}: the suggested code transformation has an
|
||||
insignificant performance impact, and decreases readability.
|
||||
|
||||
### Fixed Issues
|
||||
|
||||
* core
|
||||
* [#2970](https://github.com/pmd/pmd/issues/2970): \[core] PMD 6.30.0 release is not reproducible
|
||||
* [#2994](https://github.com/pmd/pmd/pull/2994): \[core] Fix code climate severity strings
|
||||
* java-bestpractices
|
||||
* [#575](https://github.com/pmd/pmd/issues/575): \[java] LiteralsFirstInComparisons should consider constant fields
|
||||
* [#2454](https://github.com/pmd/pmd/issues/2454): \[java] UnusedPrivateMethod violation for disabled class in 6.23.0
|
||||
* [#2833](https://github.com/pmd/pmd/issues/2833): \[java] NPE in UseCollectionIsEmptyRule with enums
|
||||
* [#2876](https://github.com/pmd/pmd/issues/2876): \[java] UnusedPrivateField cannot override ignored annotations property
|
||||
* [#2957](https://github.com/pmd/pmd/issues/2957): \[java] Ignore unused declarations that have special name
|
||||
* java-codestyle
|
||||
* [#2960](https://github.com/pmd/pmd/issues/2960): \[java] Thread issue in MethodNamingConventionsRule
|
||||
* java-design
|
||||
* [#3006](https://github.com/pmd/pmd/issues/3006): \[java] NPE in SingularFieldRule with concise resource syntax
|
||||
* java-errorprone
|
||||
* [#2976](https://github.com/pmd/pmd/issues/2976): \[java] CompareObjectsWithEquals: FP with array.length
|
||||
* [#2977](https://github.com/pmd/pmd/issues/2977): \[java] 6.30.0 introduces new false positive in CloseResource rule?
|
||||
* [#2979](https://github.com/pmd/pmd/issues/2979): \[java] UseEqualsToCompareStrings: FP with "var" variables
|
||||
* [#3004](https://github.com/pmd/pmd/issues/3004): \[java] UseEqualsToCompareStrings false positive with PMD 6.30.0
|
||||
* [#3062](https://github.com/pmd/pmd/issues/3062): \[java] CloseResource FP with reassigned stream
|
||||
* java-performance
|
||||
* [#2296](https://github.com/pmd/pmd/issues/2296): \[java] Deprecate rule AvoidUsingShortType
|
||||
* [#2740](https://github.com/pmd/pmd/issues/2740): \[java] Deprecate rule SimplifyStartsWith
|
||||
|
||||
### API Changes
|
||||
|
||||
#### Deprecated API
|
||||
|
||||
* {% jdoc xml::lang.xml.rule.AbstractDomXmlRule %}
|
||||
* {% jdoc xml::lang.wsdl.rule.AbstractWsdlRule %}
|
||||
* A few methods of {% jdoc xml::lang.xml.rule.AbstractXmlRule %}
|
||||
|
||||
#### Experimental APIs
|
||||
|
||||
* The method {% jdoc !!core::lang.ast.GenericToken#getKind() %} has been added as experimental. This
|
||||
unifies the token interface for both JavaCC and Antlr. The already existing method
|
||||
{% jdoc !!core::cpd.token.AntlrToken#getKind() %} is therefore experimental as well. The
|
||||
returned constant depends on the actual language and might change whenever the grammar
|
||||
of the language is changed.
|
||||
|
||||
### External Contributions
|
||||
|
||||
* [#2666](https://github.com/pmd/pmd/pull/2666): \[swift] Manage swift5 string literals - [kenji21](https://github.com/kenji21)
|
||||
* [#2959](https://github.com/pmd/pmd/pull/2959): \[apex] New Rule: override equals and hashcode rule - [recdevs](https://github.com/recdevs)
|
||||
* [#2963](https://github.com/pmd/pmd/pull/2963): \[cpp] Add option to ignore sequences of literals - [Maikel Steneker](https://github.com/maikelsteneker)
|
||||
* [#2964](https://github.com/pmd/pmd/pull/2964): \[cs] Update C# grammar for additional C# 7 and C# 8 features - [Maikel Steneker](https://github.com/maikelsteneker)
|
||||
* [#2965](https://github.com/pmd/pmd/pull/2965): \[cs] Improvements for ignore sequences of literals functionality - [Maikel Steneker](https://github.com/maikelsteneker)
|
||||
* [#2968](https://github.com/pmd/pmd/pull/2968): \[java] NPE in UseCollectionIsEmptyRule with enums - [foxmason](https://github.com/foxmason)
|
||||
* [#2983](https://github.com/pmd/pmd/pull/2983): \[java] LiteralsFirstInComparisons should consider constant fields - [Ozan Gulle](https://github.com/ozangulle)
|
||||
* [#2994](https://github.com/pmd/pmd/pull/2994): \[core] Fix code climate severity strings - [Vincent Maurin](https://github.com/vmaurin)
|
||||
* [#3005](https://github.com/pmd/pmd/pull/3005): \[vf] \[New Rule] Handle XSS violations that can occur within Html Style tags - [rmohan20](https://github.com/rmohan20)
|
||||
|
||||
{% endtocmaker %}
|
||||
|
||||
@@ -70,7 +70,7 @@ Thanks to Jeff Bartolotta and Roopa Mohan for contributing this!
|
||||
|
||||
##### Around RuleSet parsing
|
||||
|
||||
* <a href="https://docs.pmd-code.org/apidocs/pmd-core/6.30.0/net/sourceforge/pmd/RuleSetFactory.html#"><code>RuleSetFactory</code></a> and <a href="https://docs.pmd-code.org/apidocs/pmd-core/6.30.0/net/sourceforge/pmd/RuleSetFactoryUtils.html#"><code>RuleSetFactoryUtils</code></a> have been deprecated in favor of <a href="https://docs.pmd-code.org/apidocs/pmd-core/6.30.0/net/sourceforge/pmd/RuleSetLoader.html#"><code>RuleSetLoader</code></a>. This is easier to configure, and more maintainable than the multiple overloads of `RuleSetFactoryUtils`.
|
||||
* <a href="https://docs.pmd-code.org/apidocs/pmd-core/6.30.0/net/sourceforge/pmd/RuleSetFactory.html#"><code>RuleSetFactory</code></a> and <a href="https://docs.pmd-code.org/apidocs/pmd-core/6.30.0/net/sourceforge/pmd/RulesetsFactoryUtils.html#"><code>RulesetsFactoryUtils</code></a> have been deprecated in favor of <a href="https://docs.pmd-code.org/apidocs/pmd-core/6.30.0/net/sourceforge/pmd/RuleSetLoader.html#"><code>RuleSetLoader</code></a>. This is easier to configure, and more maintainable than the multiple overloads of `RulesetsFactoryUtils`.
|
||||
* Some static creation methods have been added to <a href="https://docs.pmd-code.org/apidocs/pmd-core/6.30.0/net/sourceforge/pmd/RuleSet.html#"><code>RuleSet</code></a> for simple cases, eg <a href="https://docs.pmd-code.org/apidocs/pmd-core/6.30.0/net/sourceforge/pmd/RuleSet.html#forSingleRule(net.sourceforge.pmd.Rule)"><code>forSingleRule</code></a>. These replace some counterparts in <a href="https://docs.pmd-code.org/apidocs/pmd-core/6.30.0/net/sourceforge/pmd/RuleSetFactory.html#"><code>RuleSetFactory</code></a>
|
||||
* Since <a href="https://docs.pmd-code.org/apidocs/pmd-core/6.30.0/net/sourceforge/pmd/RuleSets.html#"><code>RuleSets</code></a> is also deprecated, many APIs that require a RuleSets instance now are deprecated, and have a counterpart that expects a `List<RuleSet>`.
|
||||
* <a href="https://docs.pmd-code.org/apidocs/pmd-core/6.30.0/net/sourceforge/pmd/RuleSetReferenceId.html#"><code>RuleSetReferenceId</code></a>, <a href="https://docs.pmd-code.org/apidocs/pmd-core/6.30.0/net/sourceforge/pmd/RuleSetReference.html#"><code>RuleSetReference</code></a>, <a href="https://docs.pmd-code.org/apidocs/pmd-core/6.30.0/net/sourceforge/pmd/RuleSetFactoryCompatibility.html#"><code>RuleSetFactoryCompatibility</code></a> are deprecated. They are most likely not relevant outside of the implementation of pmd-core.
|
||||
|
||||
+19
-11
@@ -121,11 +121,15 @@
|
||||
Token-tracking behavior is implemented in the JJTree builder,
|
||||
so the grammar should have TRACK_TOKEN=false; (this is the default value)
|
||||
-->
|
||||
<jjtree target="etc/grammar/${lang-name}.jjt"
|
||||
outputdirectory="${target-package-dir}"
|
||||
nodeusesparser="false"
|
||||
nodepackage="${lang-ast-package}"
|
||||
javacchome="${javacc-home.path}" />
|
||||
<java fork="true"
|
||||
classname="jjtree"
|
||||
classpath="${javacc-home.path}/javacc.jar">
|
||||
<sysproperty key="file.encoding" value="UTF-8" />
|
||||
<arg value="-OUTPUT_DIRECTORY:${target-package-dir}" />
|
||||
<arg value="-NODE_USES_PARSER:false" />
|
||||
<arg value="-NODE_PACKAGE:${lang-ast-package}" />
|
||||
<arg value="etc/grammar/${lang-name}.jjt" />
|
||||
</java>
|
||||
</target>
|
||||
|
||||
<target name="jjtree-ersatz" if="no-jjtree" unless="javaccBuildNotRequired">
|
||||
@@ -135,12 +139,16 @@
|
||||
</target>
|
||||
|
||||
<target name="javacc" depends="jjtree" unless="javaccBuildNotRequired">
|
||||
<javacc static="false"
|
||||
usercharstream="true"
|
||||
unicodeinput="true"
|
||||
target="${target-package-dir}/${lang-name}.jj"
|
||||
outputdirectory="${target-package-dir}"
|
||||
javacchome="${javacc-home.path}" />
|
||||
<java fork="true"
|
||||
classname="javacc"
|
||||
classpath="${javacc-home.path}/javacc.jar">
|
||||
<sysproperty key="file.encoding" value="UTF-8" />
|
||||
<arg value="-STATIC:false" />
|
||||
<arg value="-USER_CHAR_STREAM:true" />
|
||||
<arg value="-UNICODE_INPUT:true" />
|
||||
<arg value="-OUTPUT_DIRECTORY:${target-package-dir}" />
|
||||
<arg value="${target-package-dir}/${lang-name}.jj" />
|
||||
</java>
|
||||
|
||||
</target>
|
||||
|
||||
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.lang.apex.rule.errorprone;
|
||||
|
||||
import net.sourceforge.pmd.lang.apex.ast.ASTMethod;
|
||||
import net.sourceforge.pmd.lang.apex.ast.ASTParameter;
|
||||
import net.sourceforge.pmd.lang.apex.ast.ASTUserClass;
|
||||
import net.sourceforge.pmd.lang.apex.ast.ApexNode;
|
||||
import net.sourceforge.pmd.lang.apex.rule.AbstractApexRule;
|
||||
|
||||
public class OverrideBothEqualsAndHashcodeRule extends AbstractApexRule {
|
||||
|
||||
public OverrideBothEqualsAndHashcodeRule() {
|
||||
addRuleChainVisit(ASTUserClass.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(ASTUserClass node, Object data) {
|
||||
ApexNode<?> equalsNode = null;
|
||||
ApexNode<?> hashNode = null;
|
||||
for (ASTMethod method : node.findChildrenOfType(ASTMethod.class)) {
|
||||
if (equalsNode == null && isEquals(method)) {
|
||||
equalsNode = method;
|
||||
}
|
||||
if (hashNode == null && isHashCode(method)) {
|
||||
hashNode = method;
|
||||
}
|
||||
if (hashNode != null && equalsNode != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (equalsNode != null && hashNode == null) {
|
||||
addViolation(data, equalsNode);
|
||||
} else if (hashNode != null && equalsNode == null) {
|
||||
addViolation(data, hashNode);
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
private boolean isEquals(ASTMethod node) {
|
||||
int numParams = 0;
|
||||
String paramType = null;
|
||||
for (int ix = 0; ix < node.getNumChildren(); ix++) {
|
||||
ApexNode<?> sn = node.getChild(ix);
|
||||
if (sn instanceof ASTParameter) {
|
||||
numParams++;
|
||||
paramType = ((ASTParameter) sn).getType();
|
||||
}
|
||||
}
|
||||
return numParams == 1 && "equals".equalsIgnoreCase(node.getImage()) && "Object".equalsIgnoreCase(paramType);
|
||||
}
|
||||
|
||||
private boolean isHashCode(ASTMethod node) {
|
||||
int numParams = 0;
|
||||
for (int ix = 0; ix < node.getNumChildren(); ix++) {
|
||||
ApexNode<?> sn = node.getChild(ix);
|
||||
if (sn instanceof ASTParameter) {
|
||||
numParams++;
|
||||
}
|
||||
}
|
||||
|
||||
return numParams == 0 && "hashCode".equalsIgnoreCase(node.getImage());
|
||||
}
|
||||
}
|
||||
@@ -110,6 +110,30 @@ public without sharing class Foo {
|
||||
</example>
|
||||
</rule>
|
||||
|
||||
<rule name="AvoidNonExistentAnnotations"
|
||||
language="apex"
|
||||
since="6.5.0"
|
||||
message="Use of non existent annotations will lead to broken Apex code which will not compile in the future."
|
||||
class="net.sourceforge.pmd.lang.apex.rule.errorprone.AvoidNonExistentAnnotationsRule"
|
||||
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_apex_errorprone.html#avoidnonexistentannotations">
|
||||
<description>
|
||||
Apex supported non existent annotations for legacy reasons.
|
||||
In the future, use of such non-existent annotations could result in broken apex code that will not compile.
|
||||
This will prevent users of garbage annotations from being able to use legitimate annotations added to Apex in the future.
|
||||
A full list of supported annotations can be found at https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_annotation.htm
|
||||
</description>
|
||||
<priority>3</priority>
|
||||
<example>
|
||||
<![CDATA[
|
||||
@NonExistentAnnotation public class ClassWithNonexistentAnnotation {
|
||||
@NonExistentAnnotation public void methodWithNonExistentAnnotation() {
|
||||
// ...
|
||||
}
|
||||
}
|
||||
]]>
|
||||
</example>
|
||||
</rule>
|
||||
|
||||
<rule name="EmptyCatchBlock"
|
||||
language="apex"
|
||||
since="6.0.0"
|
||||
@@ -311,24 +335,39 @@ public class MyClass {
|
||||
</example>
|
||||
</rule>
|
||||
|
||||
<rule name="AvoidNonExistentAnnotations"
|
||||
<rule name="OverrideBothEqualsAndHashcode"
|
||||
language="apex"
|
||||
since="6.5.0"
|
||||
message="Use of non existent annotations will lead to broken Apex code which will not compile in the future."
|
||||
class="net.sourceforge.pmd.lang.apex.rule.errorprone.AvoidNonExistentAnnotationsRule"
|
||||
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_apex_errorprone.html#avoidnonexistentannotations">
|
||||
since="6.31.0"
|
||||
message="Ensure you override both equals() and hashCode()"
|
||||
class="net.sourceforge.pmd.lang.apex.rule.errorprone.OverrideBothEqualsAndHashcodeRule"
|
||||
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_apex_errorprone.html#overridebothequalsandhashcode">
|
||||
<description>
|
||||
Apex supported non existent annotations for legacy reasons.
|
||||
In the future, use of such non-existent annotations could result in broken apex code that will not compile.
|
||||
This will prevent users of garbage annotations from being able to use legitimate annotations added to Apex in the future.
|
||||
A full list of supported annotations can be found at https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_annotation.htm
|
||||
Override both `public Boolean equals(Object obj)`, and `public Integer hashCode()`, or override neither.
|
||||
Even if you are inheriting a hashCode() from a parent class, consider implementing hashCode and explicitly
|
||||
delegating to your superclass.
|
||||
|
||||
This is especially important when [Using Custom Types in Map Keys and Sets](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_collections_maps_keys_userdefined.htm).
|
||||
</description>
|
||||
<priority>3</priority>
|
||||
<example>
|
||||
<![CDATA[@NonExistentAnnotation public class ClassWithNonexistentAnnotation {
|
||||
@NonExistentAnnotation public void methodWithNonExistentAnnotation() {
|
||||
// ...
|
||||
}
|
||||
<![CDATA[
|
||||
public class Bar { // poor, missing a hashCode() method
|
||||
public Boolean equals(Object o) {
|
||||
// do some comparison
|
||||
}
|
||||
}
|
||||
public class Baz { // poor, missing an equals() method
|
||||
public Integer hashCode() {
|
||||
// return some hash value
|
||||
}
|
||||
}
|
||||
public class Foo { // perfect, both methods provided
|
||||
public Boolean equals(Object other) {
|
||||
// do some comparison
|
||||
}
|
||||
public Integer hashCode() {
|
||||
// return some hash value
|
||||
}
|
||||
}
|
||||
]]>
|
||||
</example>
|
||||
|
||||
@@ -202,5 +202,6 @@
|
||||
<priority>3</priority>
|
||||
</rule>
|
||||
<!-- <rule ref="category/apex/bestpractices.xml/UnusedLocalVariable"/> -->
|
||||
<!-- <rule ref="category/apex/errorprone.xml/OverrideBothEqualsAndHashcode" /> -->
|
||||
|
||||
</ruleset>
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
/**
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.lang.apex.rule.errorprone;
|
||||
|
||||
import net.sourceforge.pmd.testframework.PmdRuleTst;
|
||||
|
||||
public class OverrideBothEqualsAndHashcodeTest extends PmdRuleTst {
|
||||
// no additional unit tests
|
||||
}
|
||||
+166
@@ -0,0 +1,166 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<test-data
|
||||
xmlns="http://pmd.sourceforge.net/rule-tests"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://pmd.sourceforge.net/rule-tests http://pmd.sourceforge.net/rule-tests_1_0_0.xsd">
|
||||
|
||||
<test-code>
|
||||
<description>hash code only</description>
|
||||
<expected-problems>1</expected-problems>
|
||||
<code><![CDATA[
|
||||
public class Foo {
|
||||
public Integer hashCode() {}
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
|
||||
<test-code>
|
||||
<description>nested hash code only</description>
|
||||
<expected-problems>1</expected-problems>
|
||||
<code><![CDATA[
|
||||
public class Foo {
|
||||
public class Bar {
|
||||
public Integer hashCode() {}
|
||||
}
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
|
||||
<test-code>
|
||||
<description>equals only</description>
|
||||
<expected-problems>1</expected-problems>
|
||||
<code><![CDATA[
|
||||
public class Foo {
|
||||
public boolean equals(Object other) {}
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
|
||||
<test-code>
|
||||
<description>nested equals only, checking case insensitiveness</description>
|
||||
<expected-problems>1</expected-problems>
|
||||
<code><![CDATA[
|
||||
public class Foo {
|
||||
public class Bar {
|
||||
public Integer eQuAlS(Object other) {}
|
||||
}
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
|
||||
<test-code>
|
||||
<description>overrides both</description>
|
||||
<expected-problems>0</expected-problems>
|
||||
<code><![CDATA[
|
||||
public class Foo {
|
||||
public boolean equals(Object other) {}
|
||||
public Integer hashCode() {}
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
|
||||
<test-code>
|
||||
<description>nested overrides both</description>
|
||||
<expected-problems>0</expected-problems>
|
||||
<code><![CDATA[
|
||||
public class Foo {
|
||||
public class Bar {
|
||||
public boolean equals(Object other) {}
|
||||
public Integer hashCode() {}
|
||||
}
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
|
||||
<test-code>
|
||||
<description>overrides neither</description>
|
||||
<expected-problems>0</expected-problems>
|
||||
<code><![CDATA[
|
||||
public class Foo {}
|
||||
]]></code>
|
||||
</test-code>
|
||||
|
||||
<test-code>
|
||||
<description>equals sig uses String, not Object</description>
|
||||
<expected-problems>1</expected-problems>
|
||||
<code><![CDATA[
|
||||
public class Foo {
|
||||
public boolean equals(String o) {
|
||||
return true;
|
||||
}
|
||||
public Integer hashCode() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
|
||||
<test-code>
|
||||
<description>interface</description>
|
||||
<expected-problems>0</expected-problems>
|
||||
<code><![CDATA[
|
||||
public interface Foo {
|
||||
boolean equals(Object o);
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
|
||||
<test-code>
|
||||
<description>implements equals but with 2 args, hashCode overloaded as well</description>
|
||||
<expected-problems>0</expected-problems>
|
||||
<code><![CDATA[
|
||||
public class Foo {
|
||||
public boolean equals(java.lang.Object o1, java.lang.Object o2) {
|
||||
return true;
|
||||
}
|
||||
public Integer hashCode(java.lang.Object o) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
|
||||
<test-code>
|
||||
<description>overloaded hashCode</description>
|
||||
<expected-problems>0</expected-problems>
|
||||
<code><![CDATA[
|
||||
public class Foo {
|
||||
public Integer hashCode(Object o1) { return false; }
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
|
||||
<test-code>
|
||||
<description>overloaded both</description>
|
||||
<expected-problems>0</expected-problems>
|
||||
<code><![CDATA[
|
||||
public class Foo {
|
||||
public boolean equals(Object o1, Object o2) { return false; }
|
||||
public Integer hashCode(Object o1) { return false; }
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
|
||||
<test-code>
|
||||
<description>overloaded hashCode, should fail on equals</description>
|
||||
<expected-problems>1</expected-problems>
|
||||
<code><![CDATA[
|
||||
public class Foo {
|
||||
public boolean equals(Object o1) { return false; }
|
||||
public Integer hashCode(Object o1) { return false; }
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
|
||||
<test-code>
|
||||
<description>implements hashCode but with args</description>
|
||||
<expected-problems>0</expected-problems>
|
||||
<code><![CDATA[
|
||||
public class Foo {
|
||||
public Integer hashCode(List<Decimal> a) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
</test-data>
|
||||
@@ -41,15 +41,23 @@
|
||||
<delete dir="${tmp-package.dir}" />
|
||||
<mkdir dir="${tmp-package.dir}" />
|
||||
<echo>Using JavaCC home: ${javacc-home.path}</echo>
|
||||
<jjtree target="etc/grammar/dummy.jjt"
|
||||
outputdirectory="${tmp-package.dir}"
|
||||
javacchome="${javacc-home.path}" />
|
||||
<java fork="true"
|
||||
classname="jjtree"
|
||||
classpath="${javacc-home.path}/javacc.jar">
|
||||
<sysproperty key="file.encoding" value="UTF-8" />
|
||||
<arg value="-OUTPUT_DIRECTORY:${tmp-package.dir}" />
|
||||
<arg value="etc/grammar/dummy.jjt" />
|
||||
</java>
|
||||
|
||||
<!-- Generate CharStream interface -->
|
||||
<javacc usercharstream="true"
|
||||
target="${tmp-package.dir}/dummy.jj"
|
||||
outputdirectory="${tmp-package.dir}"
|
||||
javacchome="${javacc-home.path}" />
|
||||
<java fork="true"
|
||||
classname="javacc"
|
||||
classpath="${javacc-home.path}/javacc.jar">
|
||||
<sysproperty key="file.encoding" value="UTF-8" />
|
||||
<arg value="-USER_CHAR_STREAM:true" />
|
||||
<arg value="-OUTPUT_DIRECTORY:${tmp-package.dir}" />
|
||||
<arg value="${tmp-package.dir}/dummy.jj" />
|
||||
</java>
|
||||
|
||||
<replace file="${tmp-package.dir}/CharStream.java"
|
||||
token="interface"
|
||||
|
||||
@@ -167,7 +167,16 @@ public class GUI implements CPDListener {
|
||||
|
||||
@Override
|
||||
public boolean canIgnoreLiteralSequences() {
|
||||
return "cs".equals(terseName);
|
||||
if (terseName == null) {
|
||||
return false;
|
||||
}
|
||||
switch(terseName) {
|
||||
case "cpp":
|
||||
case "cs":
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
package net.sourceforge.pmd.internal.util;
|
||||
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -13,6 +12,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
public final class AssertionUtil {
|
||||
|
||||
private static final Pattern PACKAGE_PATTERN = Pattern.compile("[\\w$]+(\\.[\\w$]+)*|");
|
||||
private static final Pattern BINARY_NAME_PATTERN = Pattern.compile("[\\w$]+(?:\\.[\\w$]+)*(?:\\[])*");
|
||||
|
||||
private AssertionUtil() {
|
||||
// utility class
|
||||
@@ -33,7 +33,7 @@ public final class AssertionUtil {
|
||||
}
|
||||
|
||||
public static boolean isJavaBinaryName(CharSequence name) {
|
||||
return name.length() > 0 && PACKAGE_PATTERN.matcher(name).matches();
|
||||
return name.length() > 0 && BINARY_NAME_PATTERN.matcher(name).matches();
|
||||
}
|
||||
|
||||
private static boolean isValidRange(int startInclusive, int endExclusive, int minIndex, int maxIndex) {
|
||||
@@ -118,5 +118,4 @@ public final class AssertionUtil {
|
||||
: prefix + ": " + message;
|
||||
return new AssertionError(message);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,6 +6,7 @@ package net.sourceforge.pmd.lang.ast;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import net.sourceforge.pmd.annotation.Experimental;
|
||||
import net.sourceforge.pmd.internal.util.IteratorUtil;
|
||||
import net.sourceforge.pmd.lang.ast.impl.javacc.JavaccToken;
|
||||
|
||||
@@ -138,4 +139,16 @@ public interface GenericToken<T extends GenericToken<T>> {
|
||||
return () -> IteratorUtil.generate(from.getPreviousComment(), JavaccToken::getPreviousComment);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a unique integer representing the kind of token this is.
|
||||
* The semantics of this kind depend on the language.
|
||||
*
|
||||
* <p><strong>Note:</strong> This is an experimental API.
|
||||
*
|
||||
* <p>The returned constants can be looked up in the language's "*ParserConstants",
|
||||
* e.g. CppParserConstants or JavaParserConstants. These constants are considered
|
||||
* internal API and may change at any time when the language's grammar is changed.
|
||||
*/
|
||||
@Experimental
|
||||
int getKind();
|
||||
}
|
||||
@@ -10,6 +10,7 @@ import java.util.regex.Pattern;
|
||||
import org.antlr.v4.runtime.Lexer;
|
||||
import org.antlr.v4.runtime.Token;
|
||||
|
||||
import net.sourceforge.pmd.annotation.Experimental;
|
||||
import net.sourceforge.pmd.lang.ast.GenericToken;
|
||||
|
||||
/**
|
||||
@@ -137,6 +138,8 @@ public class AntlrToken implements GenericToken<AntlrToken> {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Experimental
|
||||
public int getKind() {
|
||||
return token.getType();
|
||||
}
|
||||
|
||||
@@ -116,6 +116,11 @@ public class JavaccToken implements GenericToken<JavaccToken>, Comparable<Javacc
|
||||
return kind == EOF;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getKind() {
|
||||
return kind;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JavaccToken getNext() {
|
||||
return next;
|
||||
|
||||
@@ -80,12 +80,16 @@ public class CodeClimateRenderer extends AbstractIncrementingRenderer {
|
||||
|
||||
switch (rule.getPriority()) {
|
||||
case HIGH:
|
||||
issue.severity = "critical";
|
||||
issue.severity = "blocker";
|
||||
break;
|
||||
case MEDIUM_HIGH:
|
||||
issue.severity = "critical";
|
||||
break;
|
||||
case MEDIUM:
|
||||
issue.severity = "major";
|
||||
break;
|
||||
case MEDIUM_LOW:
|
||||
issue.severity = "normal";
|
||||
issue.severity = "minor";
|
||||
break;
|
||||
case LOW:
|
||||
default:
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<ruleset name="6310"
|
||||
xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.io/ruleset_2_0_0.xsd">
|
||||
<description>
|
||||
This ruleset contains links to rules that are new in PMD v6.31.0
|
||||
</description>
|
||||
|
||||
<rule ref="category/apex/errorprone.xml/OverrideBothEqualsAndHashcode" />
|
||||
|
||||
<rule ref="category/vf/security.xml/VfHtmlStyleTagXss" />
|
||||
|
||||
</ruleset>
|
||||
Loaded 30 of 93 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user