diff --git a/.all-contributorsrc b/.all-contributorsrc index 312dff111e..531090e31d 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -6538,6 +6538,25 @@ "contributions": [ "code" ] + }, + { + "login": "JerritEic", + "name": "JerritEic", + "avatar_url": "https://avatars.githubusercontent.com/u/60690273?v=4", + "profile": "https://github.com/JerritEic", + "contributions": [ + "code", + "doc" + ] + }, + { + "login": "karel1980", + "name": "Karel Vervaeke", + "avatar_url": "https://avatars.githubusercontent.com/u/153021?v=4", + "profile": "https://github.com/karel1980", + "contributions": [ + "bug" + ] } ], "contributorsPerLine": 7, diff --git a/.ci/build.sh b/.ci/build.sh index 7d633a8e40..ebacd1cf0c 100755 --- a/.ci/build.sh +++ b/.ci/build.sh @@ -33,23 +33,6 @@ function build() { ./mvnw clean install --show-version --errors --batch-mode --no-transfer-progress "${PMD_MAVEN_EXTRA_OPTS[@]}" pmd_ci_log_group_end - if [ "$(pmd_ci_utils_get_os)" = "linux" ]; then - pmd_ci_log_group_start "Executing PMD dogfood test with ${PMD_CI_MAVEN_PROJECT_VERSION}" - ./mvnw versions:set -DnewVersion="${PMD_CI_MAVEN_PROJECT_VERSION}-dogfood" -DgenerateBackupPoms=false - sed -i 's/[0-9]\{1,\}\.[0-9]\{1,\}\.[0-9]\{1,\}.*<\/version>\( *\)/'"${PMD_CI_MAVEN_PROJECT_VERSION}"'<\/version>\1/' pom.xml - if [ "${PMD_CI_MAVEN_PROJECT_VERSION}" = "7.0.0-SNAPSHOT" ]; then - sed -i 's/pmd-dogfood-config\.xml/pmd-dogfood-config7.xml/' pom.xml - fi - ./mvnw verify --show-version --errors --batch-mode --no-transfer-progress "${PMD_MAVEN_EXTRA_OPTS[@]}" \ - -DskipTests \ - -Dmaven.javadoc.skip=true \ - -Dmaven.source.skip=true \ - -Dcheckstyle.skip=true - ./mvnw versions:set -DnewVersion="${PMD_CI_MAVEN_PROJECT_VERSION}" -DgenerateBackupPoms=false - git checkout -- pom.xml - pmd_ci_log_group_end - fi - # Danger is executed only on the linux runner if [ "$(pmd_ci_utils_get_os)" = "linux" ]; then pmd_ci_log_group_start "Executing danger" diff --git a/Gemfile.lock b/Gemfile.lock index 318dc9fa76..359c937c19 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -3,7 +3,7 @@ GEM specs: addressable (2.8.0) public_suffix (>= 2.0.2, < 5.0) - claide (1.0.3) + claide (1.1.0) claide-plugins (0.9.2) cork nap @@ -12,7 +12,7 @@ GEM concurrent-ruby (1.1.9) cork (0.3.0) colored2 (~> 3.1) - danger (8.4.2) + danger (8.4.3) claide (~> 1.0) claide-plugins (>= 0.9.2) colored2 (~> 3.1) @@ -28,16 +28,17 @@ GEM differ (0.1.2) et-orbi (1.2.6) tzinfo - faraday (1.8.0) + faraday (1.10.0) faraday-em_http (~> 1.0) faraday-em_synchrony (~> 1.0) faraday-excon (~> 1.1) - faraday-httpclient (~> 1.0.1) + faraday-httpclient (~> 1.0) + faraday-multipart (~> 1.0) faraday-net_http (~> 1.0) - faraday-net_http_persistent (~> 1.1) + faraday-net_http_persistent (~> 1.0) faraday-patron (~> 1.0) faraday-rack (~> 1.0) - multipart-post (>= 1.2, < 3) + faraday-retry (~> 1.0) ruby2_keywords (>= 0.0.4) faraday-em_http (1.0.0) faraday-em_synchrony (1.0.0) @@ -45,14 +46,17 @@ GEM faraday-http-cache (2.2.0) faraday (>= 0.8) faraday-httpclient (1.0.1) + faraday-multipart (1.0.3) + multipart-post (>= 1.2, < 3) faraday-net_http (1.0.1) faraday-net_http_persistent (1.2.0) faraday-patron (1.0.0) faraday-rack (1.0.0) + faraday-retry (1.0.3) fugit (1.5.2) et-orbi (~> 1.1, >= 1.1.8) raabro (~> 1.4) - git (1.10.0) + git (1.10.2) rchardet (~> 1.8) kramdown (2.3.1) rexml @@ -60,14 +64,14 @@ GEM kramdown (~> 2.0) liquid (5.1.0) logger-colors (1.0.0) - mini_portile2 (2.6.1) + mini_portile2 (2.8.0) multipart-post (2.1.1) nap (1.1.0) no_proxy_fix (0.1.2) - nokogiri (1.12.5) - mini_portile2 (~> 2.6.1) + nokogiri (1.13.3) + mini_portile2 (~> 2.8.0) racc (~> 1.4) - octokit (4.21.0) + octokit (4.22.0) faraday (>= 0.9) sawyer (~> 0.8.0, >= 0.5.3) open4 (1.3.4) @@ -83,9 +87,9 @@ GEM racc (1.6.0) rchardet (1.8.0) rexml (3.2.5) - rouge (3.27.0) + rouge (3.28.0) ruby2_keywords (0.0.5) - rufus-scheduler (3.8.0) + rufus-scheduler (3.8.1) fugit (~> 1.1, >= 1.1.6) safe_yaml (1.0.5) sawyer (0.8.2) diff --git a/docs/Gemfile.lock b/docs/Gemfile.lock index 5dd3c5f378..327bd7ca7d 100644 --- a/docs/Gemfile.lock +++ b/docs/Gemfile.lock @@ -1,7 +1,7 @@ GEM remote: https://rubygems.org/ specs: - activesupport (6.0.4.4) + activesupport (6.0.4.6) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 0.7, < 2) minitest (~> 5.1) @@ -17,7 +17,7 @@ GEM commonmarker (0.17.13) ruby-enum (~> 0.5) concurrent-ruby (1.1.9) - dnsruby (1.61.7) + dnsruby (1.61.9) simpleidn (~> 0.1) em-websocket (0.5.3) eventmachine (>= 0.12.9) @@ -26,29 +26,33 @@ GEM ffi (>= 1.15.0) eventmachine (1.2.7) execjs (2.8.1) - faraday (1.8.0) + faraday (1.10.0) faraday-em_http (~> 1.0) faraday-em_synchrony (~> 1.0) faraday-excon (~> 1.1) - faraday-httpclient (~> 1.0.1) + faraday-httpclient (~> 1.0) + faraday-multipart (~> 1.0) faraday-net_http (~> 1.0) - faraday-net_http_persistent (~> 1.1) + faraday-net_http_persistent (~> 1.0) faraday-patron (~> 1.0) faraday-rack (~> 1.0) - multipart-post (>= 1.2, < 3) + faraday-retry (~> 1.0) ruby2_keywords (>= 0.0.4) faraday-em_http (1.0.0) faraday-em_synchrony (1.0.0) faraday-excon (1.1.0) faraday-httpclient (1.0.1) + faraday-multipart (1.0.3) + multipart-post (>= 1.2, < 3) faraday-net_http (1.0.1) faraday-net_http_persistent (1.2.0) faraday-patron (1.0.0) faraday-rack (1.0.0) - ffi (1.15.4) + faraday-retry (1.0.3) + ffi (1.15.5) forwardable-extended (2.6.0) gemoji (3.0.1) - github-pages (222) + github-pages (223) github-pages-health-check (= 1.17.9) jekyll (= 3.9.0) jekyll-avatar (= 0.7.0) @@ -58,6 +62,7 @@ GEM jekyll-feed (= 0.15.1) jekyll-gist (= 1.5.0) jekyll-github-metadata (= 2.13.0) + jekyll-include-cache (= 0.2.1) jekyll-mentions (= 1.6.0) jekyll-optional-front-matter (= 0.3.2) jekyll-paginate (= 1.1.0) @@ -138,6 +143,8 @@ GEM jekyll-github-metadata (2.13.0) jekyll (>= 3.4, < 5.0) octokit (~> 4.0, != 4.4.0) + jekyll-include-cache (0.2.1) + jekyll (>= 3.7, < 5.0) jekyll-mentions (1.6.0) html-pipeline (~> 2.3) jekyll (>= 3.7, < 5.0) @@ -215,28 +222,28 @@ GEM kramdown-parser-gfm (1.1.0) kramdown (~> 2.0) liquid (4.0.3) - listen (3.7.0) + listen (3.7.1) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) mercenary (0.3.6) - mini_portile2 (2.6.1) + mini_portile2 (2.8.0) minima (2.5.1) jekyll (>= 3.5, < 5.0) jekyll-feed (~> 0.9) jekyll-seo-tag (~> 2.1) minitest (5.15.0) multipart-post (2.1.1) - nokogiri (1.12.5) - mini_portile2 (~> 2.6.1) + nokogiri (1.13.3) + mini_portile2 (~> 2.8.0) racc (~> 1.4) - octokit (4.21.0) + octokit (4.22.0) faraday (>= 0.9) sawyer (~> 0.8.0, >= 0.5.3) pathutil (0.16.2) forwardable-extended (~> 2.6) public_suffix (4.0.6) racc (1.6.0) - rb-fsevent (0.11.0) + rb-fsevent (0.11.1) rb-inotify (0.10.1) ffi (~> 1.0) rexml (3.2.5) @@ -267,7 +274,7 @@ GEM unf_ext unf_ext (0.0.8) unicode-display_width (1.8.0) - zeitwerk (2.5.1) + zeitwerk (2.5.4) PLATFORMS ruby diff --git a/docs/_config.yml b/docs/_config.yml index 33a4b91a50..d6fb4f1e22 100644 --- a/docs/_config.yml +++ b/docs/_config.yml @@ -2,7 +2,7 @@ repository: pmd/pmd pmd: version: 7.0.0-SNAPSHOT - previous_version: 6.42.0 + previous_version: 6.43.0 date: ??-?????-2022 release_type: major diff --git a/docs/_layouts/default.html b/docs/_layouts/default.html index 8637522433..95137215ae 100644 --- a/docs/_layouts/default.html +++ b/docs/_layouts/default.html @@ -9,26 +9,37 @@
{% include topnav.html %} -
-
 
- -
- {% assign content_col_size = "col-md-12" %} - {% unless page.hide_sidebar %} - -
- {% include sidebar.html %} -
- {% assign content_col_size = "col-md-9" %} - {% endunless %} +
+
+
 
+ +
+ {% assign content_col_size = "col-md-12" %} + {% unless page.hide_sidebar %} + +
+ {% include sidebar.html %} +
+ {% assign content_col_size = "col-md-9" %} + {% endunless %} - -
- {{content}} + +
+ {{content}} +
+ +
- +
- + + {% unless page.toc == false %} + +
+ {% include toc.html %} +
+ {% endunless %} +
diff --git a/docs/_layouts/page.html b/docs/_layouts/page.html index 63954a406f..2139dae1b6 100644 --- a/docs/_layouts/page.html +++ b/docs/_layouts/page.html @@ -12,9 +12,7 @@ layout: default
{{page.summary}}
{% endif %} - {% unless page.toc == false %} - {% include toc.html %} - {% endunless %} +
{% if site.github_editme_path %} diff --git a/docs/css/customstyles.css b/docs/css/customstyles.css index d4ac3d27ee..f66ed349c9 100644 --- a/docs/css/customstyles.css +++ b/docs/css/customstyles.css @@ -1,6 +1,70 @@ body { font-size:15px; } +@media (max-width: 1349px) { + /* Small screen, inline TOC*/ + .container-toc-wrapper { + display: block; + } + + div.toc-col { + display: none; + } + + div#toc{ + margin-top: 15px; + margin-left: 0px; + margin-right: 0px; + } + + .container { + margin-left: auto; + margin-right: auto; + } +} + +@media (min-width: 1350px) { + /* Medium screens, keep sticky TOC but remove justify-content*/ + div#toc{ + margin-top: 60px; + margin-left: -15px; + margin-right: 15px; + } + .container { + margin-left: 15px; + margin-right: 15px; + width: 75%; + } + + .container-toc-wrapper { + display: flex; + flex-wrap: wrap; + margin-left: auto; + margin-right: auto; + } +} +@media (min-width: 1600px) { + /* Sticky TOC functionality */ + div#toc{ + margin-top: 60px; + margin-left: -15px; + margin-right: 15px; + } + .container { + margin-left: 15px; + margin-right: 15px; + width: 75%; + } + + .container-toc-wrapper { + display: flex; + flex-wrap: wrap; + justify-content: center; + margin-left: auto; + margin-right: auto; + } +} + .bs-callout { padding: 20px; diff --git a/docs/js/customscripts.js b/docs/js/customscripts.js index 96aaa58cec..f9a32a6d5e 100644 --- a/docs/js/customscripts.js +++ b/docs/js/customscripts.js @@ -1,13 +1,23 @@ + +// Detect small devices and move the TOC in line +function moveToc(){ + if(window.innerWidth < 1350){ + $( "#toc" ).detach().appendTo("#inline-toc").removeClass("position-fixed"); + } else { + $( "#toc" ).detach().appendTo(".toc-col").addClass("position-fixed"); + } +} + $( document ).ready(function() { $('#mysidebar').height($(".nav").height()); - // this script says, if the height of the viewport is greater than 800px, then insert position-fixed class, + // this script says, if the height of the viewport is greater than 600px, then insert position-fixed class, // which makes the nav bar float in a fixed position as your scroll. If you have a lot of nav items, // this height may not work for you. var h = $(window).height(); //console.log (h); - if (h > 800) { + if (h > 600) { $( "#mysidebar" ).attr("class", "nav position-fixed"); } @@ -20,6 +30,8 @@ $( document ).ready(function() { * AnchorJS */ anchors.add('h2,h3,h4,h5'); + // Check if TOC needs to be moved on page load + moveToc(); // This highlights the active parent class in the navgoco sidebar. This is critical so that the parent expands // when you're viewing a page. @@ -71,3 +83,6 @@ $( document ).ready(function() { event.preventDefault(); }); }); + +// Check if TOC needs to be moved on window resizing +$(window).resize(function () {moveToc();}); \ No newline at end of file diff --git a/docs/pages/next_major_development.md b/docs/pages/next_major_development.md index c832067232..1d3eded530 100644 --- a/docs/pages/next_major_development.md +++ b/docs/pages/next_major_development.md @@ -246,6 +246,43 @@ the breaking API changes will be performed in 7.0.0. an API is tagged as `@Deprecated` or not in the latest minor release. During the development of 7.0.0, we may decide to remove some APIs that were not tagged as deprecated, though we'll try to avoid it." %} +#### 6.43.0 + +##### Deprecated API + +Some API deprecations were performed in core PMD classes, to improve compatibility with PMD 7. +- {% jdoc core::Report %}: the constructor and other construction methods like addViolation or createReport +- {% jdoc core::RuleContext %}: all constructors, getters and setters. A new set +of stable methods, matching those in PMD 7, was added to replace the `addViolation` +overloads of {% jdoc core::lang.rule.AbstractRule %}. In PMD 7, `RuleContext` will +be the API to report violations, and it can already be used as such in PMD 6. +- The field {% jdoc core::PMD#configuration %} is unused and will be removed. + +##### Internal API + +Those APIs are not intended to be used by clients, and will be hidden or removed with PMD 7.0.0. +You can identify them with the `@InternalApi` annotation. You'll also get a deprecation warning. + +- {% jdoc core::RuleSet %}: methods that serve to apply rules, including `apply`, `start`, `end`, `removeDysfunctionalRules` +- {% jdoc !!core::renderers.AbstractAccumulatingRenderer#renderFileReport(Report) %} is internal API + and should not be overridden in own renderers. + +##### Changed API + +It is now forbidden to report a violation: +- With a `null` node +- With a `null` message +- With a `null` set of format arguments (prefer a zero-length array) + +Note that the message is set from the XML rule declaration, so this is only relevant +if you instantiate rules manually. + +{% jdoc core::RuleContext %} now requires setting the current rule before calling +{% jdoc core::Rule#apply(java.util.List, core::RuleContext) %}. This is +done automatically by `RuleSet#apply` and such. Creating and configuring a +`RuleContext` manually is strongly advised against, as the lifecycle of `RuleContext` +will change drastically in PMD 7. + #### 6.42.0 No changes. diff --git a/docs/pages/pmd/projectdocs/credits.md b/docs/pages/pmd/projectdocs/credits.md index aa13cc5fb7..c2d45320d9 100644 --- a/docs/pages/pmd/projectdocs/credits.md +++ b/docs/pages/pmd/projectdocs/credits.md @@ -325,609 +325,613 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Jens Gerdes

πŸ›
Jeroen Borgers

πŸ›
Jerome Russ

πŸ› +
JerritEic

πŸ’» πŸ“–
Jiri Pejchal

πŸ› -
Jithin Sunny

πŸ› +
Jithin Sunny

πŸ›
JiΕ™Γ­ Ε korpil

πŸ›
Joao Machado

πŸ›
Jochen Krauss

πŸ›
Johan Hammar

πŸ›
John Karp

πŸ›
John Zhang

πŸ› -
John-Teng

πŸ’» πŸ› +
John-Teng

πŸ’» πŸ›
Jon Moroney

πŸ’» πŸ›
Jonas Geiregat

πŸ›
Jonathan Wiesel

πŸ’» πŸ›
Jordan

πŸ›
Jordi Llach

πŸ›
Jorge SolΓ³rzano

πŸ› -
JorneVL

πŸ› +
JorneVL

πŸ›
Jose Palafox

πŸ›
Jose Stovall

πŸ›
Joseph

πŸ’»
Joseph Heenan

πŸ›
Josh Feingold

πŸ’» πŸ›
Josh Holthaus

πŸ› -
Joshua S Arquilevich

πŸ› +
Joshua S Arquilevich

πŸ›
JoΓ£o Ferreira

πŸ’» πŸ›
JoΓ£o Pedro Schmitt

πŸ›
Juan MartΓ­n Sotuyo Dodero

πŸ’» πŸ“– πŸ› 🚧
Juan Pablo Civile

πŸ›
Julian Voronetsky

πŸ›
Julien

πŸ› -
Julius

πŸ› +
Julius

πŸ›
JustPRV

πŸ›
JΓΆrn Huxhorn

πŸ›
KThompso

πŸ›
Kai Amundsen

πŸ› +
Karel Vervaeke

πŸ›
Karl-Andero Mere

πŸ› -
Karl-Philipp Richter

πŸ› -
Karsten Silz

πŸ› +
Karl-Philipp Richter

πŸ› +
Karsten Silz

πŸ›
Kazuma Watanabe

πŸ›
Kev

πŸ›
Keve MΓΌller

πŸ›
Kevin Guerra

πŸ’»
Kevin Jones

πŸ› -
Kevin Wayne

πŸ› -
Kieran Black

πŸ› +
Kevin Wayne

πŸ› +
Kieran Black

πŸ›
Kirill Zubov

πŸ›
Kirk Clemens

πŸ’» πŸ›
Klaus Hartl

πŸ›
Koen Van Looveren

πŸ›
Kris Scheibe

πŸ’» πŸ› -
Kunal Thanki

πŸ› -
Larry Diamond

πŸ’» πŸ› +
Kunal Thanki

πŸ› +
Larry Diamond

πŸ’» πŸ›
Lars Knickrehm

πŸ›
Leo Gutierrez

πŸ›
Lintsi

πŸ›
Linus Fernandes

πŸ›
Lixon Lookose

πŸ› -
Logesh

πŸ› -
Lorenzo Gabriele

πŸ› +
Logesh

πŸ› +
Lorenzo Gabriele

πŸ›
LoΓ―c Ledoyen

πŸ›
Lucas Silva

πŸ›
Lucas Soncini

πŸ’» πŸ›
Lukasz Slonina

πŸ›
Lukebray

πŸ› -
Lyor Goldstein

πŸ› -
MCMicS

πŸ› +
Lyor Goldstein

πŸ› +
MCMicS

πŸ›
Macarse

πŸ›
Machine account for PMD

πŸ’»
Maciek Siemczyk

πŸ›
Maikel Steneker

πŸ’» πŸ›
Maksim Moiseikin

πŸ› -
Manfred Koch

πŸ› -
Manuel Moya Ferrer

πŸ’» πŸ› +
Manfred Koch

πŸ› +
Manuel Moya Ferrer

πŸ’» πŸ›
Manuel Ryan

πŸ›
Marat Vyshegorodtsev

πŸ›
Marcel HΓ€rle

πŸ›
Marcello Fialho

πŸ›
Marcin Rataj

πŸ› -
Mark Adamcin

πŸ› -
Mark Hall

πŸ’» πŸ› +
Mark Adamcin

πŸ› +
Mark Hall

πŸ’» πŸ›
Mark Kolich

πŸ›
Mark Pritchard

πŸ›
Markus Rathgeb

πŸ›
Marquis Wang

πŸ›
Martin Feldsztejn

πŸ› -
Martin Lehmann

πŸ› -
Martin Spamer

πŸ› +
Martin Lehmann

πŸ› +
Martin Spamer

πŸ›
Martin TarjΓ‘nyi

πŸ›
MatFl

πŸ›
Mateusz Stefanski

πŸ›
Mathieu Gouin

πŸ›
MatiasComercio

πŸ’» πŸ› -
Matt Benson

πŸ› -
Matt De Poorter

πŸ› +
Matt Benson

πŸ› +
Matt De Poorter

πŸ›
Matt Harrah

πŸ›
Matt Nelson

πŸ›
Matthew Amos

πŸ›
Matthew Duggan

πŸ›
Matthew Hall

πŸ› -
MatΓ­as Fraga

πŸ’» πŸ› -
Maxime Robert

πŸ’» πŸ› +
MatΓ­as Fraga

πŸ’» πŸ› +
Maxime Robert

πŸ’» πŸ›
Michael

πŸ›
Michael Bell

πŸ›
Michael Bernstein

πŸ›
Michael Clay

πŸ›
Michael Dombrowski

πŸ› -
Michael Hausegger

πŸ› -
Michael Hoefer

πŸ› +
Michael Hausegger

πŸ› +
Michael Hoefer

πŸ›
Michael MΓΆbius

πŸ›
Michael N. Lipp

πŸ›
Michael Pellegrini

πŸ›
Michal Kordas

πŸ›
MichaΕ‚ Borek

πŸ› -
MichaΕ‚ KuliΕ„ski

πŸ› -
Miguel NΓΊΓ±ez DΓ­az-Montes

πŸ› +
MichaΕ‚ KuliΕ„ski

πŸ› +
Miguel NΓΊΓ±ez DΓ­az-Montes

πŸ›
Mihai Ionut

πŸ›
Mirek Hankus

πŸ›
Mladjan Gadzic

πŸ›
MrAngry52

πŸ›
Muminur Choudhury

πŸ› -
Mykhailo Palahuta

πŸ’» πŸ› -
Nagendra Kumar Singh

πŸ› +
Mykhailo Palahuta

πŸ’» πŸ› +
Nagendra Kumar Singh

πŸ›
Nahuel Barrios

πŸ›
Nathan Braun

πŸ›
Nathan Reynolds

πŸ›
Nathan Reynolds

πŸ›
NathanaΓ«l

πŸ› -
Nazdravi

πŸ› -
Neha-Dhonde

πŸ› +
Nazdravi

πŸ› +
Neha-Dhonde

πŸ›
Nicholas Doyle

πŸ›
Nick Butcher

πŸ›
Nico Gallinal

πŸ›
Nicola Dal Maso

πŸ›
Nicolas Filotto

πŸ’» -
Nikita Chursin

πŸ› -
Niklas Baudy

πŸ› +
Nikita Chursin

πŸ› +
Niklas Baudy

πŸ›
Nikolas Havrikov

πŸ›
Nilesh Virkar

πŸ›
Nimit Patel

πŸ›
Niranjan Harpale

πŸ›
Noah Sussman

πŸ› -
Noah0120

πŸ› -
Noam Tamim

πŸ› +
Noah0120

πŸ› +
Noam Tamim

πŸ›
Noel Grandin

πŸ›
Olaf Haalstra

πŸ›
Oleg Pavlenko

πŸ›
Oleksii Dykov

πŸ’»
Oliver Eikemeier

πŸ› -
Olivier Parent

πŸ’» πŸ› -
Ollie Abbey

πŸ’» πŸ› +
Olivier Parent

πŸ’» πŸ› +
Ollie Abbey

πŸ’» πŸ›
OverDrone

πŸ›
Ozan Gulle

πŸ’» πŸ›
PUNEET JAIN

πŸ›
Parbati Bose

πŸ›
Paul Berg

πŸ› -
Pavel Bludov

πŸ› -
Pavel Mička

πŸ› +
Pavel Bludov

πŸ› +
Pavel Mička

πŸ›
Pedro Nuno Santos

πŸ›
Pedro Rijo

πŸ›
Pelisse Romain

πŸ’» πŸ“– πŸ›
Pete Davids

πŸ›
Peter Bruin

πŸ› -
Peter Chittum

πŸ’» πŸ› -
Peter Cudmore

πŸ› +
Peter Chittum

πŸ’» πŸ› +
Peter Cudmore

πŸ›
Peter Kasson

πŸ›
Peter Kofler

πŸ›
Pham Hai Trung

πŸ›
Philip Graf

πŸ’» πŸ›
Philip Hachey

πŸ› -
Philippe Ozil

πŸ› -
Phinehas Artemix

πŸ› +
Philippe Ozil

πŸ› +
Phinehas Artemix

πŸ›
Phokham Nonava

πŸ›
Piotr SzymaΕ„ski

πŸ›
Piotrek Ε»ygieΕ‚o

πŸ’» πŸ›
Pranay Jaiswal

πŸ›
Prasad Kamath

πŸ› -
Prasanna

πŸ› -
Presh-AR

πŸ› +
Prasanna

πŸ› +
Presh-AR

πŸ›
Puneet1726

πŸ›
Rafael CortΓͺs

πŸ›
RaheemShaik999

πŸ›
RajeshR

πŸ’» πŸ›
Ramachandra Mohan

πŸ› -
Raquel Pau

πŸ› -
Ravikiran Janardhana

πŸ› +
Raquel Pau

πŸ› +
Ravikiran Janardhana

πŸ›
Reda Benhemmouche

πŸ›
Renato Oliveira

πŸ’» πŸ›
Rich DiCroce

πŸ›
Riot R1cket

πŸ›
Rishabh Jain

πŸ› -
RishabhDeep Singh

πŸ› -
Robbie Martinus

πŸ’» πŸ› +
RishabhDeep Singh

πŸ› +
Robbie Martinus

πŸ’» πŸ›
Robert Henry

πŸ›
Robert Painsi

πŸ›
Robert Russell

πŸ›
Robert SΓΆsemann

πŸ’» πŸ“– πŸ“’ πŸ›
Robert Whitebit

πŸ› -
Robin Richtsfeld

πŸ› -
Robin Stocker

πŸ’» πŸ› +
Robin Richtsfeld

πŸ› +
Robin Stocker

πŸ’» πŸ›
Robin Wils

πŸ›
RochusOest

πŸ›
Rodolfo Noviski

πŸ›
Rodrigo Casara

πŸ›
Rodrigo Fernandes

πŸ› -
Roman Salvador

πŸ’» πŸ› -
Ronald Blaschke

πŸ› +
Roman Salvador

πŸ’» πŸ› +
Ronald Blaschke

πŸ›
RΓ³bert Papp

πŸ›
Saikat Sengupta

πŸ›
Saksham Handu

πŸ›
Saladoc

πŸ›
Salesforce Bob Lightning

πŸ› -
Sam Carlberg

πŸ› -
Satoshi Kubo

πŸ› +
Sam Carlberg

πŸ› +
Satoshi Kubo

πŸ›
Scott Kennedy

πŸ›
Scott Wells

πŸ› πŸ’»
Sebastian BΓΆgl

πŸ›
Sebastian Schuberth

πŸ›
Sebastian Schwarz

πŸ› -
Sergey Gorbaty

πŸ› -
Sergey Kozlov

πŸ› +
Sergey Gorbaty

πŸ› +
Sergey Kozlov

πŸ›
Sergey Yanzin

πŸ’» πŸ›
Shubham

πŸ’» πŸ›
Simon Xiao

πŸ›
Srinivasan Venkatachalam

πŸ›
Stanislav Gromov

πŸ› -
Stanislav Myachenkov

πŸ’» -
Stefan Birkner

πŸ› +
Stanislav Myachenkov

πŸ’» +
Stefan Birkner

πŸ›
Stefan Bohn

πŸ›
Stefan Endrullis

πŸ›
Stefan KlΓΆss-Schuster

πŸ›
Stefan Wolf

πŸ›
Stephan H. Wissel

πŸ› -
Stephen

πŸ› -
Stephen Friedrich

πŸ› +
Stephen

πŸ› +
Stephen Friedrich

πŸ›
Steve Babula

πŸ’»
Stexxe

πŸ›
Stian LΓ₯gstad

πŸ›
StuartClayton5

πŸ›
Supun Arunoda

πŸ› -
Suren Abrahamyan

πŸ› -
SwatiBGupta1110

πŸ› +
Suren Abrahamyan

πŸ› +
SwatiBGupta1110

πŸ›
SyedThoufich

πŸ›
Szymon Sasin

πŸ›
T-chuangxin

πŸ›
TERAI Atsuhiro

πŸ›
TIOBE Software

πŸ’» πŸ› -
Taylor Smock

πŸ› -
Techeira DamiΓ‘n

πŸ’» πŸ› +
Taylor Smock

πŸ› +
Techeira DamiΓ‘n

πŸ’» πŸ›
Ted Husted

πŸ›
TehBakker

πŸ›
The Gitter Badger

πŸ›
Theodoor

πŸ›
Thiago Henrique HΓΌpner

πŸ› -
Thibault Meyer

πŸ› -
Thomas GΓΌttler

πŸ› +
Thibault Meyer

πŸ› +
Thomas GΓΌttler

πŸ›
Thomas Jones-Low

πŸ›
Thomas Smith

πŸ’» πŸ›
ThrawnCA

πŸ›
Thunderforge

πŸ’» πŸ›
Tim van der Lippe

πŸ› -
Tobias Weimer

πŸ’» πŸ› -
Tom Daly

πŸ› +
Tobias Weimer

πŸ’» πŸ› +
Tom Daly

πŸ›
Tomer Figenblat

πŸ›
Tomi De Lucca

πŸ’» πŸ›
Torsten Kleiber

πŸ›
TrackerSB

πŸ›
Ullrich Hafner

πŸ› -
Utku Cuhadaroglu

πŸ’» πŸ› -
Valentin Brandl

πŸ› +
Utku Cuhadaroglu

πŸ’» πŸ› +
Valentin Brandl

πŸ›
Valeria

πŸ›
Vasily Anisimov

πŸ›
Vickenty Fesunov

πŸ›
Victor NoΓ«l

πŸ›
Vincent Galloy

πŸ’» -
Vincent HUYNH

πŸ› -
Vincent Maurin

πŸ› +
Vincent HUYNH

πŸ› +
Vincent Maurin

πŸ›
Vincent Privat

πŸ›
Vishhwas

πŸ›
Vitaly

πŸ›
Vitaly Polonetsky

πŸ›
Vojtech Polivka

πŸ› -
Vsevolod Zholobov

πŸ› -
Vyom Yadav

πŸ’» +
Vsevolod Zholobov

πŸ› +
Vyom Yadav

πŸ’»
Wang Shidong

πŸ›
Waqas Ahmed

πŸ›
Wayne J. Earl

πŸ›
Wchenghui

πŸ›
Will Winder

πŸ› -
William Brockhus

πŸ’» πŸ› -
Wilson Kurniawan

πŸ› +
William Brockhus

πŸ’» πŸ› +
Wilson Kurniawan

πŸ›
Wim Deblauwe

πŸ›
Woongsik Choi

πŸ›
XenoAmess

πŸ’» πŸ›
Yang

πŸ’»
YaroslavTER

πŸ› -
Young Chan

πŸ’» πŸ› -
YuJin Kim

πŸ› +
Young Chan

πŸ’» πŸ› +
YuJin Kim

πŸ›
Yuri Dolzhenko

πŸ›
Yurii Dubinka

πŸ›
Zoltan Farkas

πŸ›
Zustin

πŸ›
aaronhurst-google

πŸ› -
alexmodis

πŸ› -
andreoss

πŸ› +
alexmodis

πŸ› +
andreoss

πŸ›
andrey81inmd

πŸ’» πŸ›
anicoara

πŸ›
arunprasathav

πŸ›
asiercamara

πŸ›
astillich-igniti

πŸ’» -
avesolovksyy

πŸ› -
avishvat

πŸ› +
avesolovksyy

πŸ› +
avishvat

πŸ›
avivmu

πŸ›
axelbarfod1

πŸ›
b-3-n

πŸ›
balbhadra9

πŸ›
base23de

πŸ› -
bergander

πŸ› -
berkam

πŸ’» πŸ› +
bergander

πŸ› +
berkam

πŸ’» πŸ›
breizh31

πŸ›
caesarkim

πŸ›
carolyujing

πŸ›
cesares-basilico

πŸ›
chrite

πŸ› -
cobratbq

πŸ› -
coladict

πŸ› +
cobratbq

πŸ› +
coladict

πŸ›
cosmoJFH

πŸ›
cristalp

πŸ›
crunsk

πŸ›
cwholmes

πŸ›
cyberjj999

πŸ› -
cyw3

πŸ› -
d1ss0nanz

πŸ› +
cyw3

πŸ› +
d1ss0nanz

πŸ›
danbrycefairsailcom

πŸ›
dariansanity

πŸ›
darrenmiliband

πŸ›
davidburstrom

πŸ›
dbirkman-paloalto

πŸ› -
deepak-patra

πŸ› -
dependabot[bot]

πŸ’» πŸ› +
deepak-patra

πŸ› +
dependabot[bot]

πŸ’» πŸ›
dinesh150

πŸ›
diziaq

πŸ›
dreaminpast123

πŸ›
duanyanan

πŸ›
dutt-sanjay

πŸ› -
dylanleung

πŸ› -
dzeigler

πŸ› +
dylanleung

πŸ› +
dzeigler

πŸ›
ekkirala

πŸ›
emersonmoura

πŸ›
fairy

πŸ›
foxmason

πŸ›
frankegabor

πŸ› -
frankl

πŸ› -
freafrea

πŸ› +
frankl

πŸ› +
freafrea

πŸ›
fsapatin

πŸ›
gracia19

πŸ›
guo fei

πŸ›
gurmsc5

πŸ›
gwilymatgearset

πŸ’» πŸ› -
haigsn

πŸ› -
hemanshu070

πŸ› +
haigsn

πŸ› +
hemanshu070

πŸ›
henrik242

πŸ›
hongpuwu

πŸ›
hvbtup

πŸ’» πŸ›
igniti GmbH

πŸ›
ilovezfs

πŸ› -
itaigilo

πŸ› -
jakivey32

πŸ› +
itaigilo

πŸ› +
jakivey32

πŸ›
jbennett2091

πŸ›
jcamerin

πŸ›
jkeener1

πŸ›
jmetertea

πŸ›
johnra2

πŸ’» -
josemanuelrolon

πŸ’» πŸ› -
kabroxiko

πŸ’» πŸ› +
josemanuelrolon

πŸ’» πŸ› +
kabroxiko

πŸ’» πŸ›
karwer

πŸ›
kaulonline

πŸ›
kdaemonv

πŸ›
kenji21

πŸ’» πŸ›
kfranic

πŸ› -
khalidkh

πŸ› -
krzyk

πŸ› +
khalidkh

πŸ› +
krzyk

πŸ›
lasselindqvist

πŸ›
lihuaib

πŸ›
lonelyma1021

πŸ›
lpeddy

πŸ›
lujiefsi

πŸ’» -
lyriccoder

πŸ› -
marcelmore

πŸ› +
lyriccoder

πŸ› +
marcelmore

πŸ›
matchbox

πŸ›
matthiaskraaz

πŸ›
meandonlyme

πŸ›
mikesive

πŸ›
milossesic

πŸ› -
mriddell95

πŸ› -
mrlzh

πŸ› +
mriddell95

πŸ› +
mrlzh

πŸ›
msloan

πŸ›
mucharlaravalika

πŸ›
mvenneman

πŸ›
nareshl119

πŸ›
nicolas-harraudeau-sonarsource

πŸ› -
noerremark

πŸ› -
novsirion

πŸ› +
noerremark

πŸ› +
novsirion

πŸ›
oggboy

πŸ›
oinume

πŸ›
orimarko

πŸ’» πŸ›
pallavi agarwal

πŸ›
parksungrin

πŸ› -
patpatpat123

πŸ› -
patriksevallius

πŸ› +
patpatpat123

πŸ› +
patriksevallius

πŸ›
pbrajesh1

πŸ›
phoenix384

πŸ›
piotrszymanski-sc

πŸ’»
plan3d

πŸ›
poojasix

πŸ› -
prabhushrikant

πŸ› -
pujitha8783

πŸ› +
prabhushrikant

πŸ› +
pujitha8783

πŸ›
r-r-a-j

πŸ›
raghujayjunk

πŸ›
rajeshveera

πŸ›
rajeswarreddy88

πŸ›
recdevs

πŸ› -
reudismam

πŸ’» πŸ› -
rijkt

πŸ› +
reudismam

πŸ’» πŸ› +
rijkt

πŸ›
rillig-tk

πŸ›
rmohan20

πŸ’» πŸ›
rxmicro

πŸ›
ryan-gustafson

πŸ’» πŸ›
sabi0

πŸ› -
scais

πŸ› -
sebbASF

πŸ› +
scais

πŸ› +
sebbASF

πŸ›
sergeygorbaty

πŸ’»
shilko2013

πŸ›
simeonKondr

πŸ›
snajberk

πŸ›
sniperrifle2004

πŸ› -
snuyanzin

πŸ› πŸ’» -
sratz

πŸ› +
snuyanzin

πŸ› πŸ’» +
sratz

πŸ›
stonio

πŸ›
sturton

πŸ’» πŸ›
sudharmohan

πŸ›
suruchidawar

πŸ›
svenfinitiv

πŸ› -
tashiscool

πŸ› -
test-git-hook

πŸ› +
tashiscool

πŸ› +
test-git-hook

πŸ›
testation21

πŸ’» πŸ›
thanosa

πŸ›
tiandiyixian

πŸ›
tobwoerk

πŸ›
tprouvot

πŸ› -
trentchilders

πŸ› -
triandicAnt

πŸ› +
trentchilders

πŸ› +
triandicAnt

πŸ›
trishul14

πŸ›
tsui

πŸ›
winhkey

πŸ›
witherspore

πŸ›
wjljack

πŸ› -
wuchiuwong

πŸ› -
xingsong

πŸ› +
wuchiuwong

πŸ› +
xingsong

πŸ›
xioayuge

πŸ›
xnYi9wRezm

πŸ’» πŸ›
xuanuy

πŸ›
xyf0921

πŸ›
yalechen-cyw3

πŸ› -
yasuharu-sato

πŸ› -
zenglian

πŸ› +
yasuharu-sato

πŸ› +
zenglian

πŸ›
zgrzyt93

πŸ’» πŸ›
zh3ng

πŸ›
zt_soft

πŸ›
ztt79

πŸ›
zzzzfeng

πŸ› + +
ÁrpÑd MagosÑnyi

πŸ›
任贡杰

πŸ› diff --git a/docs/pages/pmd/userdocs/tools/ant.md b/docs/pages/pmd/userdocs/tools/ant.md index 9eaf415b6b..638805f356 100644 --- a/docs/pages/pmd/userdocs/tools/ant.md +++ b/docs/pages/pmd/userdocs/tools/ant.md @@ -122,6 +122,14 @@ The examples below won't repeat this taskdef element, as this is always required No + + threads + + Sets the number of threads used by PMD. Set threads to 0 to disable multi-threading processing. + Default: 1 + + No + diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index f22c8624a1..8abb75f161 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -21,59 +21,9 @@ This is a {{ site.pmd.release_type }} release. ### Fixed Issues -* core - * [#3427](https://github.com/pmd/pmd/issues/3427): \[core] Stop printing CLI usage text when exiting due to invalid parameters -* java - * [#3698](https://github.com/pmd/pmd/issues/3697): \[java] Parsing error with try-with-resources and qualified resource -* java-codestyle - * [#278](https://github.com/pmd/pmd/issues/278): \[java] ConfusingTernary should treat `!= null` as positive condition -* java-performance - * [#3374](https://github.com/pmd/pmd/issues/3374): \[java] UseStringBufferForStringAppends: Wrong example in documentation -* misc - * [#3759](https://github.com/pmd/pmd/issues/3759): \[lang-test] Upgrade dokka maven plugin to 1.4.32 -* plsql - * [#3746](https://github.com/pmd/pmd/issues/3746): \[plsql] Parsing exception "Less than or equal to/Greater than or equal to" operators in DML statements - ### API Changes -#### Deprecated API - -Some API deprecations were performed in core PMD classes, to improve compatibility with PMD 7. -- {% jdoc core::Report %}: the constructor and other construction methods like addViolation or createReport -- {% jdoc core::RuleContext %}: all constructors, getters and setters. A new set -of stable methods, matching those in PMD 7, was added to replace the `addViolation` -overloads of {% jdoc core::lang.rule.AbstractRule %}. In PMD 7, `RuleContext` will -be the API to report violations, and it can already be used as such in PMD 6. -- The field {% jdoc core::PMD#configuration %} is unused and will be removed. - -#### Internal API - -Those APIs are not intended to be used by clients, and will be hidden or removed with PMD 7.0.0. -You can identify them with the `@InternalApi` annotation. You'll also get a deprecation warning. - -- {% jdoc core::RuleSet %}: methods that serve to apply rules, including `apply`, `start`, `end`, `removeDysfunctionalRules` -- {% jdoc !!core::renderers.AbstractAccumulatingRenderer#renderFileReport(Report) %} is internal API - and should not be overridden in own renderers. - -#### Changed API - -It is now forbidden to report a violation: -- With a `null` node -- With a `null` message -- With a `null` set of format arguments (prefer a zero-length array) - -Note that the message is set from the XML rule declaration, so this is only relevant -if you instantiate rules manually. - -{% jdoc core::RuleContext %} now requires setting the current rule before calling -{% jdoc core::Rule#apply(java.util.List, core::RuleContext) %}. This is -done automatically by `RuleSet#apply` and such. Creating and configuring a -`RuleContext` manually is strongly advised against, as the lifecycle of `RuleContext` -will change drastically in PMD 7. - ### External Contributions -* [#3767](https://github.com/pmd/pmd/pull/3767): \[core] Update GUI.java - [Vyom Yadav](https://github.com/Vyom-Yadav) - {% endtocmaker %} diff --git a/docs/pages/release_notes_old.md b/docs/pages/release_notes_old.md index 9d9184d4bd..f7cc315efb 100644 --- a/docs/pages/release_notes_old.md +++ b/docs/pages/release_notes_old.md @@ -5,6 +5,93 @@ permalink: pmd_release_notes_old.html Previous versions of PMD can be downloaded here: https://github.com/pmd/pmd/releases +## 26-February-2022 - 6.43.0 + +The PMD team is pleased to announce PMD 6.43.0. + +This is a minor release. + +### Table Of Contents + +* [New and noteworthy](#new-and-noteworthy) +* [Fixed Issues](#fixed-issues) +* [API Changes](#api-changes) + * [Deprecated API](#deprecated-api) + * [Internal API](#internal-api) + * [Changed API](#changed-api) +* [External Contributions](#external-contributions) +* [Stats](#stats) + +### New and noteworthy + +### Fixed Issues + +* core + * [#3427](https://github.com/pmd/pmd/issues/3427): \[core] Stop printing CLI usage text when exiting due to invalid parameters + * [#3768](https://github.com/pmd/pmd/issues/3768): \[core] SARIF formatter reports multiple locations when it should report multiple results +* doc + * [#2502](https://github.com/pmd/pmd/issues/2502): \[doc] Add floating table-of-contents (toc) on the right + * [#3807](https://github.com/pmd/pmd/pull/3807): \[doc] Document Ant Task parameter `threads` +* java + * [#3698](https://github.com/pmd/pmd/issues/3697): \[java] Parsing error with try-with-resources and qualified resource +* java-bestpractices + * [#3605](https://github.com/pmd/pmd/issues/3605): \[java] SwitchStmtsShouldHaveDefault triggered when default case is present +* java-codestyle + * [#278](https://github.com/pmd/pmd/issues/278): \[java] ConfusingTernary should treat `!= null` as positive condition +* java-performance + * [#3374](https://github.com/pmd/pmd/issues/3374): \[java] UseStringBufferForStringAppends: Wrong example in documentation +* misc + * [#3759](https://github.com/pmd/pmd/issues/3759): \[lang-test] Upgrade dokka maven plugin to 1.4.32 +* plsql + * [#3746](https://github.com/pmd/pmd/issues/3746): \[plsql] Parsing exception "Less than or equal to/Greater than or equal to" operators in DML statements + +### API Changes + +#### Deprecated API + +Some API deprecations were performed in core PMD classes, to improve compatibility with PMD 7. +- Report: the constructor and other construction methods like addViolation or createReport +- RuleContext: all constructors, getters and setters. A new set +of stable methods, matching those in PMD 7, was added to replace the `addViolation` +overloads of AbstractRule. In PMD 7, `RuleContext` will +be the API to report violations, and it can already be used as such in PMD 6. +- The field configuration is unused and will be removed. + +#### Internal API + +Those APIs are not intended to be used by clients, and will be hidden or removed with PMD 7.0.0. +You can identify them with the `@InternalApi` annotation. You'll also get a deprecation warning. + +- RuleSet: methods that serve to apply rules, including `apply`, `start`, `end`, `removeDysfunctionalRules` +- AbstractAccumulatingRenderer#renderFileReport is internal API + and should not be overridden in own renderers. + +#### Changed API + +It is now forbidden to report a violation: +- With a `null` node +- With a `null` message +- With a `null` set of format arguments (prefer a zero-length array) + +Note that the message is set from the XML rule declaration, so this is only relevant +if you instantiate rules manually. + +RuleContext now requires setting the current rule before calling +apply. This is +done automatically by `RuleSet#apply` and such. Creating and configuring a +`RuleContext` manually is strongly advised against, as the lifecycle of `RuleContext` +will change drastically in PMD 7. + +### External Contributions + +* [#3767](https://github.com/pmd/pmd/pull/3767): \[core] Update GUI.java - [Vyom Yadav](https://github.com/Vyom-Yadav) +* [#3804](https://github.com/pmd/pmd/pull/3804): \[doc] Add floating table of contents (issue #2502) - [JerritEic](https://github.com/JerritEic) + +### Stats +* 49 commits +* 22 closed tickets & PRs +* Days since last release: 27 + ## 29-January-2022 - 6.42.0 The PMD team is pleased to announce PMD 6.42.0. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/ant/PMDTask.java b/pmd-core/src/main/java/net/sourceforge/pmd/ant/PMDTask.java index 378b8396e2..ba9367ad15 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/ant/PMDTask.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/ant/PMDTask.java @@ -30,7 +30,7 @@ public class PMDTask extends Task { private String rulesetFiles; private boolean noRuleSetCompatibility; private String encoding; - private int threads; + private int threads = 1; // same default as in PMDParameters (CLI) private int minimumPriority; private int maxRuleViolations = 0; private String failuresPropertyName; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cli/PMDParameters.java b/pmd-core/src/main/java/net/sourceforge/pmd/cli/PMDParameters.java index 1dc44417cb..892093af24 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cli/PMDParameters.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cli/PMDParameters.java @@ -64,7 +64,7 @@ public class PMDParameters { @Parameter(names = { "--threads", "-threads", "-t" }, description = "Sets the number of threads used by PMD.", validateWith = PositiveInteger.class) - private int threads = 1; + private int threads = 1; // see also default in PMDTask (Ant) @Parameter(names = { "--benchmark", "-benchmark", "-b" }, description = "Benchmark mode - output a benchmark report upon completion; default to System.err.") diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/internal/sarif/SarifLogBuilder.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/internal/sarif/SarifLogBuilder.java index 8732432982..23fa770a0c 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/internal/sarif/SarifLogBuilder.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/internal/sarif/SarifLogBuilder.java @@ -4,38 +4,36 @@ package net.sourceforge.pmd.renderers.internal.sarif; -import static net.sourceforge.pmd.renderers.internal.sarif.SarifLog.ArtifactLocation; -import static net.sourceforge.pmd.renderers.internal.sarif.SarifLog.AssociatedRule; -import static net.sourceforge.pmd.renderers.internal.sarif.SarifLog.Component; -import static net.sourceforge.pmd.renderers.internal.sarif.SarifLog.Exception; -import static net.sourceforge.pmd.renderers.internal.sarif.SarifLog.Invocation; -import static net.sourceforge.pmd.renderers.internal.sarif.SarifLog.Location; -import static net.sourceforge.pmd.renderers.internal.sarif.SarifLog.Message; -import static net.sourceforge.pmd.renderers.internal.sarif.SarifLog.MultiformatMessage; -import static net.sourceforge.pmd.renderers.internal.sarif.SarifLog.PhysicalLocation; -import static net.sourceforge.pmd.renderers.internal.sarif.SarifLog.PropertyBag; -import static net.sourceforge.pmd.renderers.internal.sarif.SarifLog.Region; -import static net.sourceforge.pmd.renderers.internal.sarif.SarifLog.ReportingDescriptor; -import static net.sourceforge.pmd.renderers.internal.sarif.SarifLog.Result; -import static net.sourceforge.pmd.renderers.internal.sarif.SarifLog.Run; -import static net.sourceforge.pmd.renderers.internal.sarif.SarifLog.Tool; -import static net.sourceforge.pmd.renderers.internal.sarif.SarifLog.ToolConfigurationNotification; -import static net.sourceforge.pmd.renderers.internal.sarif.SarifLog.ToolExecutionNotification; - import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; -import java.util.HashMap; import java.util.HashSet; import java.util.List; -import java.util.Map; import net.sourceforge.pmd.PMDVersion; import net.sourceforge.pmd.Report; import net.sourceforge.pmd.RuleViolation; +import net.sourceforge.pmd.renderers.internal.sarif.SarifLog.ArtifactLocation; +import net.sourceforge.pmd.renderers.internal.sarif.SarifLog.AssociatedRule; +import net.sourceforge.pmd.renderers.internal.sarif.SarifLog.Component; +import net.sourceforge.pmd.renderers.internal.sarif.SarifLog.Exception; +import net.sourceforge.pmd.renderers.internal.sarif.SarifLog.Invocation; +import net.sourceforge.pmd.renderers.internal.sarif.SarifLog.Location; +import net.sourceforge.pmd.renderers.internal.sarif.SarifLog.Message; +import net.sourceforge.pmd.renderers.internal.sarif.SarifLog.MultiformatMessage; +import net.sourceforge.pmd.renderers.internal.sarif.SarifLog.PhysicalLocation; +import net.sourceforge.pmd.renderers.internal.sarif.SarifLog.PropertyBag; +import net.sourceforge.pmd.renderers.internal.sarif.SarifLog.Region; +import net.sourceforge.pmd.renderers.internal.sarif.SarifLog.ReportingDescriptor; +import net.sourceforge.pmd.renderers.internal.sarif.SarifLog.Result; +import net.sourceforge.pmd.renderers.internal.sarif.SarifLog.Run; +import net.sourceforge.pmd.renderers.internal.sarif.SarifLog.Tool; +import net.sourceforge.pmd.renderers.internal.sarif.SarifLog.ToolConfigurationNotification; +import net.sourceforge.pmd.renderers.internal.sarif.SarifLog.ToolExecutionNotification; public class SarifLogBuilder { - private final Map> locationsByRule = new HashMap<>(); + private final List rules = new ArrayList<>(); + private final List results = new ArrayList<>(); private final List toolConfigurationNotifications = new ArrayList<>(); private final List toolExecutionNotifications = new ArrayList<>(); @@ -45,11 +43,15 @@ public class SarifLogBuilder { public SarifLogBuilder add(RuleViolation violation) { final ReportingDescriptor ruleDescriptor = getReportingDescriptor(violation); - final Location location = getRuleViolationLocation(violation); + int ruleIndex = rules.indexOf(ruleDescriptor); + if (ruleIndex == -1) { + rules.add(ruleDescriptor); + ruleIndex = rules.size() - 1; + } - final List ruleLocation = locationsByRule.containsKey(ruleDescriptor) ? locationsByRule.get(ruleDescriptor) : new ArrayList<>(); - ruleLocation.add(location); - locationsByRule.put(ruleDescriptor, ruleLocation); + final Location location = getRuleViolationLocation(violation); + final Result result = resultFrom(ruleDescriptor, ruleIndex, location); + results.add(result); return this; } @@ -105,15 +107,6 @@ public class SarifLogBuilder { } public SarifLog build() { - final List rules = new ArrayList<>(locationsByRule.keySet()); - - final List results = new ArrayList<>(); - for (int i = 0, size = rules.size(); i < size; i++) { - ReportingDescriptor rule = rules.get(i); - List locations = locationsByRule.get(rule); - results.add(resultFrom(rule, i, locations)); - } - final Component driver = getDriverComponent().toBuilder().rules(rules).build(); final Tool tool = Tool.builder().driver(driver).build(); final Invocation invocation = Invocation.builder() @@ -136,7 +129,7 @@ public class SarifLogBuilder { return toolExecutionNotifications.isEmpty() && toolConfigurationNotifications.isEmpty(); } - private Result resultFrom(ReportingDescriptor rule, Integer ruleIndex, List locations) { + private Result resultFrom(ReportingDescriptor rule, Integer ruleIndex, Location location) { final Result result = Result.builder() .ruleId(rule.getId()) .ruleIndex(ruleIndex) @@ -147,7 +140,7 @@ public class SarifLogBuilder { .build(); result.setMessage(message); - result.setLocations(locations); + result.setLocations(Collections.singletonList(location)); return result; } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/AbstractRendererTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/AbstractRendererTest.java index 8b699dd1dc..826a048408 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/AbstractRendererTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/AbstractRendererTest.java @@ -19,6 +19,7 @@ import net.sourceforge.pmd.Report; import net.sourceforge.pmd.Report.ConfigurationError; import net.sourceforge.pmd.Report.ProcessingError; import net.sourceforge.pmd.ReportTest; +import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.RulePriority; import net.sourceforge.pmd.RuleViolation; import net.sourceforge.pmd.RuleWithProperties; @@ -68,31 +69,49 @@ public abstract class AbstractRendererTest { } protected Consumer reportOneViolation() { - return it -> it.onRuleViolation(newRuleViolation(1)); + return it -> it.onRuleViolation(newRuleViolation(1, 1, 1, 1, createFooRule())); } private Consumer reportTwoViolations() { return it -> { - RuleViolation informationalRuleViolation = newRuleViolation(1); - informationalRuleViolation.getRule().setPriority(RulePriority.LOW); + RuleViolation informationalRuleViolation = newRuleViolation(1, 1, 1, 1, createFooRule()); it.onRuleViolation(informationalRuleViolation); - RuleViolation severeRuleViolation = newRuleViolation(2); - severeRuleViolation.getRule().setPriority(RulePriority.HIGH); + RuleViolation severeRuleViolation = newRuleViolation(1, 1, 1, 2, createBooRule()); it.onRuleViolation(severeRuleViolation); }; } - protected RuleViolation newRuleViolation(int endColumn) { - return newRuleViolation(endColumn, "Foo"); + protected DummyNode createNode(int beginLine, int beginColumn, int endLine, int endColumn) { + DummyNode node = new DummyRoot().withFileName(getSourceCodeFilename()); + node.setCoords(beginLine, beginColumn, endLine, endColumn); + return node; } - protected RuleViolation newRuleViolation(int endColumn, String ruleName) { - DummyNode node = createNode(endColumn); - FooRule rule = new FooRule(); - rule.setName(ruleName); + protected RuleViolation newRuleViolation(int beginLine, int beginColumn, int endLine, int endColumn, Rule rule) { + DummyNode node = createNode(beginLine, beginColumn, endLine, endColumn); return new ParametricRuleViolation(rule, node, "blah"); } + /** + * Creates a new rule instance with name "Boo" and priority {@link RulePriority#HIGH}. + */ + protected Rule createBooRule() { + Rule booRule = new FooRule(); + booRule.setName("Boo"); + booRule.setPriority(RulePriority.HIGH); + return booRule; + } + + /** + * Creates a new rule instance with name "Foo" and priority {@link RulePriority#LOW}. + */ + protected Rule createFooRule() { + Rule fooRule = new FooRule(); + fooRule.setName("Foo"); + fooRule.setPriority(RulePriority.LOW); + return fooRule; + } + /** * Read a resource file relative to this class's location. */ @@ -104,19 +123,14 @@ public abstract class AbstractRendererTest { } } - protected DummyNode createNode(int endColumn) { - DummyNode node = new DummyRoot().withFileName(getSourceCodeFilename()); - node.setCoords(1, 1, 1, endColumn); - return node; - } - @Test public void testRuleWithProperties() throws Exception { - DummyNode node = createNode(1); + DummyNode node = createNode(1, 1, 1, 1); RuleWithProperties theRule = new RuleWithProperties(); theRule.setProperty(RuleWithProperties.STRING_PROPERTY_DESCRIPTOR, "the string value\nsecond line with \"quotes\""); - String rendered = ReportTest.render(getRenderer(), it -> it.onRuleViolation(new ParametricRuleViolation(theRule, node, "blah"))); + String rendered = ReportTest.render(getRenderer(), + it -> it.onRuleViolation(new ParametricRuleViolation(theRule, node, "blah"))); assertEquals(filter(getExpectedWithProperties()), filter(rendered)); } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/CSVRendererTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/CSVRendererTest.java index 5ef24218fe..4b0fdf3024 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/CSVRendererTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/CSVRendererTest.java @@ -30,7 +30,7 @@ public class CSVRendererTest extends AbstractRendererTest { public String getExpectedMultiple() { return getHeader() + "\"1\",\"\",\"" + getSourceCodeFilename() + "\",\"5\",\"1\",\"blah\",\"RuleSet\",\"Foo\"" + PMD.EOL - + "\"2\",\"\",\"" + getSourceCodeFilename() + "\",\"1\",\"1\",\"blah\",\"RuleSet\",\"Foo\"" + PMD.EOL; + + "\"2\",\"\",\"" + getSourceCodeFilename() + "\",\"1\",\"1\",\"blah\",\"RuleSet\",\"Boo\"" + PMD.EOL; } @Override @@ -46,8 +46,4 @@ public class CSVRendererTest extends AbstractRendererTest { private String getHeader() { return "\"Problem\",\"Package\",\"File\",\"Priority\",\"Line\",\"Description\",\"Rule set\",\"Rule\"" + PMD.EOL; } - - public static junit.framework.Test suite() { - return new junit.framework.JUnit4TestAdapter(CSVRendererTest.class); - } } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/CodeClimateRendererTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/CodeClimateRendererTest.java index 4ec116b6f4..431d075c19 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/CodeClimateRendererTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/CodeClimateRendererTest.java @@ -10,9 +10,6 @@ import org.junit.Test; import net.sourceforge.pmd.PMD; import net.sourceforge.pmd.ReportTest; -import net.sourceforge.pmd.lang.ast.DummyNode; -import net.sourceforge.pmd.lang.ast.Node; -import net.sourceforge.pmd.lang.rule.ParametricRuleViolation; import net.sourceforge.pmd.lang.rule.XPathRule; import net.sourceforge.pmd.lang.rule.xpath.XPathVersion; @@ -72,8 +69,8 @@ public class CodeClimateRendererTest extends AbstractRendererTest { + "violationSuppressRegex | | Suppress violations with messages matching a regular expression\\n" + "violationSuppressXPath | | Suppress violations on nodes which match a given relative XPath expression.\\n" + "\"},\"categories\":[\"Style\"],\"location\":{\"path\":\"" + getSourceCodeFilename() + "\",\"lines\":{\"begin\":1,\"end\":1}},\"severity\":\"info\",\"remediation_points\":50000}" - + "\u0000" + PMD.EOL + "{\"type\":\"issue\",\"check_name\":\"Foo\",\"description\":\"blah\"," - + "\"content\":{\"body\":\"## Foo\\n\\nSince: PMD null\\n\\nPriority: High\\n\\n" + + "\u0000" + PMD.EOL + "{\"type\":\"issue\",\"check_name\":\"Boo\",\"description\":\"blah\"," + + "\"content\":{\"body\":\"## Boo\\n\\nSince: PMD null\\n\\nPriority: High\\n\\n" + "[Categories](https://github.com/codeclimate/platform/blob/master/spec/analyzers/SPEC.md#categories): Style\\n\\n" + "[Remediation Points](https://github.com/codeclimate/platform/blob/master/spec/analyzers/SPEC.md#remediation-points): 50000\\n\\n" + "desc\\n\\n" @@ -87,14 +84,13 @@ public class CodeClimateRendererTest extends AbstractRendererTest { @Test public void testXPathRule() throws Exception { - DummyNode node = createNode(1); XPathRule theRule = new XPathRule(XPathVersion.XPATH_3_1, "//dummyNode"); // Setup as FooRule theRule.setDescription("desc"); theRule.setName("Foo"); - String rendered = ReportTest.render(getRenderer(), it -> it.onRuleViolation(new ParametricRuleViolation(theRule, node, "blah"))); + String rendered = ReportTest.render(getRenderer(), it -> it.onRuleViolation(newRuleViolation(1, 1, 1, 2, theRule))); // Output should be the exact same as for non xpath rules assertEquals(filter(getExpected()), filter(rendered)); diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/JsonRendererTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/JsonRendererTest.java index 7344297e0d..9aa8193a12 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/JsonRendererTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/JsonRendererTest.java @@ -10,6 +10,7 @@ import java.io.IOException; import org.junit.Assert; import org.junit.Test; +import net.sourceforge.pmd.FooRule; import net.sourceforge.pmd.Report.ConfigurationError; import net.sourceforge.pmd.Report.ProcessingError; import net.sourceforge.pmd.Report.SuppressedViolation; @@ -79,7 +80,7 @@ public class JsonRendererTest extends AbstractRendererTest { @Test public void suppressedViolations() throws IOException { SuppressedViolation suppressed = new SuppressedViolation( - newRuleViolation(1), + newRuleViolation(1, 1, 1, 1, new FooRule()), ViolationSuppressor.NOPMD_COMMENT_SUPPRESSOR, "test" ); diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/PapariTextRendererTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/PapariTextRendererTest.java index 7047e79d46..69c7f384a1 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/PapariTextRendererTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/PapariTextRendererTest.java @@ -42,7 +42,7 @@ public class PapariTextRendererTest extends AbstractRendererTest { public String getExpectedMultiple() { return "* file: " + getSourceCodeFilename() + PMD.EOL + " src: " + getSourceCodeFilename() + ":1:1" + PMD.EOL + " rule: Foo" + PMD.EOL + " msg: blah" + PMD.EOL + " code: public class Foo {}" + PMD.EOL + PMD.EOL + " src: " - + getSourceCodeFilename() + ":1:1" + PMD.EOL + " rule: Foo" + PMD.EOL + " msg: blah" + PMD.EOL + + getSourceCodeFilename() + ":1:1" + PMD.EOL + " rule: Boo" + PMD.EOL + " msg: blah" + PMD.EOL + " code: public class Foo {}" + PMD.EOL + PMD.EOL + PMD.EOL + PMD.EOL + "Summary:" + PMD.EOL + PMD.EOL + "* warnings: 2" + PMD.EOL; } @@ -67,8 +67,4 @@ public class PapariTextRendererTest extends AbstractRendererTest { + " err: a configuration error" + PMD.EOL + PMD.EOL + "* errors: 1" + PMD.EOL + "* warnings: 0" + PMD.EOL; } - - public static junit.framework.Test suite() { - return new junit.framework.JUnit4TestAdapter(PapariTextRendererTest.class); - } } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/RenderersTests.java b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/RenderersTests.java index b97d81e0e2..ce0ae361f7 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/RenderersTests.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/RenderersTests.java @@ -20,9 +20,12 @@ import org.junit.runners.Suite.SuiteClasses; EmacsRendererTest.class, HTMLRendererTest.class, IDEAJRendererTest.class, + JsonRendererTest.class, PapariTextRendererTest.class, + SarifRendererTest.class, SummaryHTMLRendererTest.class, TextPadRendererTest.class, + TextRendererTest.class, VBHTMLRendererTest.class, XMLRendererTest.class, XSLTRendererTest.class, diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/SarifRendererTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/SarifRendererTest.java index 5d3f08b1ca..d71823e21e 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/SarifRendererTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/SarifRendererTest.java @@ -4,17 +4,17 @@ package net.sourceforge.pmd.renderers; -import static org.hamcrest.CoreMatchers.containsString; -import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.Assert.assertEquals; import java.util.function.Consumer; +import org.json.JSONArray; +import org.json.JSONObject; import org.junit.Test; import net.sourceforge.pmd.Report; import net.sourceforge.pmd.ReportTest; -import net.sourceforge.pmd.RulePriority; -import net.sourceforge.pmd.RuleViolation; +import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.reporting.FileAnalysisListener; public class SarifRendererTest extends AbstractRendererTest { @@ -65,32 +65,34 @@ public class SarifRendererTest extends AbstractRendererTest { @Override public String filter(String expected) { - return expected.replaceAll("\r\n", "\n"); // make the test run on Windows, too + return expected.replaceAll("\r\n", "\n") // make the test run on Windows, too + .replaceAll("\"version\": \".+\",", "\"version\": \"unknown\","); } - @Override + /** + * Multiple occurrences of the same rule should be reported as individual results. + * + * @see [core] SARIF formatter reports multiple locations + * when it should report multiple results #3768 + */ @Test - public void testRendererMultiple() throws Exception { - // Exercise - String actual = ReportTest.render(getRenderer(), reportTwoViolations()); + public void testRendererMultipleLocations() throws Exception { + String actual = ReportTest.render(getRenderer(), reportThreeViolationsTwoRules()); - // Verify that both rules are and rule ids are linked in the results - // Initially was comparing whole files but order of rules rendered can't be guaranteed when the report is being rendered - // Refer to pmd-core/src/test/resources/net/sourceforge/pmd/renderers/sarif/expected-multiple.sarif.json to see an example data structure - assertThat(filter(actual), containsString("\"ruleId\": \"Foo\"")); - assertThat(filter(actual), containsString("\"ruleId\": \"Boo\"")); - assertThat(filter(actual), containsString("\"id\": \"Foo\"")); - assertThat(filter(actual), containsString("\"id\": \"Boo\"")); + JSONObject json = new JSONObject(actual); + JSONArray results = json.getJSONArray("runs").getJSONObject(0).getJSONArray("results"); + assertEquals(3, results.length()); + assertEquals(filter(readFile("expected-multiple-locations.sarif.json")), filter(actual)); } - private Consumer reportTwoViolations() { + private Consumer reportThreeViolationsTwoRules() { + Rule fooRule = createFooRule(); + Rule booRule = createBooRule(); + return reportBuilder -> { - RuleViolation informationalRuleViolation = newRuleViolation(1, "Foo"); - informationalRuleViolation.getRule().setPriority(RulePriority.LOW); - reportBuilder.onRuleViolation(informationalRuleViolation); - RuleViolation severeRuleViolation = newRuleViolation(2, "Boo"); - severeRuleViolation.getRule().setPriority(RulePriority.HIGH); - reportBuilder.onRuleViolation(severeRuleViolation); + reportBuilder.onRuleViolation(newRuleViolation(1, 1, 1, 10, fooRule)); + reportBuilder.onRuleViolation(newRuleViolation(5, 1, 5, 11, fooRule)); + reportBuilder.onRuleViolation(newRuleViolation(2, 2, 3, 1, booRule)); }; } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/SummaryHTMLRendererTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/SummaryHTMLRendererTest.java index dedd344d15..5e56ec4423 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/SummaryHTMLRendererTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/SummaryHTMLRendererTest.java @@ -70,7 +70,8 @@ public class SummaryHTMLRendererTest extends AbstractRendererTest { return "PMD" + PMD.EOL + "

Summary

" + PMD.EOL + "" + PMD.EOL + "" + PMD.EOL - + "" + PMD.EOL + "
Rule nameNumber of violations
Foo2
" + PMD.EOL + + "Boo1" + PMD.EOL + + "Foo1" + PMD.EOL + "" + PMD.EOL + "

Detail

" + PMD.EOL + "

PMD report

Problems found

" diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/TextPadRendererTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/TextPadRendererTest.java index c96d73c2f5..ac45b8a55b 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/TextPadRendererTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/TextPadRendererTest.java @@ -25,10 +25,6 @@ public class TextPadRendererTest extends AbstractRendererTest { @Override public String getExpectedMultiple() { - return getSourceCodeFilename() + "(1, Foo): blah" + PMD.EOL + getSourceCodeFilename() + "(1, Foo): blah" + PMD.EOL; - } - - public static junit.framework.Test suite() { - return new junit.framework.JUnit4TestAdapter(TextPadRendererTest.class); + return getSourceCodeFilename() + "(1, Foo): blah" + PMD.EOL + getSourceCodeFilename() + "(1, Boo): blah" + PMD.EOL; } } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/TextRendererTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/TextRendererTest.java index 69983b5f85..2e85785db2 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/TextRendererTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/TextRendererTest.java @@ -28,7 +28,7 @@ public class TextRendererTest extends AbstractRendererTest { @Override public String getExpectedMultiple() { return getSourceCodeFilename() + ":1:\tFoo:\tblah" + PMD.EOL - + getSourceCodeFilename() + ":1:\tFoo:\tblah" + PMD.EOL; + + getSourceCodeFilename() + ":1:\tBoo:\tblah" + PMD.EOL; } @Override diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/VBHTMLRendererTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/VBHTMLRendererTest.java index e2c1e15023..7bc7118adb 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/VBHTMLRendererTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/VBHTMLRendererTest.java @@ -93,8 +93,4 @@ public class VBHTMLRendererTest extends AbstractRendererTest { + "-->

 Configuration problems found
" + error.rule().getName() + "" + error.issue() + "
" + PMD.EOL; } - - public static junit.framework.Test suite() { - return new junit.framework.JUnit4TestAdapter(VBHTMLRendererTest.class); - } } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/XMLRendererTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/XMLRendererTest.java index f6fc5556bf..7e843ed3e0 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/XMLRendererTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/XMLRendererTest.java @@ -63,7 +63,7 @@ public class XMLRendererTest extends AbstractRendererTest { return getHeader() + "" + PMD.EOL + "" + PMD.EOL + "blah" + PMD.EOL + "" + PMD.EOL - + "" + + "" + PMD.EOL + "blah" + PMD.EOL + "" + PMD.EOL + "" + PMD.EOL + "" + PMD.EOL; } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/YAHTMLRendererTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/YAHTMLRendererTest.java index 728bbe18d5..862edc7bc8 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/YAHTMLRendererTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/YAHTMLRendererTest.java @@ -16,7 +16,6 @@ import java.util.regex.Pattern; import org.apache.commons.io.IOUtils; import org.junit.Before; -import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; @@ -25,6 +24,7 @@ import net.sourceforge.pmd.PMD; import net.sourceforge.pmd.Report.ConfigurationError; import net.sourceforge.pmd.Report.ProcessingError; import net.sourceforge.pmd.ReportTest; +import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.RuleViolation; import net.sourceforge.pmd.lang.ast.DummyNode; import net.sourceforge.pmd.lang.ast.Node; @@ -34,7 +34,7 @@ public class YAHTMLRendererTest extends AbstractRendererTest { private File outputDir; - @Rule + @org.junit.Rule public TemporaryFolder folder = new TemporaryFolder(); @Before @@ -42,8 +42,8 @@ public class YAHTMLRendererTest extends AbstractRendererTest { outputDir = folder.newFolder("pmdtest"); } - private RuleViolation newRuleViolation(int endColumn, final String packageNameArg, final String classNameArg) { - DummyNode node = createNode(endColumn); + private RuleViolation newRuleViolation(int beginLine, int beginColumn, int endLine, int endColumn, final String packageNameArg, final String classNameArg) { + DummyNode node = createNode(beginLine, beginColumn, endLine, endColumn); return new ParametricRuleViolation(new FooRule(), node, "blah") { { packageName = packageNameArg; @@ -53,17 +53,17 @@ public class YAHTMLRendererTest extends AbstractRendererTest { } @Override - protected RuleViolation newRuleViolation(int endColumn) { - return newRuleViolation(endColumn, "net.sf.pmd.test", "YAHTMLSampleClass"); + protected RuleViolation newRuleViolation(int beginLine, int beginColumn, int endLine, int endColumn, Rule rule) { + return newRuleViolation(beginLine, beginColumn, endLine, endColumn, "net.sf.pmd.test", "YAHTMLSampleClass"); } @Test public void testReportMultipleViolations() throws Exception { String actual = ReportTest.render(getRenderer(), it -> { - it.onRuleViolation(newRuleViolation(1, "net.sf.pmd.test", "YAHTMLSampleClass1")); - it.onRuleViolation(newRuleViolation(2, "net.sf.pmd.test", "YAHTMLSampleClass1")); - it.onRuleViolation(newRuleViolation(1, "net.sf.pmd.other", "YAHTMLSampleClass2")); + it.onRuleViolation(newRuleViolation(1, 1, 1, 1, "net.sf.pmd.test", "YAHTMLSampleClass1")); + it.onRuleViolation(newRuleViolation(1, 1, 1, 2, "net.sf.pmd.test", "YAHTMLSampleClass1")); + it.onRuleViolation(newRuleViolation(1, 1, 1, 1, "net.sf.pmd.other", "YAHTMLSampleClass2")); }); assertEquals(filter(getExpected()), filter(actual)); diff --git a/pmd-core/src/test/resources/net/sourceforge/pmd/renderers/json/expected-multiple.json b/pmd-core/src/test/resources/net/sourceforge/pmd/renderers/json/expected-multiple.json index 9ab3704f1e..127a1d535a 100644 --- a/pmd-core/src/test/resources/net/sourceforge/pmd/renderers/json/expected-multiple.json +++ b/pmd-core/src/test/resources/net/sourceforge/pmd/renderers/json/expected-multiple.json @@ -22,7 +22,7 @@ "endline": 1, "endcolumn": 2, "description": "blah", - "rule": "Foo", + "rule": "Boo", "ruleset": "RuleSet", "priority": 1 } diff --git a/pmd-core/src/test/resources/net/sourceforge/pmd/renderers/sarif/expected-multiple-locations.sarif.json b/pmd-core/src/test/resources/net/sourceforge/pmd/renderers/sarif/expected-multiple-locations.sarif.json new file mode 100644 index 0000000000..7a545006b0 --- /dev/null +++ b/pmd-core/src/test/resources/net/sourceforge/pmd/renderers/sarif/expected-multiple-locations.sarif.json @@ -0,0 +1,130 @@ +{ + "$schema": "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json", + "version": "2.1.0", + "runs": [ + { + "tool": { + "driver": { + "name": "PMD", + "version": "unknown", + "informationUri": "https://pmd.github.io/pmd/", + "rules": [ + { + "id": "Foo", + "shortDescription": { + "text": "blah" + }, + "fullDescription": { + "text": "desc" + }, + "help": { + "text": "desc" + }, + "properties": { + "ruleset": "RuleSet", + "priority": 5, + "tags": [ + "RuleSet" + ] + } + }, + { + "id": "Boo", + "shortDescription": { + "text": "blah" + }, + "fullDescription": { + "text": "desc" + }, + "help": { + "text": "desc" + }, + "properties": { + "ruleset": "RuleSet", + "priority": 1, + "tags": [ + "RuleSet" + ] + } + } + ] + } + }, + "results": [ + { + "ruleId": "Foo", + "ruleIndex": 0, + "message": { + "text": "blah" + }, + "locations": [ + { + "physicalLocation": { + "artifactLocation": { + "uri": "notAvailable.ext" + }, + "region": { + "startLine": 1, + "startColumn": 1, + "endLine": 1, + "endColumn": 10 + } + } + } + ] + }, + { + "ruleId": "Boo", + "ruleIndex": 1, + "message": { + "text": "blah" + }, + "locations": [ + { + "physicalLocation": { + "artifactLocation": { + "uri": "notAvailable.ext" + }, + "region": { + "startLine": 2, + "startColumn": 2, + "endLine": 3, + "endColumn": 1 + } + } + } + ] + }, + { + "ruleId": "Foo", + "ruleIndex": 0, + "message": { + "text": "blah" + }, + "locations": [ + { + "physicalLocation": { + "artifactLocation": { + "uri": "notAvailable.ext" + }, + "region": { + "startLine": 5, + "startColumn": 1, + "endLine": 5, + "endColumn": 11 + } + } + } + ] + } + ], + "invocations": [ + { + "executionSuccessful": true, + "toolConfigurationNotifications": [], + "toolExecutionNotifications": [] + } + ] + } + ] +} \ No newline at end of file diff --git a/pmd-core/src/test/resources/net/sourceforge/pmd/renderers/sarif/expected-multiple.sarif.json b/pmd-core/src/test/resources/net/sourceforge/pmd/renderers/sarif/expected-multiple.sarif.json index e89a3927df..108ac1578f 100644 --- a/pmd-core/src/test/resources/net/sourceforge/pmd/renderers/sarif/expected-multiple.sarif.json +++ b/pmd-core/src/test/resources/net/sourceforge/pmd/renderers/sarif/expected-multiple.sarif.json @@ -9,25 +9,6 @@ "version": "unknown", "informationUri": "https://pmd.github.io/pmd/", "rules": [ - { - "id": "Boo", - "shortDescription": { - "text": "blah" - }, - "fullDescription": { - "text": "desc" - }, - "help": { - "text": "desc" - }, - "properties": { - "ruleset": "RuleSet", - "priority": 1, - "tags": [ - "RuleSet" - ] - } - }, { "id": "Foo", "shortDescription": { @@ -46,36 +27,33 @@ "RuleSet" ] } + }, + { + "id": "Boo", + "shortDescription": { + "text": "blah" + }, + "fullDescription": { + "text": "desc" + }, + "help": { + "text": "desc" + }, + "properties": { + "ruleset": "RuleSet", + "priority": 1, + "tags": [ + "RuleSet" + ] + } } ] } }, "results": [ - { - "ruleId": "Boo", - "ruleIndex": 0, - "message": { - "text": "blah" - }, - "locations": [ - { - "physicalLocation": { - "artifactLocation": { - "uri": "notAvailable.ext" - }, - "region": { - "startLine": 1, - "startColumn": 1, - "endLine": 1, - "endColumn": 2 - } - } - } - ] - }, { "ruleId": "Foo", - "ruleIndex": 1, + "ruleIndex": 0, "message": { "text": "blah" }, @@ -94,6 +72,28 @@ } } ] + }, + { + "ruleId": "Boo", + "ruleIndex": 1, + "message": { + "text": "blah" + }, + "locations": [ + { + "physicalLocation": { + "artifactLocation": { + "uri": "notAvailable.ext" + }, + "region": { + "startLine": 1, + "startColumn": 1, + "endLine": 1, + "endColumn": 2 + } + } + } + ] } ], "invocations": [ diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTSwitchLike.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTSwitchLike.java index 771bc4acd3..9850122c37 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTSwitchLike.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTSwitchLike.java @@ -107,4 +107,14 @@ public interface ASTSwitchLike extends JavaNode, Iterable { default Iterator iterator() { return children(ASTSwitchBranch.class).iterator(); } + + /** + * Returns true if this a switch which uses fallthrough branches + * (old school {@code case label: break;}) and not arrow branches. + * If the switch has no branches, returns false. + */ + default boolean isFallthroughSwitch() { + return getBranches().filterIs(ASTSwitchFallthroughBranch.class).nonEmpty(); + } + } diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTSwitchStatement.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTSwitchStatement.java index 9ea3ef2d81..115ab5c866 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTSwitchStatement.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTSwitchStatement.java @@ -19,4 +19,5 @@ public final class ASTSwitchStatement extends AbstractStatement implements ASTSw protected R acceptVisitor(JavaVisitor visitor, P data) { return visitor.visit(this, data); } + } diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/ASTSwitchStatementTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/ASTSwitchStatementTest.java index ba3ec6244f..e5dd0fd7bc 100644 --- a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/ASTSwitchStatementTest.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/ASTSwitchStatementTest.java @@ -19,5 +19,52 @@ public class ASTSwitchStatementTest extends BaseParserTest { .descendants(ASTSwitchStatement.class).firstOrThrow(); Assert.assertFalse(switchStatement.isExhaustiveEnumSwitch()); // this should not throw a NPE... Assert.assertTrue(switchStatement.hasDefaultCase()); + Assert.assertTrue(switchStatement.isFallthroughSwitch()); + } + + @Test + public void defaultCaseWithArrowBlock() { + ASTSwitchStatement switchStatement = getNodes(ASTSwitchStatement.class, + "class Foo { void bar(int x) {" + + "switch (x) { default -> { } } } }") + .get(0); + Assert.assertFalse(switchStatement.isExhaustiveEnumSwitch()); + Assert.assertTrue(switchStatement.iterator().hasNext()); + Assert.assertTrue(switchStatement.hasDefaultCase()); + Assert.assertFalse(switchStatement.isFallthroughSwitch()); + } + + @Test + public void emptySwitch() { + ASTSwitchStatement switchStatement = getNodes(ASTSwitchStatement.class, + "class Foo { void bar(int x) {" + + "switch (x) { } } }") + .get(0); + Assert.assertFalse(switchStatement.isExhaustiveEnumSwitch()); + Assert.assertFalse(switchStatement.iterator().hasNext()); + Assert.assertFalse(switchStatement.hasDefaultCase()); + Assert.assertFalse(switchStatement.isFallthroughSwitch()); + } + + @Test + public void defaultCaseWithArrowExprs() { + ASTSwitchStatement switchStatement = + getNodes(ASTSwitchStatement.class, + "import net.sourceforge.pmd.lang.java.rule.bestpractices.switchstmtsshouldhavedefault.SimpleEnum;\n" + + "\n" + + " public class Foo {\n" + + " void bar(SimpleEnum x) {\n" + + " switch (x) {\n" + + " case FOO -> System.out.println(\"it is on\");\n" + + " case BAR -> System.out.println(\"it is off\");\n" + + " default -> System.out.println(\"it is neither on nor off - should not happen? maybe null?\");\n" + + " }\n" + + " }\n" + + " }") + .get(0); + Assert.assertFalse(switchStatement.isExhaustiveEnumSwitch()); + Assert.assertTrue(switchStatement.iterator().hasNext()); + Assert.assertFalse(switchStatement.isFallthroughSwitch()); + Assert.assertTrue(switchStatement.hasDefaultCase()); } } diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/ParserCornerCases17.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/ParserCornerCases17.txt index 16c95c3ac8..31e2afbf4d 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/ParserCornerCases17.txt +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/ParserCornerCases17.txt @@ -102,7 +102,7 @@ | | +- InfixExpression[@CompileTimeConstant = "false", @Operator = "&", @ParenthesisDepth = "0", @Parenthesized = "false"] | | +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Image = "instruction", @Name = "instruction", @ParenthesisDepth = "0", @Parenthesized = "false"] | | +- NumericLiteral[@Base = "2", @CompileTimeConstant = "true", @DoubleLiteral = "false", @FloatLiteral = "false", @Image = "0b00001111", @IntLiteral = "true", @Integral = "true", @LongLiteral = "false", @ParenthesisDepth = "0", @Parenthesized = "false", @ValueAsDouble = "15.0", @ValueAsFloat = "15.0", @ValueAsInt = "15", @ValueAsLong = "15"] - | +- SwitchStatement[@DefaultCase = "true", @EnumSwitch = "false", @ExhaustiveEnumSwitch = "false"] + | +- SwitchStatement[@DefaultCase = "true", @EnumSwitch = "false", @ExhaustiveEnumSwitch = "false", @FallthroughSwitch = "true"] | +- InfixExpression[@CompileTimeConstant = "false", @Operator = "&", @ParenthesisDepth = "0", @Parenthesized = "false"] | | +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Image = "instruction", @Name = "instruction", @ParenthesisDepth = "0", @Parenthesized = "false"] | | +- NumericLiteral[@Base = "2", @CompileTimeConstant = "true", @DoubleLiteral = "false", @FloatLiteral = "false", @Image = "0b11110000", @IntLiteral = "true", @Integral = "true", @LongLiteral = "false", @ParenthesisDepth = "0", @Parenthesized = "false", @ValueAsDouble = "240.0", @ValueAsFloat = "240.0", @ValueAsInt = "240", @ValueAsLong = "240"] @@ -255,7 +255,7 @@ | | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "String"] | | +- VariableDeclarator[@Initializer = "false", @Name = "typeOfDay"] | | +- VariableDeclaratorId[@ArrayType = "false", @EffectiveVisibility = "local", @EnumConstant = "false", @ExceptionBlockParameter = "false", @Field = "false", @Final = "false", @ForLoopVariable = "false", @ForeachVariable = "false", @FormalParameter = "false", @LambdaParameter = "false", @LocalVariable = "true", @Name = "typeOfDay", @PatternBinding = "false", @RecordComponent = "false", @ResourceDeclaration = "false", @TypeInferred = "false", @Visibility = "local"] - | +- SwitchStatement[@DefaultCase = "true", @EnumSwitch = "false", @ExhaustiveEnumSwitch = "false"] + | +- SwitchStatement[@DefaultCase = "true", @EnumSwitch = "false", @ExhaustiveEnumSwitch = "false", @FallthroughSwitch = "true"] | | +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Image = "dayOfWeekArg", @Name = "dayOfWeekArg", @ParenthesisDepth = "0", @Parenthesized = "false"] | | +- SwitchFallthroughBranch[@Default = "false"] | | | +- SwitchLabel[@Default = "false"] diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/SwitchStatements.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/SwitchStatements.txt index d0b302a950..2ed47e7f40 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/SwitchStatements.txt +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/SwitchStatements.txt @@ -13,16 +13,16 @@ | +- VariableDeclarator[@Initializer = "true", @Name = "a"] | +- VariableDeclaratorId[@ArrayType = "false", @EffectiveVisibility = "local", @EnumConstant = "false", @ExceptionBlockParameter = "false", @Field = "false", @Final = "false", @ForLoopVariable = "false", @ForeachVariable = "false", @FormalParameter = "false", @LambdaParameter = "false", @LocalVariable = "true", @Name = "a", @PatternBinding = "false", @RecordComponent = "false", @ResourceDeclaration = "false", @TypeInferred = "false", @Visibility = "local"] | +- NumericLiteral[@Base = "10", @CompileTimeConstant = "true", @DoubleLiteral = "false", @FloatLiteral = "false", @Image = "1", @IntLiteral = "true", @Integral = "true", @LongLiteral = "false", @ParenthesisDepth = "0", @Parenthesized = "false", @ValueAsDouble = "1.0", @ValueAsFloat = "1.0", @ValueAsInt = "1", @ValueAsLong = "1"] - +- SwitchStatement[@DefaultCase = "true", @EnumSwitch = "false", @ExhaustiveEnumSwitch = "false"] + +- SwitchStatement[@DefaultCase = "true", @EnumSwitch = "false", @ExhaustiveEnumSwitch = "false", @FallthroughSwitch = "true"] | +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Image = "a", @Name = "a", @ParenthesisDepth = "0", @Parenthesized = "false"] | +- SwitchFallthroughBranch[@Default = "false"] | | +- SwitchLabel[@Default = "false"] | | +- NumericLiteral[@Base = "10", @CompileTimeConstant = "true", @DoubleLiteral = "false", @FloatLiteral = "false", @Image = "1", @IntLiteral = "true", @Integral = "true", @LongLiteral = "false", @ParenthesisDepth = "0", @Parenthesized = "false", @ValueAsDouble = "1.0", @ValueAsFloat = "1.0", @ValueAsInt = "1", @ValueAsLong = "1"] | +- SwitchFallthroughBranch[@Default = "true"] | +- SwitchLabel[@Default = "true"] - +- SwitchStatement[@DefaultCase = "false", @EnumSwitch = "false", @ExhaustiveEnumSwitch = "false"] + +- SwitchStatement[@DefaultCase = "false", @EnumSwitch = "false", @ExhaustiveEnumSwitch = "false", @FallthroughSwitch = "false"] | +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Image = "a", @Name = "a", @ParenthesisDepth = "0", @Parenthesized = "false"] - +- SwitchStatement[@DefaultCase = "true", @EnumSwitch = "false", @ExhaustiveEnumSwitch = "false"] + +- SwitchStatement[@DefaultCase = "true", @EnumSwitch = "false", @ExhaustiveEnumSwitch = "false", @FallthroughSwitch = "true"] +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Image = "a", @Name = "a", @ParenthesisDepth = "0", @Parenthesized = "false"] +- SwitchFallthroughBranch[@Default = "false"] | +- SwitchLabel[@Default = "false"] diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/SwitchWithFallthrough.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/SwitchWithFallthrough.txt index a88b620f31..41687f5d4c 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/SwitchWithFallthrough.txt +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/SwitchWithFallthrough.txt @@ -13,7 +13,7 @@ | +- VariableDeclarator[@Initializer = "true", @Name = "a"] | +- VariableDeclaratorId[@ArrayType = "false", @EffectiveVisibility = "local", @EnumConstant = "false", @ExceptionBlockParameter = "false", @Field = "false", @Final = "false", @ForLoopVariable = "false", @ForeachVariable = "false", @FormalParameter = "false", @LambdaParameter = "false", @LocalVariable = "true", @Name = "a", @PatternBinding = "false", @RecordComponent = "false", @ResourceDeclaration = "false", @TypeInferred = "false", @Visibility = "local"] | +- NumericLiteral[@Base = "10", @CompileTimeConstant = "true", @DoubleLiteral = "false", @FloatLiteral = "false", @Image = "1", @IntLiteral = "true", @Integral = "true", @LongLiteral = "false", @ParenthesisDepth = "0", @Parenthesized = "false", @ValueAsDouble = "1.0", @ValueAsFloat = "1.0", @ValueAsInt = "1", @ValueAsLong = "1"] - +- SwitchStatement[@DefaultCase = "true", @EnumSwitch = "false", @ExhaustiveEnumSwitch = "false"] + +- SwitchStatement[@DefaultCase = "true", @EnumSwitch = "false", @ExhaustiveEnumSwitch = "false", @FallthroughSwitch = "true"] +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Image = "a", @Name = "a", @ParenthesisDepth = "0", @Parenthesized = "false"] +- SwitchFallthroughBranch[@Default = "false"] | +- SwitchLabel[@Default = "false"] diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java17p/DealingWithNull.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java17p/DealingWithNull.txt index fa06aede1d..c946588f75 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java17p/DealingWithNull.txt +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java17p/DealingWithNull.txt @@ -11,7 +11,7 @@ | | +- ClassOrInterfaceType[@ArrayDepth = "0", @ArrayType = "false", @ClassOrInterfaceType = "true", @FullyQualified = "false", @PrimitiveType = "false", @ReferenceToClassSameCompilationUnit = "false", @SimpleName = "Object", @TypeImage = "Object"] | | +- VariableDeclaratorId[@Abstract = "false", @ArrayType = "false", @EffectiveVisibility = "local", @EnumConstant = "false", @ExceptionBlockParameter = "false", @Field = "false", @Final = "false", @ForLoopVariable = "false", @ForeachVariable = "false", @FormalParameter = "true", @Image = "o", @LambdaParameter = "false", @LocalVariable = "false", @Name = "o", @Native = "false", @PackagePrivate = "false", @PatternBinding = "false", @Private = "false", @Protected = "false", @Public = "false", @RecordComponent = "false", @ResourceDeclaration = "false", @Static = "false", @Strictfp = "false", @Synchronized = "false", @SyntacticallyAbstract = "false", @SyntacticallyFinal = "false", @SyntacticallyPublic = "false", @SyntacticallyStatic = "false", @Transient = "false", @TypeInferred = "false", @VariableName = "o", @Visibility = "local", @Volatile = "false"] | +- Block[@Empty = "false", @Size = "1", @containsComment = "false"] - | +- SwitchStatement[@DefaultCase = "true", @EnumSwitch = "false", @ExhaustiveEnumSwitch = "false"] + | +- SwitchStatement[@DefaultCase = "true", @EnumSwitch = "false", @ExhaustiveEnumSwitch = "false", @FallthroughSwitch = "false"] | +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Expression = "true", @Image = "o", @Name = "o", @ParenthesisDepth = "0", @Parenthesized = "false"] | +- SwitchArrowBranch[@Default = "false"] | | +- SwitchLabel[@Default = "false"] @@ -52,7 +52,7 @@ | | +- ClassOrInterfaceType[@ArrayDepth = "0", @ArrayType = "false", @ClassOrInterfaceType = "true", @FullyQualified = "false", @PrimitiveType = "false", @ReferenceToClassSameCompilationUnit = "false", @SimpleName = "Object", @TypeImage = "Object"] | | +- VariableDeclaratorId[@Abstract = "false", @ArrayType = "false", @EffectiveVisibility = "local", @EnumConstant = "false", @ExceptionBlockParameter = "false", @Field = "false", @Final = "false", @ForLoopVariable = "false", @ForeachVariable = "false", @FormalParameter = "true", @Image = "o", @LambdaParameter = "false", @LocalVariable = "false", @Name = "o", @Native = "false", @PackagePrivate = "false", @PatternBinding = "false", @Private = "false", @Protected = "false", @Public = "false", @RecordComponent = "false", @ResourceDeclaration = "false", @Static = "false", @Strictfp = "false", @Synchronized = "false", @SyntacticallyAbstract = "false", @SyntacticallyFinal = "false", @SyntacticallyPublic = "false", @SyntacticallyStatic = "false", @Transient = "false", @TypeInferred = "false", @VariableName = "o", @Visibility = "local", @Volatile = "false"] | +- Block[@Empty = "false", @Size = "1", @containsComment = "false"] - | +- SwitchStatement[@DefaultCase = "true", @EnumSwitch = "false", @ExhaustiveEnumSwitch = "false"] + | +- SwitchStatement[@DefaultCase = "true", @EnumSwitch = "false", @ExhaustiveEnumSwitch = "false", @FallthroughSwitch = "false"] | +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Expression = "true", @Image = "o", @Name = "o", @ParenthesisDepth = "0", @Parenthesized = "false"] | +- SwitchArrowBranch[@Default = "false"] | | +- SwitchLabel[@Default = "false"] @@ -106,7 +106,7 @@ | | +- ClassOrInterfaceType[@ArrayDepth = "0", @ArrayType = "false", @ClassOrInterfaceType = "true", @FullyQualified = "false", @PrimitiveType = "false", @ReferenceToClassSameCompilationUnit = "false", @SimpleName = "Object", @TypeImage = "Object"] | | +- VariableDeclaratorId[@Abstract = "false", @ArrayType = "false", @EffectiveVisibility = "local", @EnumConstant = "false", @ExceptionBlockParameter = "false", @Field = "false", @Final = "false", @ForLoopVariable = "false", @ForeachVariable = "false", @FormalParameter = "true", @Image = "o", @LambdaParameter = "false", @LocalVariable = "false", @Name = "o", @Native = "false", @PackagePrivate = "false", @PatternBinding = "false", @Private = "false", @Protected = "false", @Public = "false", @RecordComponent = "false", @ResourceDeclaration = "false", @Static = "false", @Strictfp = "false", @Synchronized = "false", @SyntacticallyAbstract = "false", @SyntacticallyFinal = "false", @SyntacticallyPublic = "false", @SyntacticallyStatic = "false", @Transient = "false", @TypeInferred = "false", @VariableName = "o", @Visibility = "local", @Volatile = "false"] | +- Block[@Empty = "false", @Size = "4", @containsComment = "false"] - | +- SwitchStatement[@DefaultCase = "true", @EnumSwitch = "false", @ExhaustiveEnumSwitch = "false"] + | +- SwitchStatement[@DefaultCase = "true", @EnumSwitch = "false", @ExhaustiveEnumSwitch = "false", @FallthroughSwitch = "true"] | | +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Expression = "true", @Image = "o", @Name = "o", @ParenthesisDepth = "0", @Parenthesized = "false"] | | +- SwitchFallthroughBranch[@Default = "false"] | | | +- SwitchLabel[@Default = "false"] @@ -136,7 +136,7 @@ | | | +- ArgumentList[@Empty = "false", @Size = "1"] | | | +- StringLiteral[@BooleanLiteral = "false", @CharLiteral = "false", @CompileTimeConstant = "true", @ConstValue = "default case", @DoubleLiteral = "false", @Empty = "false", @Expression = "true", @FloatLiteral = "false", @Image = "\"default case\"", @IntLiteral = "false", @Length = "12", @LongLiteral = "false", @NullLiteral = "false", @NumericLiteral = "false", @ParenthesisDepth = "0", @Parenthesized = "false", @StringLiteral = "true", @TextBlock = "false"] | | +- BreakStatement[@Label = null] - | +- SwitchStatement[@DefaultCase = "true", @EnumSwitch = "false", @ExhaustiveEnumSwitch = "false"] + | +- SwitchStatement[@DefaultCase = "true", @EnumSwitch = "false", @ExhaustiveEnumSwitch = "false", @FallthroughSwitch = "false"] | | +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Expression = "true", @Image = "o", @Name = "o", @ParenthesisDepth = "0", @Parenthesized = "false"] | | +- SwitchArrowBranch[@Default = "false"] | | | +- SwitchLabel[@Default = "false"] @@ -160,7 +160,7 @@ | | | +- ClassOrInterfaceType[@ArrayDepth = "0", @ArrayType = "false", @ClassOrInterfaceType = "true", @FullyQualified = "false", @PrimitiveType = "false", @ReferenceToClassSameCompilationUnit = "false", @SimpleName = "System", @TypeImage = "System"] | | +- ArgumentList[@Empty = "false", @Size = "1"] | | +- StringLiteral[@BooleanLiteral = "false", @CharLiteral = "false", @CompileTimeConstant = "true", @ConstValue = "default case", @DoubleLiteral = "false", @Empty = "false", @Expression = "true", @FloatLiteral = "false", @Image = "\"default case\"", @IntLiteral = "false", @Length = "12", @LongLiteral = "false", @NullLiteral = "false", @NumericLiteral = "false", @ParenthesisDepth = "0", @Parenthesized = "false", @StringLiteral = "true", @TextBlock = "false"] - | +- SwitchStatement[@DefaultCase = "true", @EnumSwitch = "false", @ExhaustiveEnumSwitch = "false"] + | +- SwitchStatement[@DefaultCase = "true", @EnumSwitch = "false", @ExhaustiveEnumSwitch = "false", @FallthroughSwitch = "true"] | | +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Expression = "true", @Image = "o", @Name = "o", @ParenthesisDepth = "0", @Parenthesized = "false"] | | +- SwitchFallthroughBranch[@Default = "false"] | | | +- SwitchLabel[@Default = "false"] @@ -174,7 +174,7 @@ | | | +- ClassOrInterfaceType[@ArrayDepth = "0", @ArrayType = "false", @ClassOrInterfaceType = "true", @FullyQualified = "false", @PrimitiveType = "false", @ReferenceToClassSameCompilationUnit = "false", @SimpleName = "System", @TypeImage = "System"] | | +- ArgumentList[@Empty = "false", @Size = "1"] | | +- StringLiteral[@BooleanLiteral = "false", @CharLiteral = "false", @CompileTimeConstant = "true", @ConstValue = "The rest (including null)", @DoubleLiteral = "false", @Empty = "false", @Expression = "true", @FloatLiteral = "false", @Image = "\"The rest (including null)\"", @IntLiteral = "false", @Length = "25", @LongLiteral = "false", @NullLiteral = "false", @NumericLiteral = "false", @ParenthesisDepth = "0", @Parenthesized = "false", @StringLiteral = "true", @TextBlock = "false"] - | +- SwitchStatement[@DefaultCase = "true", @EnumSwitch = "false", @ExhaustiveEnumSwitch = "false"] + | +- SwitchStatement[@DefaultCase = "true", @EnumSwitch = "false", @ExhaustiveEnumSwitch = "false", @FallthroughSwitch = "false"] | +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Expression = "true", @Image = "o", @Name = "o", @ParenthesisDepth = "0", @Parenthesized = "false"] | +- SwitchArrowBranch[@Default = "true"] | +- SwitchLabel[@Default = "true"] diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java17p/EnhancedTypeCheckingSwitch.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java17p/EnhancedTypeCheckingSwitch.txt index e5ece9855d..0cf85c5739 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java17p/EnhancedTypeCheckingSwitch.txt +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java17p/EnhancedTypeCheckingSwitch.txt @@ -11,7 +11,7 @@ | | | +- ClassOrInterfaceType[@ArrayDepth = "0", @ArrayType = "false", @ClassOrInterfaceType = "true", @FullyQualified = "false", @PrimitiveType = "false", @ReferenceToClassSameCompilationUnit = "false", @SimpleName = "Object", @TypeImage = "Object"] | | | +- VariableDeclaratorId[@Abstract = "false", @ArrayType = "false", @EffectiveVisibility = "local", @EnumConstant = "false", @ExceptionBlockParameter = "false", @Field = "false", @Final = "false", @ForLoopVariable = "false", @ForeachVariable = "false", @FormalParameter = "true", @Image = "o", @LambdaParameter = "false", @LocalVariable = "false", @Name = "o", @Native = "false", @PackagePrivate = "false", @PatternBinding = "false", @Private = "false", @Protected = "false", @Public = "false", @RecordComponent = "false", @ResourceDeclaration = "false", @Static = "false", @Strictfp = "false", @Synchronized = "false", @SyntacticallyAbstract = "false", @SyntacticallyFinal = "false", @SyntacticallyPublic = "false", @SyntacticallyStatic = "false", @Transient = "false", @TypeInferred = "false", @VariableName = "o", @Visibility = "local", @Volatile = "false"] | | +- Block[@Empty = "false", @Size = "1", @containsComment = "false"] - | | +- SwitchStatement[@DefaultCase = "true", @EnumSwitch = "false", @ExhaustiveEnumSwitch = "false"] + | | +- SwitchStatement[@DefaultCase = "true", @EnumSwitch = "false", @ExhaustiveEnumSwitch = "false", @FallthroughSwitch = "false"] | | +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Expression = "true", @Image = "o", @Name = "o", @ParenthesisDepth = "0", @Parenthesized = "false"] | | +- SwitchArrowBranch[@Default = "false"] | | | +- SwitchLabel[@Default = "false"] diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java17p/GuardedAndParenthesizedPatterns.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java17p/GuardedAndParenthesizedPatterns.txt index 0e9b300a87..e00634a4c4 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java17p/GuardedAndParenthesizedPatterns.txt +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java17p/GuardedAndParenthesizedPatterns.txt @@ -11,7 +11,7 @@ | | +- ClassOrInterfaceType[@ArrayDepth = "0", @ArrayType = "false", @ClassOrInterfaceType = "true", @FullyQualified = "false", @PrimitiveType = "false", @ReferenceToClassSameCompilationUnit = "false", @SimpleName = "Object", @TypeImage = "Object"] | | +- VariableDeclaratorId[@Abstract = "false", @ArrayType = "false", @EffectiveVisibility = "local", @EnumConstant = "false", @ExceptionBlockParameter = "false", @Field = "false", @Final = "false", @ForLoopVariable = "false", @ForeachVariable = "false", @FormalParameter = "true", @Image = "o", @LambdaParameter = "false", @LocalVariable = "false", @Name = "o", @Native = "false", @PackagePrivate = "false", @PatternBinding = "false", @Private = "false", @Protected = "false", @Public = "false", @RecordComponent = "false", @ResourceDeclaration = "false", @Static = "false", @Strictfp = "false", @Synchronized = "false", @SyntacticallyAbstract = "false", @SyntacticallyFinal = "false", @SyntacticallyPublic = "false", @SyntacticallyStatic = "false", @Transient = "false", @TypeInferred = "false", @VariableName = "o", @Visibility = "local", @Volatile = "false"] | +- Block[@Empty = "false", @Size = "1", @containsComment = "false"] - | +- SwitchStatement[@DefaultCase = "true", @EnumSwitch = "false", @ExhaustiveEnumSwitch = "false"] + | +- SwitchStatement[@DefaultCase = "true", @EnumSwitch = "false", @ExhaustiveEnumSwitch = "false", @FallthroughSwitch = "false"] | +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Expression = "true", @Image = "o", @Name = "o", @ParenthesisDepth = "0", @Parenthesized = "false"] | +- SwitchArrowBranch[@Default = "false"] | | +- SwitchLabel[@Default = "false"] diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java17p/PatternsInSwitchLabels.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java17p/PatternsInSwitchLabels.txt index 15d9382d7d..37f3dbb202 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java17p/PatternsInSwitchLabels.txt +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java17p/PatternsInSwitchLabels.txt @@ -25,7 +25,7 @@ | +- ClassOrInterfaceType[@ArrayDepth = "0", @ArrayType = "false", @ClassOrInterfaceType = "true", @FullyQualified = "false", @PrimitiveType = "false", @ReferenceToClassSameCompilationUnit = "false", @SimpleName = "String", @TypeImage = "String"] | +- VariableDeclarator[@Initializer = "true", @Name = "formatted"] | +- VariableDeclaratorId[@Abstract = "false", @ArrayType = "false", @EffectiveVisibility = "local", @EnumConstant = "false", @ExceptionBlockParameter = "false", @Field = "false", @Final = "false", @ForLoopVariable = "false", @ForeachVariable = "false", @FormalParameter = "false", @Image = "formatted", @LambdaParameter = "false", @LocalVariable = "true", @Name = "formatted", @Native = "false", @PackagePrivate = "false", @PatternBinding = "false", @Private = "false", @Protected = "false", @Public = "false", @RecordComponent = "false", @ResourceDeclaration = "false", @Static = "false", @Strictfp = "false", @Synchronized = "false", @SyntacticallyAbstract = "false", @SyntacticallyFinal = "false", @SyntacticallyPublic = "false", @SyntacticallyStatic = "false", @Transient = "false", @TypeInferred = "false", @VariableName = "formatted", @Visibility = "local", @Volatile = "false"] - | +- SwitchExpression[@CompileTimeConstant = "false", @DefaultCase = "true", @EnumSwitch = "false", @ExhaustiveEnumSwitch = "false", @Expression = "true", @ParenthesisDepth = "0", @Parenthesized = "false"] + | +- SwitchExpression[@CompileTimeConstant = "false", @DefaultCase = "true", @EnumSwitch = "false", @ExhaustiveEnumSwitch = "false", @Expression = "true", @FallthroughSwitch = "false", @ParenthesisDepth = "0", @Parenthesized = "false"] | +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Expression = "true", @Image = "o", @Name = "o", @ParenthesisDepth = "0", @Parenthesized = "false"] | +- SwitchArrowBranch[@Default = "false"] | | +- SwitchLabel[@Default = "false"] diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java17p/ScopeOfPatternVariableDeclarations.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java17p/ScopeOfPatternVariableDeclarations.txt index 2c0d3d8e4d..056465cc5e 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java17p/ScopeOfPatternVariableDeclarations.txt +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java17p/ScopeOfPatternVariableDeclarations.txt @@ -11,7 +11,7 @@ | | +- ClassOrInterfaceType[@ArrayDepth = "0", @ArrayType = "false", @ClassOrInterfaceType = "true", @FullyQualified = "false", @PrimitiveType = "false", @ReferenceToClassSameCompilationUnit = "false", @SimpleName = "Object", @TypeImage = "Object"] | | +- VariableDeclaratorId[@Abstract = "false", @ArrayType = "false", @EffectiveVisibility = "local", @EnumConstant = "false", @ExceptionBlockParameter = "false", @Field = "false", @Final = "false", @ForLoopVariable = "false", @ForeachVariable = "false", @FormalParameter = "true", @Image = "o", @LambdaParameter = "false", @LocalVariable = "false", @Name = "o", @Native = "false", @PackagePrivate = "false", @PatternBinding = "false", @Private = "false", @Protected = "false", @Public = "false", @RecordComponent = "false", @ResourceDeclaration = "false", @Static = "false", @Strictfp = "false", @Synchronized = "false", @SyntacticallyAbstract = "false", @SyntacticallyFinal = "false", @SyntacticallyPublic = "false", @SyntacticallyStatic = "false", @Transient = "false", @TypeInferred = "false", @VariableName = "o", @Visibility = "local", @Volatile = "false"] | +- Block[@Empty = "false", @Size = "1", @containsComment = "false"] - | +- SwitchStatement[@DefaultCase = "true", @EnumSwitch = "false", @ExhaustiveEnumSwitch = "false"] + | +- SwitchStatement[@DefaultCase = "true", @EnumSwitch = "false", @ExhaustiveEnumSwitch = "false", @FallthroughSwitch = "false"] | +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Expression = "true", @Image = "o", @Name = "o", @ParenthesisDepth = "0", @Parenthesized = "false"] | +- SwitchArrowBranch[@Default = "false"] | | +- SwitchLabel[@Default = "false"] @@ -71,7 +71,7 @@ | | +- ClassOrInterfaceType[@ArrayDepth = "0", @ArrayType = "false", @ClassOrInterfaceType = "true", @FullyQualified = "false", @PrimitiveType = "false", @ReferenceToClassSameCompilationUnit = "false", @SimpleName = "Object", @TypeImage = "Object"] | | +- VariableDeclaratorId[@Abstract = "false", @ArrayType = "false", @EffectiveVisibility = "local", @EnumConstant = "false", @ExceptionBlockParameter = "false", @Field = "false", @Final = "false", @ForLoopVariable = "false", @ForeachVariable = "false", @FormalParameter = "true", @Image = "o", @LambdaParameter = "false", @LocalVariable = "false", @Name = "o", @Native = "false", @PackagePrivate = "false", @PatternBinding = "false", @Private = "false", @Protected = "false", @Public = "false", @RecordComponent = "false", @ResourceDeclaration = "false", @Static = "false", @Strictfp = "false", @Synchronized = "false", @SyntacticallyAbstract = "false", @SyntacticallyFinal = "false", @SyntacticallyPublic = "false", @SyntacticallyStatic = "false", @Transient = "false", @TypeInferred = "false", @VariableName = "o", @Visibility = "local", @Volatile = "false"] | +- Block[@Empty = "false", @Size = "1", @containsComment = "false"] - | +- SwitchStatement[@DefaultCase = "true", @EnumSwitch = "false", @ExhaustiveEnumSwitch = "false"] + | +- SwitchStatement[@DefaultCase = "true", @EnumSwitch = "false", @ExhaustiveEnumSwitch = "false", @FallthroughSwitch = "true"] | +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Expression = "true", @Image = "o", @Name = "o", @ParenthesisDepth = "0", @Parenthesized = "false"] | +- SwitchFallthroughBranch[@Default = "false"] | | +- SwitchLabel[@Default = "false"] diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/bestpractices/xml/SwitchStmtsShouldHaveDefault.xml b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/bestpractices/xml/SwitchStmtsShouldHaveDefault.xml index 7adf6f1832..758b97b43b 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/bestpractices/xml/SwitchStmtsShouldHaveDefault.xml +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/bestpractices/xml/SwitchStmtsShouldHaveDefault.xml @@ -79,7 +79,89 @@ public class Foo { } } } - ]]> + ]]> + + + #3605 switch on enum with default + 0 + + + + #3605 switch on enum with default, nonexhaustive + 0 + + + + #3605 switch on enum with default, nonexhaustive, arrow + 0 + System.out.println("it is on"); + case BAR -> System.out.println("it is off"); + default -> System.out.println("it is neither on nor off - should not happen? maybe null?"); + } + } + } + ]]> + + + #3605 switch on enum with default, exhaustive, arrow + 0 + System.out.println("it is on"); + case BAR -> System.out.println("it is off"); + case BZAZ -> System.out.println("it is bzaz"); + default -> System.out.println("it is neither on nor off - should not happen? maybe null?"); + } + } + } + ]]> diff --git a/pom.xml b/pom.xml index 3f3abb530d..5c48fc0e83 100644 --- a/pom.xml +++ b/pom.xml @@ -76,7 +76,7 @@ - 2022-01-29T08:53:37Z + 2022-02-26T09:01:07Z 8 @@ -416,12 +416,12 @@ net.sourceforge.pmd pmd-core - 6.42.0 + 6.43.0 net.sourceforge.pmd pmd-java - 6.42.0 + 6.43.0 net.sourceforge.pmd