Merge branch 'master' into experimental-apex-parser

This commit is contained in:
Andreas Dangel 2024-02-22 18:38:17 +01:00
commit 3a7b570df0
No known key found for this signature in database
GPG Key ID: 93450DF2DF9A3FA3
609 changed files with 3304 additions and 6610 deletions

View File

@ -7242,8 +7242,8 @@
"contributions": [
"bug"
]
},
{
},
{
"login": "eant60",
"name": "eant60",
"avatar_url": "https://avatars.githubusercontent.com/u/41472980?v=4",
@ -7351,6 +7351,16 @@
"contributions": [
"code"
]
},
{
"login": "lbovet",
"name": "Laurent Bovet",
"avatar_url": "https://avatars.githubusercontent.com/u/692124?v=4",
"profile": "https://github.com/lbovet",
"contributions": [
"bug",
"code"
]
}
],
"contributorsPerLine": 7,

View File

@ -167,11 +167,12 @@ function build() {
#
# Installs bundler, which is needed for doc generation and regression tester
# Bundler should be already installed - it should be included in the ruby distribution.
# Bundler is needed for doc generation and regression tester
#
function pmd_ci_build_setup_bundler() {
pmd_ci_log_info "Installing bundler..."
gem install bundler -v 2.4.22
pmd_ci_log_info "Checking bundler version..."
bundle --version
}
#
@ -210,8 +211,6 @@ function pmd_ci_deploy_build_artifacts() {
pmd_ci_sourceforge_uploadFile "pmd/${PMD_CI_MAVEN_PROJECT_VERSION}" "pmd-dist/target/pmd-dist-${PMD_CI_MAVEN_PROJECT_VERSION}-bin.zip"
pmd_ci_sourceforge_uploadFile "pmd/${PMD_CI_MAVEN_PROJECT_VERSION}" "pmd-dist/target/pmd-dist-${PMD_CI_MAVEN_PROJECT_VERSION}-src.zip"
# Deploy SBOM
cp pmd-dist/target/bom.xml "pmd-dist/target/pmd-${PMD_CI_MAVEN_PROJECT_VERSION}-cyclonedx.xml"
cp pmd-dist/target/bom.json "pmd-dist/target/pmd-${PMD_CI_MAVEN_PROJECT_VERSION}-cyclonedx.json"
pmd_ci_sourceforge_uploadFile "pmd/${PMD_CI_MAVEN_PROJECT_VERSION}" "pmd-dist/target/pmd-${PMD_CI_MAVEN_PROJECT_VERSION}-cyclonedx.xml"
pmd_ci_sourceforge_uploadFile "pmd/${PMD_CI_MAVEN_PROJECT_VERSION}" "pmd-dist/target/pmd-${PMD_CI_MAVEN_PROJECT_VERSION}-cyclonedx.json"
fi
@ -229,8 +228,6 @@ function pmd_ci_deploy_build_artifacts() {
pmd_ci_sourceforge_uploadFile "pmd/${PMD_CI_MAVEN_PROJECT_VERSION}" "pmd-dist/target/pmd-dist-${PMD_CI_MAVEN_PROJECT_VERSION}-bin.zip"
pmd_ci_sourceforge_uploadFile "pmd/${PMD_CI_MAVEN_PROJECT_VERSION}" "pmd-dist/target/pmd-dist-${PMD_CI_MAVEN_PROJECT_VERSION}-src.zip"
# Deploy SBOM
cp pmd-dist/target/bom.xml "pmd-dist/target/pmd-${PMD_CI_MAVEN_PROJECT_VERSION}-cyclonedx.xml"
cp pmd-dist/target/bom.json "pmd-dist/target/pmd-${PMD_CI_MAVEN_PROJECT_VERSION}-cyclonedx.json"
pmd_ci_sourceforge_uploadFile "pmd/${PMD_CI_MAVEN_PROJECT_VERSION}" "pmd-dist/target/pmd-${PMD_CI_MAVEN_PROJECT_VERSION}-cyclonedx.xml"
pmd_ci_sourceforge_uploadFile "pmd/${PMD_CI_MAVEN_PROJECT_VERSION}" "pmd-dist/target/pmd-${PMD_CI_MAVEN_PROJECT_VERSION}-cyclonedx.json"

View File

@ -19,8 +19,9 @@ function regression_tester_setup_ci() {
source .ci/files/public-env >/dev/null 2>&1
rm .ci/files/public-env
if hash "bundler" 2>/dev/null; then
if hash "bundle" 2>/dev/null; then
pmd_ci_log_debug "Bundler is already installed"
bundle --version
else
pmd_ci_log_info "Installing bundler..."
gem install bundler

View File

@ -52,10 +52,10 @@ jobs:
key: v3-${{ runner.os }}-${{ hashFiles('**/pom.xml') }}
restore-keys: |
v3-${{ runner.os }}-
- name: Set up Ruby 2.7
- name: Set up Ruby 3.3
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7
ruby-version: 3.3
- name: Setup Environment
shell: bash
run: |

View File

@ -27,10 +27,10 @@ jobs:
key: v3-${{ runner.os }}-${{ hashFiles('**/pom.xml') }}
restore-keys: |
v3-${{ runner.os }}-
- name: Set up Ruby 2.7
- name: Set up Ruby 3.3
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7
ruby-version: 3.3
- name: Setup Environment
shell: bash
run: |

View File

@ -6,7 +6,7 @@ require 'etc'
@logger = Logger.new(STDOUT)
def get_args(base_branch, autogen = TRUE, patch_config = './pmd/.ci/files/all-regression-rules.xml')
def get_args(base_branch, autogen = true, patch_config = './pmd/.ci/files/all-regression-rules.xml')
['--local-git-repo', './pmd',
'--list-of-project', './pmd/.ci/files/project-list.xml',
'--base-branch', base_branch,

View File

@ -10,10 +10,10 @@ GEM
nap
open4 (~> 1.3)
colored2 (3.1.2)
concurrent-ruby (1.2.2)
concurrent-ruby (1.2.3)
cork (0.3.0)
colored2 (~> 3.1)
danger (9.4.2)
danger (9.4.3)
claide (~> 1.0)
claide-plugins (>= 0.9.2)
colored2 (~> 3.1)
@ -29,17 +29,16 @@ GEM
differ (0.1.2)
et-orbi (1.2.7)
tzinfo
faraday (2.7.12)
base64
faraday-net_http (>= 2.0, < 3.1)
ruby2_keywords (>= 0.0.4)
faraday-http-cache (2.5.0)
faraday (2.9.0)
faraday-net_http (>= 2.0, < 3.2)
faraday-http-cache (2.5.1)
faraday (>= 0.8)
faraday-net_http (3.0.2)
faraday-net_http (3.1.0)
net-http
fugit (1.9.0)
et-orbi (~> 1, >= 1.2.7)
raabro (~> 1.4)
git (1.18.0)
git (1.19.1)
addressable (~> 2.8)
rchardet (~> 1.8)
kramdown (2.4.0)
@ -50,11 +49,14 @@ GEM
logger-colors (1.0.0)
mini_portile2 (2.8.5)
nap (1.1.0)
net-http (0.4.1)
uri
no_proxy_fix (0.1.2)
nokogiri (1.15.5)
nokogiri (1.16.2)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
octokit (8.0.0)
octokit (8.1.0)
base64
faraday (>= 1, < 3)
sawyer (~> 0.9)
open4 (1.3.4)
@ -71,7 +73,6 @@ GEM
rchardet (1.8.0)
rexml (3.2.6)
rouge (4.2.0)
ruby2_keywords (0.0.5)
rufus-scheduler (3.9.1)
fugit (~> 1.1, >= 1.1.6)
safe_yaml (1.0.5)
@ -84,6 +85,7 @@ GEM
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.5.0)
uri (0.13.0)
PLATFORMS
ruby
@ -96,4 +98,4 @@ DEPENDENCIES
safe_yaml
BUNDLED WITH
2.4.22
2.5.3

View File

@ -17,6 +17,30 @@ if [ ! -f pom.xml ] || [ ! -d ../pmd.github.io ]; then
exit 1
fi
#
# Make sure, we have ruby and bundler available
#
set +e # don't stop for error "command not found" - it is handled
ruby_version_full=$(ruby --version 2>&1)
ruby_version=$(echo "${ruby_version_full}" | grep "ruby 3" | head -1 2>&1)
if [ $? -eq 0 ] && [ -n "${ruby_version}" ]; then
echo "Using ${ruby_version_full}"
else
echo "Wrong ruby version! Expected ruby 3"
echo "${ruby_version_full}"
exit 1
fi
bundler_version=$(bundler --version 2>&1)
if [ $? -eq 0 ]; then
echo "Using ${bundler_version}"
else
echo "Missing bundler!"
echo "${bundler_version}"
exit 1
fi
# abort the script on the first failing sub command
set -e
CURRENT_BRANCH=
echo "-------------------------------------------"

View File

@ -1,7 +1,7 @@
GEM
remote: https://rubygems.org/
specs:
activesupport (7.1.2)
activesupport (7.1.3)
base64
bigdecimal
concurrent-ruby (~> 1.0, >= 1.0.2)
@ -14,14 +14,14 @@ GEM
addressable (2.8.6)
public_suffix (>= 2.0.2, < 6.0)
base64 (0.2.0)
bigdecimal (3.1.5)
bigdecimal (3.1.6)
coffee-script (2.4.1)
coffee-script-source
execjs
coffee-script-source (1.11.1)
coffee-script-source (1.12.2)
colorator (1.1.0)
commonmarker (0.23.10)
concurrent-ruby (1.2.2)
concurrent-ruby (1.2.3)
connection_pool (2.4.1)
dnsruby (1.70.0)
simpleidn (~> 0.2.1)
@ -34,24 +34,23 @@ GEM
ffi (>= 1.15.0)
eventmachine (1.2.7)
execjs (2.9.1)
faraday (2.7.12)
base64
faraday-net_http (>= 2.0, < 3.1)
ruby2_keywords (>= 0.0.4)
faraday-net_http (3.0.2)
faraday (2.9.0)
faraday-net_http (>= 2.0, < 3.2)
faraday-net_http (3.1.0)
net-http
ffi (1.16.3)
forwardable-extended (2.6.0)
gemoji (3.0.1)
github-pages (228)
github-pages-health-check (= 1.17.9)
jekyll (= 3.9.3)
jekyll-avatar (= 0.7.0)
jekyll-coffeescript (= 1.1.1)
gemoji (4.1.0)
github-pages (231)
github-pages-health-check (= 1.18.2)
jekyll (= 3.9.5)
jekyll-avatar (= 0.8.0)
jekyll-coffeescript (= 1.2.2)
jekyll-commonmark-ghpages (= 0.4.0)
jekyll-default-layout (= 0.1.4)
jekyll-feed (= 0.15.1)
jekyll-default-layout (= 0.1.5)
jekyll-feed (= 0.17.0)
jekyll-gist (= 1.5.0)
jekyll-github-metadata (= 2.13.0)
jekyll-github-metadata (= 2.16.1)
jekyll-include-cache (= 0.2.1)
jekyll-mentions (= 1.6.0)
jekyll-optional-front-matter (= 0.3.2)
@ -78,20 +77,20 @@ GEM
jekyll-theme-tactile (= 0.2.0)
jekyll-theme-time-machine (= 0.2.0)
jekyll-titles-from-headings (= 0.5.3)
jemoji (= 0.12.0)
kramdown (= 2.3.2)
jemoji (= 0.13.0)
kramdown (= 2.4.0)
kramdown-parser-gfm (= 1.1.0)
liquid (= 4.0.4)
mercenary (~> 0.3)
minima (= 2.5.1)
nokogiri (>= 1.13.6, < 2.0)
rouge (= 3.26.0)
rouge (= 3.30.0)
terminal-table (~> 1.4)
github-pages-health-check (1.17.9)
github-pages-health-check (1.18.2)
addressable (~> 2.3)
dnsruby (~> 1.60)
octokit (~> 4.0)
public_suffix (>= 3.0, < 5.0)
octokit (>= 4, < 8)
public_suffix (>= 3.0, < 6.0)
typhoeus (~> 1.3)
html-pipeline (2.14.3)
activesupport (>= 2)
@ -99,7 +98,7 @@ GEM
http_parser.rb (0.8.0)
i18n (1.14.1)
concurrent-ruby (~> 1.0)
jekyll (3.9.3)
jekyll (3.9.5)
addressable (~> 2.4)
colorator (~> 1.0)
em-websocket (~> 0.5)
@ -112,11 +111,11 @@ GEM
pathutil (~> 0.9)
rouge (>= 1.7, < 4)
safe_yaml (~> 1.0)
jekyll-avatar (0.7.0)
jekyll-avatar (0.8.0)
jekyll (>= 3.0, < 5.0)
jekyll-coffeescript (1.1.1)
jekyll-coffeescript (1.2.2)
coffee-script (~> 2.2)
coffee-script-source (~> 1.11.1)
coffee-script-source (~> 1.12)
jekyll-commonmark (1.4.0)
commonmarker (~> 0.22)
jekyll-commonmark-ghpages (0.4.0)
@ -124,15 +123,15 @@ GEM
jekyll (~> 3.9.0)
jekyll-commonmark (~> 1.4.0)
rouge (>= 2.0, < 5.0)
jekyll-default-layout (0.1.4)
jekyll (~> 3.0)
jekyll-feed (0.15.1)
jekyll-default-layout (0.1.5)
jekyll (>= 3.0, < 5.0)
jekyll-feed (0.17.0)
jekyll (>= 3.7, < 5.0)
jekyll-gist (1.5.0)
octokit (~> 4.2)
jekyll-github-metadata (2.13.0)
jekyll-github-metadata (2.16.1)
jekyll (>= 3.4, < 5.0)
octokit (~> 4.0, != 4.4.0)
octokit (>= 4, < 7, != 4.4.0)
jekyll-include-cache (0.2.1)
jekyll (>= 3.7, < 5.0)
jekyll-mentions (1.6.0)
@ -203,11 +202,11 @@ GEM
jekyll (>= 3.3, < 5.0)
jekyll-watch (2.2.1)
listen (~> 3.0)
jemoji (0.12.0)
gemoji (~> 3.0)
jemoji (0.13.0)
gemoji (>= 3, < 5)
html-pipeline (~> 2.2)
jekyll (>= 3.0, < 5.0)
kramdown (2.3.2)
kramdown (2.4.0)
rexml
kramdown-parser-gfm (1.1.0)
kramdown (~> 2.0)
@ -221,9 +220,11 @@ GEM
jekyll (>= 3.5, < 5.0)
jekyll-feed (~> 0.9)
jekyll-seo-tag (~> 2.1)
minitest (5.20.0)
minitest (5.22.2)
mutex_m (0.2.0)
nokogiri (1.15.5)
net-http (0.4.1)
uri
nokogiri (1.16.2)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
octokit (4.25.1)
@ -231,13 +232,13 @@ GEM
sawyer (~> 0.9)
pathutil (0.16.2)
forwardable-extended (~> 2.6)
public_suffix (4.0.7)
public_suffix (5.0.4)
racc (1.7.3)
rb-fsevent (0.11.2)
rb-inotify (0.10.1)
ffi (~> 1.0)
rexml (3.2.6)
rouge (3.26.0)
rouge (3.30.0)
ruby2_keywords (0.0.5)
rubyzip (2.3.2)
safe_yaml (1.0.5)
@ -261,6 +262,7 @@ GEM
unf_ext
unf_ext (0.0.9.1)
unicode-display_width (1.8.0)
uri (0.13.0)
webrick (1.8.1)
PLATFORMS
@ -272,4 +274,4 @@ DEPENDENCIES
webrick
BUNDLED WITH
2.4.22
2.5.3

View File

@ -1,15 +1,13 @@
---
title: HTML support
permalink: pmd_languages_html.html
last_updated: September 2023 (7.0.0)
tags: [languages, PmdCapableLanguage, CpdCapableLanguage, experimental]
last_updated: February 2024 (7.0.0)
tags: [languages, PmdCapableLanguage, CpdCapableLanguage]
summary: "HTML-specific features and guidance"
---
{% include language_info.html name='HTML' id='html' implementation='html::lang.html.HtmlLanguageModule' supports_pmd=true supports_cpd=true since='6.45.0' %}
{% include warning.html content="This language module is experimental and may change any time." %}
The HTML language module uses [jsoup](https://jsoup.org/) for parsing.
XPath rules are supported, but the DOM is not always a typical XML/XPath DOM.

View File

@ -1,17 +1,13 @@
---
title: Kotlin Support
permalink: pmd_languages_kotlin.html
last_updated: September 2023 (7.0.0)
tags: [languages, PmdCapableLanguage, CpdCapableLanguage, experimental]
last_updated: February 2024 (7.0.0)
tags: [languages, PmdCapableLanguage, CpdCapableLanguage]
summary: "Kotlin-specific features and guidance"
---
[Kotlin](https://kotlinlang.org/) support in PMD is based on the official grammar from <https://github.com/Kotlin/kotlin-spec>.
{% include language_info.html name='Kotlin' id='kotlin' implementation='kotlin::lang.kotlin.JspLanguageModule' supports_pmd=true supports_cpd=true %}
{% include language_info.html name='Kotlin' id='kotlin' implementation='kotlin::lang.kotlin.JspLanguageModule' supports_pmd=true supports_cpd=true since=7.0.0 %}
Java-based rules and XPath-based rules are supported.
{% include note.html content="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." %}

View File

@ -1,8 +1,8 @@
---
title: Visualforce Support
permalink: pmd_languages_visualforce.html
last_updated: September 2023
tags: [languages, PmdCapableLanguage, CpdCapableLanguage, experimental]
last_updated: February 2024 (7.0.0)
tags: [languages, PmdCapableLanguage, CpdCapableLanguage]
author: Andreas Dangel
summary: "Visualforce-specific features and guidance"
---
@ -40,9 +40,6 @@ These env vars have changed from PMD 6 to PMD 7:
* `PMD_VF_OBJECTSDIRECTORIES` ➡️ `PMD_VF_OBJECTS_DIRECTORIES`
"%}
This feature is experimental, in particular, expect changes to the way the configuration is specified.
We'll probably extend the CLI instead of relying on environment variables in a future version.
### Sample usage
```

File diff suppressed because it is too large Load Diff

View File

@ -63,7 +63,7 @@ However, this also adds additional tasks, and it takes time to write down and do
## Change History
2022-09-30: Status changed to "Accepted".
2022-09-30: Status changed to "Accepted". ([#4072](https://github.com/pmd/pmd/pull/4072))
2022-09-06: Added section "Change History" to the template. Added "Last updated" to "Status" section.

View File

@ -66,6 +66,6 @@ Maintaining a polyglot code base with multiple languages is likely to be more ch
## Change History
2022-09-30: Changed status to "Accepted".
2022-09-30: Changed status to "Accepted". ([#4072](https://github.com/pmd/pmd/pull/4072))
2022-07-28: Proposed initial version.

View File

@ -5,8 +5,8 @@ permalink: pmd_projectdocs_decisions_adr_3.html
sidebaractiveurl: /pmd_projectdocs_decisions.html
adr: true
# Proposed / Accepted / Deprecated / Superseded
adr_status: "Proposed"
last_updated: December 2023
adr_status: "Accepted"
last_updated: February 2024
---
<!-- https://github.com/joelparkerhenderson/architecture-decision-record/blob/main/templates/decision-record-template-by-michael-nygard/index.md -->
@ -184,4 +184,6 @@ Non-concrete AST classes (like base classes or common interfaces) should follow
## Change History
2024-02-01: Changed status to "Accepted". ([#4756](https://github.com/pmd/pmd/pull/4756))
2023-12-01: Proposed initial version.

View File

@ -57,6 +57,25 @@ There are a couple of deprecated things in PMD 6, you might encounter:
and the old rulesets like `basic.xml` have been deprecated and have been removed with PMD 7.
It is about time to create a [custom ruleset](pmd_userdocs_making_rulesets.html).
## Approaching 7.0.0
After that, migrate to the release candidates, and fix any problems you encounter. Start with 7.0.0-rc1 via
7.0.0-rc2, 7.0.0-rc3 and 7.0.0-rc4 until you finally use 7.0.0.
You might encounter additionally the following types of problems:
* If you use any programmatic API of PMD, first avoid any usage of deprecated or internal classes/methods. These
are marked with one of these annotations: `@Deprecated`, `@DeprecatedUtil700`, `@InternalApi`.
* Some of these classes are available until 7.0.0-rc4 but are finally removed with 7.0.0.
* See [API changes](pmd_release_notes_pmd7.html#api-changes) for details.
* Some rules have been removed, because they have been deprecated. See [Removed Rules](pmd_release_notes_pmd7.html#removed-rules).
* Some rule properties have been removed or changed. See [Changed Rules](pmd_release_notes_pmd7.html#changed-rules).
* The filenames of the assets of a release (the "binary distribution zip file") have changed,
see [Release downloads](#release-downloads).
* Some CLI options have been removed, because they have been deprecated. See [CLI Changes](#cli-changes) for details.
* If you call CPD programmatically, the API has changed, see [New Programmatic API for CPD](pmd_release_notes_pmd7.html#new-programmatic-api-for-cpd).
The following topics describe well known migration challenges in more detail.
## Use cases
@ -205,7 +224,8 @@ Most notable changes:
an error message such as `[main] ERROR net.sourceforge.pmd.cli.commands.internal.PmdCommand - No such file false`.
* PMD tries to display a progress bar. If you don't want this (e.g. on a CI build server), you can disable this
with `--no-progress`.
* `--no-ruleset-compatibility` has been removed
* `--no-ruleset-compatibility` has been removed without replacement.
* `--stress` (or `-stress`) has been removed without replacement.
### Custom distribution packages
@ -443,14 +463,15 @@ Some nodes have already the image attribute (and others) deprecated. These depre
* {% jdoc java::lang.java.ast.ASTAnnotationTypeDeclaration %}: `@Image` ➡️ `@SimpleName`
* {% jdoc java::lang.java.ast.ASTAnonymousClassDeclaration %}: `@Image` ➡️ `@SimpleName`
* {% jdoc java::lang.java.ast.ASTClassOrInterfaceDeclaration %}: `@Image` ➡️ `@SimpleName`
* {% jdoc java::lang.java.ast.ASTClassDeclaration %} (previously "ASTClassOrInterfaceDeclaration"): `@Image` ➡️ `@SimpleName`
* {% jdoc java::lang.java.ast.ASTEnumDeclaration %}: `@Image` ➡️ `@SimpleName`
* {% jdoc java::lang.java.ast.ASTFieldDeclaration %}: `@VariableName` ➡️ `VariableDeclaratorId/@Name`
* {% jdoc java::lang.java.ast.ASTFieldDeclaration %}: `@VariableName` ➡️ `VariableId/@Name`
* {% jdoc java::lang.java.ast.ASTMethodDeclaration %}: `@Image` ➡️ `@Name`
* {% jdoc java::lang.java.ast.ASTMethodDeclaration %}: `@MethodName` ➡️ `@Name`
* {% jdoc java::lang.java.ast.ASTRecordDeclaration %}: `@Image` ➡️ `@SimpleName`
* {% jdoc java::lang.java.ast.ASTVariableDeclaratorId %}: `@Image` ➡️ `@Name`
* {% jdoc java::lang.java.ast.ASTVariableDeclaratorId %}: `@VariableName` ➡️ `@Name`
* {% jdoc java::lang.java.ast.ASTVariableDeclaratorId %}: `@Array` ➡️ `@ArrayType`
* {% jdoc java::lang.java.ast.ASTVariableId %} (previously "ASTVariableDeclaratorId"): `@Image` ➡️ `@Name`
* {% jdoc java::lang.java.ast.ASTVariableId %} (previously "ASTVariableDeclaratorId"): `@VariableName` ➡️ `@Name`
* {% jdoc java::lang.java.ast.ASTVariableId %} (previously "ASTVariableDeclaratorId"): `@Array` ➡️ `@ArrayType`
#### JavaScript
@ -3340,31 +3361,7 @@ See the use case [I'm using only built-in rules](#im-using-only-built-in-rules)
#### Maven
* Due to some changes in PMD's API, you can't simply pull in the new PMD 7 dependency.
* However, there is now a compatibility module, that makes it possible to use PMD 7 with Maven. In addition to the PMD 7
dependencies documented in [Upgrading PMD at Runtime](https://maven.apache.org/plugins/maven-pmd-plugin/examples/upgrading-PMD-at-runtime.html)
you need to add additionally the following dependency (first available version is 7.0.0-rc4):
```xml
<dependency>
<groupId>net.sourceforge.pmd</groupId>
<artifactId>pmd-compat6</artifactId>
<version>${pmdVersion}</version>
</dependency>
```
It is important to add this dependency as the **first** in the list, so that maven-pmd-plugin sees the (old)
compatible versions of some classes.
This module is available beginning with version 7.0.0-rc4 and will be there at least for the first
final version PMD 7 (7.0.0). It's not decided yet, whether we will keep updating it, after PMD 7 is finally
released.
Note: This compatibility module only works for the built-in rules, that are still available in PMD 7. E.g. you need
to review your rulesets and look out for deprecated rules and such. See the use case
[I'm using only built-in rules](#im-using-only-built-in-rules)
As PMD 7 revamped the Java module, if you have custom rules, you need to migrate these rules.
See the use case [I'm using custom rules](#im-using-custom-rules).
* See [Using PMD 7 with maven-pmd-plugin](pmd_userdocs_tools_maven.html#using-pmd-7-with-maven-pmd-plugin).
#### Gradle
@ -3377,3 +3374,13 @@ See the use case [I'm using custom rules](#im-using-custom-rules).
```
* Gradle 8.3 most likely will support PMD 7 out of the box.
* See [Support for PMD 7.0](https://github.com/gradle/gradle/issues/24502)
### XML Report Format
The [XML Report format](pmd_userdocs_report_formats.html#xml) supports rendering [suppressed violations](pmd_userdocs_suppressing_warnings.html).
The content of the attribute `suppressiontype` is changed in PMD 7.0.0:
* `nopmd` ➡️ `//nopmd`
* `annotation` ➡️ `@suppresswarnings`
* `xpath` - new value. Suppressed via property "violationSuppressXPath".
* `regex` - new value. Suppressed via property "violationSuppressRegex".

View File

@ -327,7 +327,7 @@ Was expecting one of:
... 10 more
]]>
</error>
<suppressedviolation filename="/home/pmd/source/pmd-core/src/main/java/net/sourceforge/pmd/PMD.java" suppressiontype="annotation" msg="Ensure that resources like this OutputStreamWriter object are closed after use" usermsg=""/>
<suppressedviolation filename="/home/pmd/source/pmd-core/src/main/java/net/sourceforge/pmd/PMD.java" suppressiontype="@suppresswarnings" msg="Ensure that resources like this OutputStreamWriter object are closed after use" usermsg=""/>
<configerror rule="LoosePackageCoupling" msg="No packages or classes specified"/>
</pmd>
```

View File

@ -2,12 +2,12 @@
title: Maven PMD Plugin
tags: [userdocs, tools]
permalink: pmd_userdocs_tools_maven.html
last_updated: March 2020
mpmd_version: 3.13.0
last_updated: February 2024
mpmd_version: 3.21.2
author: >
Miguel Griffa <mikkey@users.sourceforge.net>,
Romain PELISSE <belaran@gmail.com>,
Andreas Dangel <andreas.dangel@adangel.org>
Andreas Dangel <andreas.dangel@pmd-code.org>
---
## Maven 2 and 3
@ -239,56 +239,51 @@ Maven plugin will use and benefit from the latest bugfixes and enhancements:
</project>
```
#### Using PMD 7 with maven-pmd-plugin
The Maven PMD plugin comes with a specific PMD version, which is documented on the
[plugin project page](https://maven.apache.org/plugins/maven-pmd-plugin/index.html).
This might not support PMD 7 out of the box.
Since PMD 7 is a major release which breaks compatibility in various ways, the solution described
above in [Upgrading the PMD version at runtime](#upgrading-the-pmd-version-at-runtime) doesn't work
directly.
In order to use PMD 7 with [maven-pmd-plugin](https://maven.apache.org/plugins/maven-pmd-plugin/) a new
compatibility module has been created. This allows to use PMD 7 by simply adding one additional dependency:
1. Follow the guide [Upgrading PMD at Runtime](https://maven.apache.org/plugins/maven-pmd-plugin/examples/upgrading-PMD-at-runtime.html)
2. Add additionally the following dependency:
```xml
<dependency>
<groupId>net.sourceforge.pmd</groupId>
<artifactId>pmd-compat6</artifactId>
<version>${pmdVersion}</version>
</dependency>
```
It is important to add this dependency as the **first** in the list, so that maven-pmd-plugin sees the (old)
compatible versions of some classes.
This module is available beginning with version 7.0.0-rc4 and will be there at least for the first
final version PMD 7 (7.0.0). It's not decided yet, whether we will keep updating it, after PMD 7 is finally
released.
Note: This compatibility module only works for the built-in rules, that are still available in PMD 7. E.g. you need
to review your rulesets and look out for deprecated rules and such. See the use case
[I'm using only built-in rules](pmd_userdocs_migrating_to_pmd7.html#im-using-only-built-in-rules)
in the [Migration Guide for PMD 7](pmd_userdocs_migrating_to_pmd7.html).
As PMD 7 revamped the Java module, if you have custom rules, you need to migrate these rules.
See the use case [I'm using custom rules](pmd_userdocs_migrating_to_pmd7.html#im-using-custom-rules)
in the Migration Guide.
### Reference
For more information, please see the well documented PMD plugin project page here:
<http://maven.apache.org/plugins/maven-pmd-plugin/index.html>.
Also, the bug tracker for this plugin is [here](https://issues.apache.org/jira/browse/MPMD).
## Maven 1
{% include warning.html content="Apache Maven 1.x has reached its end of life, and is no longer supported. For more information, see the [announcement](http://maven.apache.org/maven-1.x-eol.html). Users are encouraged to migrate to the current version of Apache Maven." %}
This section is about the maven 1 PMD plugin.
### Running the pmd plugin
#### Generating a project report
To include the PMD report in the project reports section add the following line under
the reports element in your project.xml:
<report>maven-pmd-plugin</report>
This will add an entry to the 'project reports' section with the PMD report.
#### Executing PMD manually
To run PMD on a Maven project without adding it as a report, simply run
maven pmd xdoc
The PMD plugin writes the report in XML which will then be formatted into more readable HTML.
### Customization
#### Changing rulesets
To specify a set of official, built-in rulesets to be used set them in the property
<em>maven.pmd.rulesets</em>. You can include this setting in your project.properties file.
A clean strategy for customizing which rules to use for a project is to write a ruleset file.
In this file you can define which rules to use, add custom rules, and
customizing which rules to include/exclude from official rulesets. More information on
writing a ruleset can be found [here](pmd_userdocs_making_rulesets.html).
Add to the root of your Maven project a pmd.xml file which contains the ruleset mentioned in
the previous paragraph. Add the following property to your project now:
maven.pmd.rulesetfiles = ${basedir}/pmd.xml
### Reference
See the PMD plugin project page here:
<http://maven.apache.org/maven-1.x/plugins/pmd/>
Also, the bug tracker for this plugin is [MPMD](https://issues.apache.org/jira/browse/MPMD).

File diff suppressed because it is too large Load Diff

View File

@ -225,8 +225,8 @@ The following previously deprecated methods have been removed:
* pmd-core
* `net.sourceforge.pmd.properties.PropertyBuilder.GenericCollectionPropertyBuilder#delim(char)`
* `net.sourceforge.pmd.properties.PropertySource#setProperty(...)`
* `net.sourceforge.pmd.properties.PropertyTypeId#factoryFor(...)`
* `net.sourceforge.pmd.properties.PropertyTypeId#typeIdFor(...)`
* `net.sourceforge.pmd.properties.internal.PropertyTypeId#factoryFor(...)`
* `net.sourceforge.pmd.properties.internal.PropertyTypeId#typeIdFor(...)`
* `net.sourceforge.pmd.properties.PropertyDescriptor`: removed methods errorFor, type, isMultiValue,
uiOrder, compareTo, isDefinedExternally, valueFrom, asDelimitedString

View File

@ -176,15 +176,11 @@ Contributors: [Lucas Soncini](https://github.com/lsoncini) (@lsoncini),
[Matías Fraga](https://github.com/matifraga) (@matifraga),
[Tomás De Lucca](https://github.com/tomidelucca) (@tomidelucca)
### New: Kotlin support (experimental)
### New: Kotlin support
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
@ -247,6 +243,11 @@ PMD supports Apache Velocity for a very long time, but the CPD integration never
This is now done and CPD supports Apache Velocity Template language for detecting copy and paste.
It is shipped in the module `pmd-vm`.
### Changed: HTML support
Support for HTML was introduced in PMD 6.55.0 as an experimental feature. With PMD 7.0.0 this
is now considered stable.
### Changed: JavaScript support
The JS specific parser options have been removed. The parser now always retains comments and uses version ES6.
@ -445,78 +446,72 @@ The following previously deprecated rules have been finally removed:
**Java**
* {% deleted_rule java/codestyle/AbstractNaming %} ➡️ use {% rule java/codestyle/ClassNamingConventions %}
* AvoidFinalLocalVariable (java-codestyle) ➡️ not replaced
* AvoidPrefixingMethodParameters (java-codestyle) ➡️ use {% rule "java/codestyle/FormalParameterNamingConventions" %}
* AvoidUsingShortType (java-performance) ➡️ not replaced
* BadComparison (java-errorprone) ➡️ use {% rule "java/errorprone/ComparisonWithNaN" %}
* BeanMembersShouldSerialize (java-errorprone) ➡️ use {% rule java/errorprone/NonSerializableClass %}
* BooleanInstantiation (java-performance) ➡️ use {% rule "java/codestyle/UnnecessaryBoxing" %}
* {% deleted_rule java/codestyle/AvoidFinalLocalVariable %} ➡️ not replaced
* {% deleted_rule java/codestyle/AvoidPrefixingMethodParameters %} ➡️ use {% rule "java/codestyle/FormalParameterNamingConventions" %}
* {% deleted_rule java/performance/AvoidUsingShortType %} ➡️ not replaced
* {% deleted_rule java/errorprone/BadComparison %} ➡️ use {% rule "java/errorprone/ComparisonWithNaN" %}
* {% deleted_rule java/errorprone/BeanMembersShouldSerialize %} ➡️ use {% rule java/errorprone/NonSerializableClass %}
* {% deleted_rule java/performance/BooleanInstantiation %} ➡️ use {% rule "java/codestyle/UnnecessaryBoxing" %}
and {% rule "java/bestpractices/PrimitiveWrapperInstantiation" %}
* ByteInstantiation (java-performance) ➡️ use {% rule "java/codestyle/UnnecessaryBoxing" %}
* {% deleted_rule java/performance/ByteInstantiation %} ➡️ use {% rule "java/codestyle/UnnecessaryBoxing" %}
and {% rule "java/bestpractices/PrimitiveWrapperInstantiation" %}
* CloneThrowsCloneNotSupportedException (java-errorprone) ➡️ not replaced
* DataflowAnomalyAnalysis (java-errorprone) ➡️ use {% rule java/bestpractices/UnusedAssignment %}
* DefaultPackage (java-codestyle) ➡️ use {% rule "java/codestyle/CommentDefaultAccessModifier" %}
* DoNotCallSystemExit (java-errorprone) ➡️ use {% rule "java/errorprone/DoNotTerminateVM" %}
* DontImportJavaLang (java-codestyle) ➡️ use {% rule java/codestyle/UnnecessaryImport %}
* DuplicateImports (java-codestyle) ➡️ use {% rule java/codestyle/UnnecessaryImport %}
* EmptyFinallyBlock (java-errorprone) ➡️ use {% rule java/codestyle/EmptyControlStatement %}
* EmptyIfStmt (java-errorprone) ➡️ use {% rule java/codestyle/EmptyControlStatement %}
* EmptyInitializer (java-errorprone) ➡️ use {% rule java/codestyle/EmptyControlStatement %}
* EmptyStatementBlock (java-errorprone) ➡️ use {% rule java/codestyle/EmptyControlStatement %}
* EmptyStatementNotInLoop (java-errorprone) ➡️ use {% rule java/codestyle/UnnecessarySemicolon %}
* EmptySwitchStatements (java-errorprone) ➡️ use {% rule java/codestyle/EmptyControlStatement %}
* EmptySynchronizedBlock (java-errorprone) ➡️ use {% rule java/codestyle/EmptyControlStatement %}
* EmptyTryBlock (java-errorprone) ➡️ use {% rule java/codestyle/EmptyControlStatement %}
* EmptyWhileStmt (java-errorprone) ➡️ use {% rule java/codestyle/EmptyControlStatement %}
* ExcessiveClassLength (java-design) ➡️ use {% rule java/design/NcssCount %}
* ExcessiveMethodLength (java-design) ➡️ use {% rule java/design/NcssCount %}
* ForLoopsMustUseBraces (java-codestyle) ➡️ use {% rule java/codestyle/ControlStatementBraces %}
* IfElseStmtsMustUseBraces (java-codestyle) ➡️ use {% rule java/codestyle/ControlStatementBraces %}
* IfStmtsMustUseBraces (java-codestyle) ➡️ use {% rule java/codestyle/ControlStatementBraces %}
* ImportFromSamePackage (java-errorprone) ➡️ use {% rule java/codestyle/UnnecessaryImport %}
* IntegerInstantiation (java-performance) ➡️ use {% rule java/codestyle/UnnecessaryBoxing %}
* {% deleted_rule java/errorprone/CloneThrowsCloneNotSupportedException %} ➡️ not replaced
* {% deleted_rule java/errorprone/DataflowAnomalyAnalysis %} ➡️ use {% rule java/bestpractices/UnusedAssignment %}
* {% deleted_rule java/codestyle/DefaultPackage %} ➡️ use {% rule "java/codestyle/CommentDefaultAccessModifier" %}
* {% deleted_rule java/errorprone/DoNotCallSystemExit %} ➡️ use {% rule "java/errorprone/DoNotTerminateVM" %}
* {% deleted_rule java/codestyle/DontImportJavaLang %} ➡️ use {% rule java/codestyle/UnnecessaryImport %}
* {% deleted_rule java/codestyle/DuplicateImports %} ➡️ use {% rule java/codestyle/UnnecessaryImport %}
* {% deleted_rule java/errorprone/EmptyFinallyBlock %} ➡️ use {% rule java/codestyle/EmptyControlStatement %}
* {% deleted_rule java/errorprone/EmptyIfStmt %} ➡️ use {% rule java/codestyle/EmptyControlStatement %}
* {% deleted_rule java/errorprone/EmptyInitializer %} ➡️ use {% rule java/codestyle/EmptyControlStatement %}
* {% deleted_rule java/errorprone/EmptyStatementBlock %} ➡️ use {% rule java/codestyle/EmptyControlStatement %}
* {% deleted_rule java/errorprone/EmptyStatementNotInLoop %} ➡️ use {% rule java/codestyle/UnnecessarySemicolon %}
* {% deleted_rule java/errorprone/EmptySwitchStatements %} ➡️ use {% rule java/codestyle/EmptyControlStatement %}
* {% deleted_rule java/errorprone/EmptySynchronizedBlock %} ➡️ use {% rule java/codestyle/EmptyControlStatement %}
* {% deleted_rule java/errorprone/EmptyTryBlock %} ➡️ use {% rule java/codestyle/EmptyControlStatement %}
* {% deleted_rule java/errorprone/EmptyWhileStmt %} ➡️ use {% rule java/codestyle/EmptyControlStatement %}
* {% deleted_rule java/design/ExcessiveClassLength %} ➡️ use {% rule java/design/NcssCount %}
* {% deleted_rule java/design/ExcessiveMethodLength %} ➡️ use {% rule java/design/NcssCount %}
* {% deleted_rule java/codestyle/ForLoopsMustUseBraces %} ➡️ use {% rule java/codestyle/ControlStatementBraces %}
* {% deleted_rule java/codestyle/IfElseStmtsMustUseBraces %} ➡️ use {% rule java/codestyle/ControlStatementBraces %}
* {% deleted_rule java/codestyle/IfStmtsMustUseBraces %} ➡️ use {% rule java/codestyle/ControlStatementBraces %}
* {% deleted_rule java/errorprone/ImportFromSamePackage %} ➡️ use {% rule java/codestyle/UnnecessaryImport %}
* {% deleted_rule java/performance/IntegerInstantiation %} ➡️ use {% rule java/codestyle/UnnecessaryBoxing %}
and {% rule "java/bestpractices/PrimitiveWrapperInstantiation" %}
* InvalidSlf4jMessageFormat (java-errorprone) ➡️ use {% rule "java/errorprone/InvalidLogMessageFormat" %}
* LoggerIsNotStaticFinal (java-errorprone) ➡️ use {% rule java/errorprone/ProperLogger %}
* LongInstantiation (java-performance) ➡️ use {% rule "java/codestyle/UnnecessaryBoxing" %}
* {% deleted_rule java/errorprone/InvalidSlf4jMessageFormat %} ➡️ use {% rule "java/errorprone/InvalidLogMessageFormat" %}
* {% deleted_rule java/errorprone/LoggerIsNotStaticFinal %} ➡️ use {% rule java/errorprone/ProperLogger %}
* {% deleted_rule java/performance/LongInstantiation %} ➡️ use {% rule "java/codestyle/UnnecessaryBoxing" %}
and {% rule "java/bestpractices/PrimitiveWrapperInstantiation" %}
* MIsLeadingVariableName (java-codestyle) ➡️ use {% rule java/codestyle/FieldNamingConventions %},
* {% deleted_rule java/codestyle/MIsLeadingVariableName %} ➡️ use {% rule java/codestyle/FieldNamingConventions %},
{% rule java/codestyle/FormalParameterNamingConventions %},
or {% rule java/codestyle/LocalVariableNamingConventions %}
* MissingBreakInSwitch (java-errorprone) ➡️ use {% rule "java/errorprone/ImplicitSwitchFallThrough" %}
* ModifiedCyclomaticComplexity (java-design) ➡️ use {% rule "java/design/CyclomaticComplexity" %}
* NcssConstructorCount (java-design) ➡️ use {% rule java/design/NcssCount %}
* NcssMethodCount (java-design) ➡️ use {% rule java/design/NcssCount %}
* NcssTypeCount (java-design) ➡️ use {% rule java/design/NcssCount %}
* PositionLiteralsFirstInCaseInsensitiveComparisons (java-bestpractices) ➡️
* {% deleted_rule java/errorprone/MissingBreakInSwitch %} ➡️ use {% rule "java/errorprone/ImplicitSwitchFallThrough" %}
* {% deleted_rule java/design/ModifiedCyclomaticComplexity %} ➡️ use {% rule "java/design/CyclomaticComplexity" %}
* {% deleted_rule java/design/NcssConstructorCount %} ➡️ use {% rule java/design/NcssCount %}
* {% deleted_rule java/design/NcssMethodCount %} ➡️ use {% rule java/design/NcssCount %}
* {% deleted_rule java/design/NcssTypeCount %} ➡️ use {% rule java/design/NcssCount %}
* {% deleted_rule java/bestpractices/PositionLiteralsFirstInCaseInsensitiveComparisons %} ➡️
use {% rule "java/bestpractices/LiteralsFirstInComparisons" %}
* PositionLiteralsFirstInComparisons (java-bestpractices) ➡️
* {% deleted_rule java/bestpractices/PositionLiteralsFirstInComparisons %} ➡️
use {% rule "java/bestpractices/LiteralsFirstInComparisons" %}
* ReturnEmptyArrayRatherThanNull (java-errorprone) ➡️
* {% deleted_rule java/errorprone/ReturnEmptyArrayRatherThanNull %} ➡️
use {% rule "java/errorprone/ReturnEmptyCollectionRatherThanNull" %}
* ShortInstantiation (java-performance) ➡️ use {% rule "java/codestyle/UnnecessaryBoxing" %}
* {% deleted_rule java/performance/ShortInstantiation %} ➡️ use {% rule "java/codestyle/UnnecessaryBoxing" %}
and {% rule "java/bestpractices/PrimitiveWrapperInstantiation" %}
* SimplifyBooleanAssertion (java-design) ➡️ use {% rule "java/bestpractices/SimplifiableTestAssertion" %}
* SimplifyStartsWith (java-performance) ➡️ not replaced
* StdCyclomaticComplexity (java-design) ➡️ use {% rule "java/design/CyclomaticComplexity" %}
* SuspiciousConstantFieldName (java-codestyle) ➡️ use {% rule java/codestyle/FieldNamingConventions %}
* UnnecessaryWrapperObjectCreation (java-performance) ➡️ use the new rule {% rule "java/codestyle/UnnecessaryBoxing" %}
* UnsynchronizedStaticDateFormatter (java-multithreading) ➡️
use {% rule java/multithreading/UnsynchronizedStaticFormatter %}
* UnusedImports (java-bestpractices) ➡️ use {% rule java/codestyle/UnnecessaryImport %}
* UseAssertEqualsInsteadOfAssertTrue (java-bestpractices) ➡️
use {% rule "java/bestpractices/SimplifiableTestAssertion" %}
* UseAssertNullInsteadOfAssertEquals (java-bestpractices) ➡️
use {% rule "java/bestpractices/SimplifiableTestAssertion" %}
* UseAssertSameInsteadOfAssertEquals (java-bestpractices) ➡️
use {% rule "java/bestpractices/SimplifiableTestAssertion" %}
* UseAssertTrueInsteadOfAssertEquals (java-bestpractices) ➡️
use {% rule "java/bestpractices/SimplifiableTestAssertion" %}
* VariableNamingConventions (java-codestyle) ➡️ use {% rule java/codestyle/FieldNamingConventions %},
{% rule java/codestyle/FormalParameterNamingConventions %},
or {% rule java/codestyle/LocalVariableNamingConventions %}
* WhileLoopsMustUseBraces (java-codestyle) ➡️ use {% rule "java/codestyle/ControlStatementBraces" %}
* {% deleted_rule java/design/SimplifyBooleanAssertion %} ➡️ use {% rule "java/bestpractices/SimplifiableTestAssertion" %}
* {% deleted_rule java/performance/SimplifyStartsWith %} ➡️ not replaced
* {% deleted_rule java/design/StdCyclomaticComplexity %} ➡️ use {% rule "java/design/CyclomaticComplexity" %}
* {% deleted_rule java/codestyle/SuspiciousConstantFieldName %} ➡️ use {% rule java/codestyle/FieldNamingConventions %}
* {% deleted_rule java/performance/UnnecessaryWrapperObjectCreation %} ➡️ use the new rule {% rule "java/codestyle/UnnecessaryBoxing" %}
* {% deleted_rule java/multithreading/UnsynchronizedStaticDateFormatter %} ➡️ use {% rule java/multithreading/UnsynchronizedStaticFormatter %}
* {% deleted_rule java/bestpractices/UnusedImports %} ➡️ use {% rule java/codestyle/UnnecessaryImport %}
* {% deleted_rule java/bestpractices/UseAssertEqualsInsteadOfAssertTrue %} ➡️ use {% rule "java/bestpractices/SimplifiableTestAssertion" %}
* {% deleted_rule java/bestpractices/UseAssertNullInsteadOfAssertEquals %} ➡️ use {% rule "java/bestpractices/SimplifiableTestAssertion" %}
* {% deleted_rule java/bestpractices/UseAssertSameInsteadOfAssertEquals %} ➡️ use {% rule "java/bestpractices/SimplifiableTestAssertion" %}
* {% deleted_rule java/bestpractices/UseAssertTrueInsteadOfAssertEquals %} ➡️ use {% rule "java/bestpractices/SimplifiableTestAssertion" %}
* {% deleted_rule java/codestyle/VariableNamingConventions %} ➡️ use {% rule java/codestyle/FieldNamingConventions %},
{% rule java/codestyle/FormalParameterNamingConventions %}, or {% rule java/codestyle/LocalVariableNamingConventions %}
* {% deleted_rule java/codestyle/WhileLoopsMustUseBraces %} ➡️ use {% rule "java/codestyle/ControlStatementBraces" %}
## 💥 Compatibility and Migration Notes
@ -531,7 +526,7 @@ The full detailed documentation of the changes are available in the
* CLI changed: Custom scripts need to be updated (`run.sh pmd ...` ➡️ `pmd check ...`, `run.sh cpd ...`, `pmd cpd ...`).
* Java module revamped: Custom rules need to be updated.
* Removed rules: Custom rulesets need to be reviewed. See below for a list of new and removed rules.
* XPath 1.0 support is removed, `violationSuppressXPath` now requires XPath 2.0 or 3.1: Custom rulesets need
* XPath 1.0 and 2.0 support is removed, `violationSuppressXPath` now requires XPath 3.1: Custom rulesets need
to be reviewed.
* Custom rules using rulechains: Need to override {% jdoc core::lang.rule.AbstractRule#buildTargetSelector() %}
using {% jdoc core::lang.rule.RuleTargetSelector#forTypes(java.lang.Class,java.lang.Class...) %}.
@ -541,6 +536,7 @@ The full detailed documentation of the changes are available in the
The structure inside the ZIP files stay the same, e.g. we still provide inside the binary distribution
ZIP file the base directory `pmd-bin-<version>`.
* For maven-pmd-plugin usage, see [Using PMD 7 with maven-pmd-plugin](pmd_userdocs_tools_maven.html#using-pmd-7-with-maven-pmd-plugin).
### For integrators
@ -605,7 +601,7 @@ See [ADR 3 - API evolution principles](pmd_projectdocs_decisions_adr_3.html) and
### XPath 3.1 support
Support for XPath versions 1.0, 1.0-compatibility was removed, support for XPath 2.0 is deprecated. The default
Support for XPath versions 1.0, 1.0-compatibility, 2.0 was removed. 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.
@ -815,8 +811,8 @@ The following previously deprecated methods have been removed:
* pmd-core
* `net.sourceforge.pmd.properties.PropertyBuilder.GenericCollectionPropertyBuilder#delim(char)`
* `net.sourceforge.pmd.properties.PropertySource#setProperty(...)`
* `net.sourceforge.pmd.properties.PropertyTypeId#factoryFor(...)`
* `net.sourceforge.pmd.properties.PropertyTypeId#typeIdFor(...)`
* `net.sourceforge.pmd.properties.internal.PropertyTypeId#factoryFor(...)`
* `net.sourceforge.pmd.properties.internal.PropertyTypeId#typeIdFor(...)`
* `net.sourceforge.pmd.properties.PropertyDescriptor`: removed methods errorFor, type, isMultiValue,
uiOrder, compareTo, isDefinedExternally, valueFrom, asDelimitedString
@ -899,7 +895,7 @@ The following classes have been removed:
##### Internal APIs
* {% jdoc core::cpd.Tokens %}
* {% jdoc core::net.sourceforge.pmd.properties.PropertyTypeId %}
* {% jdoc core::net.sourceforge.pmd.properties.internal.PropertyTypeId %}
##### Deprecated API

View File

@ -203,11 +203,11 @@
<fileset dir="${target-package-dir}" />
</replaceregexp>
<replace token=".beginLine" value=".getBeginLine()">
<replace token=".beginLine" value=".getReportLocation().getStartLine()">
<fileset dir="${target-package-dir}" />
</replace>
<replace token=".beginColumn" value=".getBeginColumn()">
<replace token=".beginColumn" value=".getReportLocation().getStartColumn()">
<fileset dir="${target-package-dir}" />
</replace>
@ -283,7 +283,7 @@
<!-- Use own LexException instead of JavaCC's TokenMgrError -->
<replaceregexp>
<regexp pattern='throw new TokenMgrError\(EOFSeen' />
<substitution expression='throw new net.sourceforge.pmd.lang.ast.LexException(EOFSeen' />
<substitution expression='throw net.sourceforge.pmd.lang.ast.InternalApiBridge.newLexException(EOFSeen' />
<file name="${tokenmgr-file}" />
</replaceregexp>

View File

@ -28,7 +28,6 @@ import net.sourceforge.pmd.cpd.CPDReport;
import net.sourceforge.pmd.cpd.CPDReportRenderer;
import net.sourceforge.pmd.cpd.CSVRenderer;
import net.sourceforge.pmd.cpd.CpdAnalysis;
import net.sourceforge.pmd.cpd.CpdLanguageProperties;
import net.sourceforge.pmd.cpd.SimpleRenderer;
import net.sourceforge.pmd.cpd.XMLRenderer;
import net.sourceforge.pmd.lang.Language;
@ -79,7 +78,7 @@ public class CPDTask extends Task {
private boolean skipLexicalErrors;
private boolean skipDuplicateFiles;
private boolean skipBlocks = true;
private String skipBlocksPattern = CpdLanguageProperties.DEFAULT_SKIP_BLOCKS_PATTERN;
private String skipBlocksPattern;
private File outputFile;
private String encoding = System.getProperty("file.encoding");
private List<FileSet> filesets = new ArrayList<>();

View File

@ -26,7 +26,6 @@ import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.Parameter;
import net.sourceforge.pmd.annotation.InternalApi;
import net.sourceforge.pmd.internal.util.IOUtil;
import net.sourceforge.pmd.lang.document.TextFile;
import net.sourceforge.pmd.renderers.Renderer;
@ -35,9 +34,22 @@ import net.sourceforge.pmd.reporting.FileAnalysisListener;
import net.sourceforge.pmd.reporting.FileNameRenderer;
import net.sourceforge.pmd.reporting.GlobalAnalysisListener;
import net.sourceforge.pmd.reporting.ListenerInitializer;
import net.sourceforge.pmd.reporting.Report;
@InternalApi
/**
* Part of PMD Ant task configuration. Setters of this class are interpreted by Ant as properties
* settable in the XML. This is therefore published API.
*
* <p>This class is used to configure a specific {@link Renderer} for outputting the violations. This is called
* a formatter in PMD Ant task configuration and might look like this:
*
* <pre>{@code
* <pmd>
* <formatter type="html" toFile="${build}/pmd_report.html"/>
* </pmd>
* }</pre>
*
* @see PMDTask#addFormatter(Formatter)
*/
public class Formatter {
private File toFile;
@ -68,15 +80,7 @@ public class Formatter {
this.parameters.add(parameter);
}
@Deprecated
@InternalApi
public Renderer getRenderer() {
return renderer;
}
@Deprecated
@InternalApi
public void start(String baseDir) {
private void start(String baseDir) {
Properties properties = createProperties();
@ -122,25 +126,7 @@ public class Formatter {
}
}
@Deprecated
@InternalApi
public void end(Report errorReport) {
try {
renderer.renderFileReport(errorReport);
renderer.end();
if (toConsole) {
writer.flush();
} else {
writer.close();
}
} catch (IOException ioe) {
throw new BuildException(ioe.getMessage(), ioe);
}
}
@Deprecated
@InternalApi
public boolean isNoOutputSupplied() {
boolean isNoOutputSupplied() {
return toFile == null && !toConsole;
}
@ -248,12 +234,8 @@ public class Formatter {
return null;
}
@Deprecated
@InternalApi
public GlobalAnalysisListener newListener(Project project) throws IOException {
GlobalAnalysisListener newListener(Project project) throws IOException {
start(project.getBaseDir().toString());
Renderer renderer = getRenderer();
return new GlobalAnalysisListener() {
final GlobalAnalysisListener listener = renderer.newListener();

View File

@ -0,0 +1,32 @@
/*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.ant;
import java.io.IOException;
import org.apache.tools.ant.Project;
import net.sourceforge.pmd.annotation.InternalApi;
import net.sourceforge.pmd.reporting.GlobalAnalysisListener;
/**
* Internal API.
*
* <p>Acts as a bridge between outer parts of PMD and the restricted access
* internal API of this package.
*
* <p><b>None of this is published API, and compatibility can be broken anytime!</b>
* Use this only at your own risk.
*
* @apiNote Internal API
*/
@InternalApi
public final class InternalApiBridge {
private InternalApiBridge() {}
public static GlobalAnalysisListener newListener(Formatter formatter, Project project) throws IOException {
return formatter.newListener(project);
}
}

View File

@ -4,7 +4,6 @@
package net.sourceforge.pmd.ant;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
@ -15,9 +14,7 @@ import org.apache.tools.ant.Task;
import org.apache.tools.ant.types.FileSet;
import org.apache.tools.ant.types.Path;
import org.apache.tools.ant.types.Reference;
import org.apache.tools.ant.types.Resource;
import net.sourceforge.pmd.annotation.InternalApi;
import net.sourceforge.pmd.ant.internal.PMDTaskImpl;
import net.sourceforge.pmd.lang.rule.RulePriority;
@ -290,15 +287,4 @@ public class PMDTask extends Task {
public List<Path> getRelativizePathsWith() {
return relativizePathsWith;
}
@InternalApi
public List<java.nio.file.Path> getRelativizeRoots() {
List<java.nio.file.Path> paths = new ArrayList<>();
for (Path path : getRelativizePathsWith()) {
for (Resource resource : path) {
paths.add(Paths.get(resource.toString()));
}
}
return paths;
}
}

View File

@ -6,11 +6,12 @@ package net.sourceforge.pmd.ant;
/**
* @author Philippe T'Seyen
* @apiNote Internal API
*/
public class ReportException extends RuntimeException {
class ReportException extends RuntimeException {
private static final long serialVersionUID = 6043174086675858209L;
public ReportException(Throwable cause) {
ReportException(Throwable cause) {
super(cause);
}
}

View File

@ -4,6 +4,21 @@
package net.sourceforge.pmd.ant;
/**
* Part of PMD Ant task configuration. Setters of this class are interpreted by Ant as properties
* settable in the XML. This is therefore published API.
*
* <p>This class is used to configure {@link net.sourceforge.pmd.lang.rule.RuleSet} as nested XML tags.
* It might look like this:
*
* <pre>{@code
* <pmd>
* <ruleset>rulesets/java/quickstart.xml</ruleset>
* </pmd>
* }</pre>
*
* @see PMDTask#addRuleset(RuleSetWrapper)
*/
public class RuleSetWrapper {
private String file;

View File

@ -7,7 +7,19 @@ package net.sourceforge.pmd.ant;
import net.sourceforge.pmd.lang.Language;
/**
* Stores LanguageVersion terse name value.
* Part of PMD Ant task configuration. Setters of this class are interpreted by Ant as properties
* settable in the XML. This is therefore published API.
*
* <p>This class is used to configure the language and version to use.
* It might look like this:
*
* <pre>{@code
* <pmd>
* <sourceLanguage name="java" version="21"/>
* </pmd>
* }</pre>
*
* @see PMDTask#addConfiguredSourceLanguage(SourceLanguage)
*/
public class SourceLanguage {

Some files were not shown because too many files have changed in this diff Show More