forked from phoedos/pmd
Merge branch 'master' into pmd6-file-collector
This commit is contained in:
@ -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,
|
||||
|
30
Gemfile.lock
30
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)
|
||||
|
@ -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
|
||||
|
@ -1,9 +1,9 @@
|
||||
repository: pmd/pmd
|
||||
|
||||
pmd:
|
||||
version: 6.43.0-SNAPSHOT
|
||||
previous_version: 6.42.0
|
||||
date: 26-February-2022
|
||||
version: 6.44.0-SNAPSHOT
|
||||
previous_version: 6.43.0
|
||||
date: 26-March-2022
|
||||
release_type: minor
|
||||
|
||||
# release types: major, minor, bugfix
|
||||
|
@ -78,26 +78,37 @@
|
||||
<div id="topbar-content-offset">
|
||||
{% include topnav.html %}
|
||||
<!-- Page Content -->
|
||||
<div class="container">
|
||||
<div class="col-lg-12"> </div>
|
||||
<!-- Content Row -->
|
||||
<div class="row">
|
||||
{% assign content_col_size = "col-md-12" %}
|
||||
{% unless page.hide_sidebar %}
|
||||
<!-- Sidebar Column -->
|
||||
<div class="col-md-3" id="tg-sb-sidebar">
|
||||
{% include sidebar.html %}
|
||||
</div>
|
||||
{% assign content_col_size = "col-md-9" %}
|
||||
{% endunless %}
|
||||
<div class="container-toc-wrapper">
|
||||
<div class="container">
|
||||
<div class="col-lg-12"> </div>
|
||||
<!-- Content Row -->
|
||||
<div class="row">
|
||||
{% assign content_col_size = "col-md-12" %}
|
||||
{% unless page.hide_sidebar %}
|
||||
<!-- Sidebar Column -->
|
||||
<div class="col-md-3" id="tg-sb-sidebar">
|
||||
{% include sidebar.html %}
|
||||
</div>
|
||||
{% assign content_col_size = "col-md-9" %}
|
||||
{% endunless %}
|
||||
|
||||
<!-- Content Column -->
|
||||
<div class="{{content_col_size}}" id="tg-sb-content">
|
||||
{{content}}
|
||||
<!-- Content Column -->
|
||||
<div class="{{content_col_size}}" id="tg-sb-content">
|
||||
{{content}}
|
||||
</div>
|
||||
|
||||
<!-- /.row -->
|
||||
</div>
|
||||
<!-- /.row -->
|
||||
<!-- /.container -->
|
||||
</div>
|
||||
<!-- /.container -->
|
||||
|
||||
{% unless page.toc == false %}
|
||||
<!-- Sticky TOC column -->
|
||||
<div class="toc-col">
|
||||
{% include toc.html %}
|
||||
</div>
|
||||
{% endunless %}
|
||||
<!-- /.toc-container-wrapper -->
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
@ -34,9 +34,7 @@ layout: default
|
||||
<div class="summary">{{page.summary}}</div>
|
||||
{% endif %}
|
||||
|
||||
{% unless page.toc == false %}
|
||||
{% include toc.html %}
|
||||
{% endunless %}
|
||||
<div id="inline-toc"><!-- empty, move TOC here when screen size too small --></div>
|
||||
|
||||
|
||||
{% if site.github_editme_path %}
|
||||
|
@ -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;
|
||||
|
@ -1,6 +1,14 @@
|
||||
|
||||
$('#mysidebar').height($(".nav").height());
|
||||
|
||||
// Detect small devices and move the TOC in line
|
||||
function moveToc(){
|
||||
if(window.innerWidth < 1350){
|
||||
$( "#toc" ).detach().appendTo("#inline-toc").removeClass("affix");
|
||||
} else {
|
||||
$( "#toc" ).detach().appendTo(".toc-col").addClass("affix");
|
||||
}
|
||||
}
|
||||
|
||||
$( document ).ready(function() {
|
||||
|
||||
@ -8,7 +16,7 @@ $( document ).ready(function() {
|
||||
// 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 affix");
|
||||
}
|
||||
// activate tooltips. although this is a bootstrap js function, it must be activated this way in your theme.
|
||||
@ -20,6 +28,8 @@ $( document ).ready(function() {
|
||||
* AnchorJS
|
||||
*/
|
||||
anchors.add('h2,h3,h4,h5');
|
||||
// Check if TOC needs to be moved on page load
|
||||
moveToc();
|
||||
|
||||
});
|
||||
|
||||
@ -53,3 +63,6 @@ $(function() {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Check if TOC needs to be moved on window resizing
|
||||
$(window).resize(function () {moveToc();});
|
@ -125,6 +125,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.
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -122,6 +122,14 @@ The examples below won't repeat this taskdef element, as this is always required
|
||||
</td>
|
||||
<td>No</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>threads</td>
|
||||
<td>
|
||||
Sets the number of threads used by PMD. Set threads to <code>0</code> to disable multi-threading processing.
|
||||
Default: 1
|
||||
</td>
|
||||
<td>No</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
|
@ -39,71 +39,17 @@ All other members are now deprecated for removal.
|
||||
|
||||
### 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.
|
||||
* Several members of {% jdoc core::PMD %}, including:
|
||||
* Several members of {% jdoc core::PMD %} have been newly deprecated, including:
|
||||
- `PMD#EOL`
|
||||
- `PMD#SUPPRESS_MARKER`
|
||||
- `PMD#configuration`
|
||||
- `PMD#processFiles`
|
||||
- `PMD#getApplicableFiles`
|
||||
|
||||
#### Source-incompatible changes
|
||||
|
||||
* {% jdoc core::PMDConfiguration#prependClasspath(java.lang.String) %} does not throw
|
||||
a checked `IOException` anymore, but an unchecked `IllegalArgumentException`. This change
|
||||
is not source-compatible, but should make the API easier to use.
|
||||
|
||||
#### 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 %}
|
||||
|
||||
|
@ -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.
|
||||
- <a href="https://docs.pmd-code.org/apidocs/pmd-core/6.43.0/net/sourceforge/pmd/Report.html#"><code>Report</code></a>: the constructor and other construction methods like addViolation or createReport
|
||||
- <a href="https://docs.pmd-code.org/apidocs/pmd-core/6.43.0/net/sourceforge/pmd/RuleContext.html#"><code>RuleContext</code></a>: all constructors, getters and setters. A new set
|
||||
of stable methods, matching those in PMD 7, was added to replace the `addViolation`
|
||||
overloads of <a href="https://docs.pmd-code.org/apidocs/pmd-core/6.43.0/net/sourceforge/pmd/lang/rule/AbstractRule.html#"><code>AbstractRule</code></a>. In PMD 7, `RuleContext` will
|
||||
be the API to report violations, and it can already be used as such in PMD 6.
|
||||
- The field <a href="https://docs.pmd-code.org/apidocs/pmd-core/6.43.0/net/sourceforge/pmd/PMD.html#configuration"><code>configuration</code></a> 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.
|
||||
|
||||
- <a href="https://docs.pmd-code.org/apidocs/pmd-core/6.43.0/net/sourceforge/pmd/RuleSet.html#"><code>RuleSet</code></a>: methods that serve to apply rules, including `apply`, `start`, `end`, `removeDysfunctionalRules`
|
||||
- <a href="https://docs.pmd-code.org/apidocs/pmd-core/6.43.0/net/sourceforge/pmd/renderers/AbstractAccumulatingRenderer.html#renderFileReport(Report)"><code>AbstractAccumulatingRenderer#renderFileReport</code></a> 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.
|
||||
|
||||
<a href="https://docs.pmd-code.org/apidocs/pmd-core/6.43.0/net/sourceforge/pmd/RuleContext.html#"><code>RuleContext</code></a> now requires setting the current rule before calling
|
||||
<a href="https://docs.pmd-code.org/apidocs/pmd-core/6.43.0/net/sourceforge/pmd/Rule.html#apply(java.util.List,net.sourceforge.pmd.RuleContext)"><code>apply</code></a>. 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.
|
||||
|
@ -8,7 +8,7 @@
|
||||
<parent>
|
||||
<groupId>net.sourceforge.pmd</groupId>
|
||||
<artifactId>pmd</artifactId>
|
||||
<version>6.43.0-SNAPSHOT</version>
|
||||
<version>6.44.0-SNAPSHOT</version>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>net.sourceforge.pmd</groupId>
|
||||
<artifactId>pmd</artifactId>
|
||||
<version>6.43.0-SNAPSHOT</version>
|
||||
<version>6.44.0-SNAPSHOT</version>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>net.sourceforge.pmd</groupId>
|
||||
<artifactId>pmd</artifactId>
|
||||
<version>6.43.0-SNAPSHOT</version>
|
||||
<version>6.44.0-SNAPSHOT</version>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -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;
|
||||
|
@ -59,7 +59,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.")
|
||||
|
@ -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<ReportingDescriptor, List<Location>> locationsByRule = new HashMap<>();
|
||||
private final List<ReportingDescriptor> rules = new ArrayList<>();
|
||||
private final List<Result> results = new ArrayList<>();
|
||||
private final List<ToolConfigurationNotification> toolConfigurationNotifications = new ArrayList<>();
|
||||
private final List<ToolExecutionNotification> 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<Location> ruleLocation = locationsByRule.containsKey(ruleDescriptor) ? locationsByRule.get(ruleDescriptor) : new ArrayList<Location>();
|
||||
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<ReportingDescriptor> rules = new ArrayList<>(locationsByRule.keySet());
|
||||
|
||||
final List<Result> results = new ArrayList<>();
|
||||
for (int i = 0, size = rules.size(); i < size; i++) {
|
||||
ReportingDescriptor rule = rules.get(i);
|
||||
List<Location> 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<Location> 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;
|
||||
}
|
||||
|
@ -15,6 +15,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.RuleContext;
|
||||
import net.sourceforge.pmd.RulePriority;
|
||||
import net.sourceforge.pmd.RuleViolation;
|
||||
@ -64,26 +65,53 @@ public abstract class AbstractRendererTest {
|
||||
|
||||
protected Report reportOneViolation() {
|
||||
Report report = new Report();
|
||||
report.addRuleViolation(newRuleViolation(1));
|
||||
report.addRuleViolation(newRuleViolation(1, 1, 1, 1, createFooRule()));
|
||||
return report;
|
||||
}
|
||||
|
||||
private Report reportTwoViolations() {
|
||||
protected Report reportTwoViolations() {
|
||||
Report report = new Report();
|
||||
RuleViolation informationalRuleViolation = newRuleViolation(1);
|
||||
informationalRuleViolation.getRule().setPriority(RulePriority.LOW);
|
||||
RuleViolation informationalRuleViolation = newRuleViolation(1, 1, 1, 1, createFooRule());
|
||||
report.addRuleViolation(informationalRuleViolation);
|
||||
RuleViolation severeRuleViolation = newRuleViolation(2);
|
||||
severeRuleViolation.getRule().setPriority(RulePriority.HIGH);
|
||||
RuleViolation severeRuleViolation = newRuleViolation(1, 1, 1, 2, createBooRule());
|
||||
report.addRuleViolation(severeRuleViolation);
|
||||
return report;
|
||||
}
|
||||
|
||||
protected RuleViolation newRuleViolation(int endColumn) {
|
||||
DummyNode node = createNode(endColumn);
|
||||
protected DummyNode createNode(int beginLine, int beginColumn, int endLine, int endColumn) {
|
||||
DummyNode node = new DummyNode(1);
|
||||
node.testingOnlySetBeginLine(beginLine);
|
||||
node.testingOnlySetBeginColumn(beginColumn);
|
||||
node.testingOnlySetEndLine(endLine);
|
||||
node.testingOnlySetEndColumn(endColumn);
|
||||
return node;
|
||||
}
|
||||
|
||||
protected RuleViolation newRuleViolation(int beginLine, int beginColumn, int endLine, int endColumn, Rule rule) {
|
||||
DummyNode node = createNode(beginLine, beginColumn, endLine, endColumn);
|
||||
RuleContext ctx = new RuleContext();
|
||||
ctx.setSourceCodeFile(new File(getSourceCodeFilename()));
|
||||
return new ParametricRuleViolation<Node>(new FooRule(), ctx, node, "blah");
|
||||
return new ParametricRuleViolation<Node>(rule, ctx, 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;
|
||||
}
|
||||
|
||||
protected static DummyNode createNode(int endColumn) {
|
||||
@ -97,14 +125,11 @@ public abstract class AbstractRendererTest {
|
||||
|
||||
@Test
|
||||
public void testRuleWithProperties() throws Exception {
|
||||
DummyNode node = createNode(1);
|
||||
RuleContext ctx = new RuleContext();
|
||||
ctx.setSourceCodeFile(new File(getSourceCodeFilename()));
|
||||
Report report = new Report();
|
||||
RuleWithProperties theRule = new RuleWithProperties();
|
||||
theRule.setProperty(RuleWithProperties.STRING_PROPERTY_DESCRIPTOR,
|
||||
"the string value\nsecond line with \"quotes\"");
|
||||
report.addRuleViolation(new ParametricRuleViolation<Node>(theRule, ctx, node, "blah"));
|
||||
report.addRuleViolation(newRuleViolation(1, 1, 1, 1, theRule));
|
||||
String rendered = ReportTest.render(getRenderer(), report);
|
||||
assertEquals(filter(getExpectedWithProperties()), filter(rendered));
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -6,17 +6,11 @@ package net.sourceforge.pmd.renderers;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import net.sourceforge.pmd.PMD;
|
||||
import net.sourceforge.pmd.Report;
|
||||
import net.sourceforge.pmd.ReportTest;
|
||||
import net.sourceforge.pmd.RuleContext;
|
||||
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;
|
||||
|
||||
public class CodeClimateRendererTest extends AbstractRendererTest {
|
||||
@ -75,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"
|
||||
@ -90,18 +84,15 @@ public class CodeClimateRendererTest extends AbstractRendererTest {
|
||||
|
||||
@Test
|
||||
public void testXPathRule() throws Exception {
|
||||
DummyNode node = createNode(1);
|
||||
RuleContext ctx = new RuleContext();
|
||||
ctx.setSourceCodeFile(new File(getSourceCodeFilename()));
|
||||
Report report = new Report();
|
||||
|
||||
XPathRule theRule = new XPathRule();
|
||||
theRule.setProperty(XPathRule.XPATH_DESCRIPTOR, "//dummyNode");
|
||||
|
||||
// Setup as FooRule
|
||||
theRule.setDescription("desc");
|
||||
theRule.setName("Foo");
|
||||
|
||||
report.addRuleViolation(new ParametricRuleViolation<Node>(theRule, ctx, node, "blah"));
|
||||
report.addRuleViolation(newRuleViolation(1, 1, 1, 2, theRule));
|
||||
String rendered = ReportTest.render(getRenderer(), report);
|
||||
|
||||
// Output should be the exact same as for non xpath rules
|
||||
|
@ -15,6 +15,7 @@ import org.apache.commons.io.IOUtils;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import net.sourceforge.pmd.FooRule;
|
||||
import net.sourceforge.pmd.Report;
|
||||
import net.sourceforge.pmd.Report.ConfigurationError;
|
||||
import net.sourceforge.pmd.Report.ProcessingError;
|
||||
@ -90,7 +91,7 @@ public class JsonRendererTest extends AbstractRendererTest {
|
||||
Map<Integer, String> suppressedLines = new HashMap<>();
|
||||
suppressedLines.put(1, "test");
|
||||
rep.suppress(suppressedLines);
|
||||
rep.addRuleViolation(newRuleViolation(1));
|
||||
rep.addRuleViolation(newRuleViolation(1, 1, 1, 1, new FooRule()));
|
||||
String actual = ReportTest.render(getRenderer(), rep);
|
||||
String expected = readFile("expected-suppressed.json");
|
||||
Assert.assertEquals(filter(expected), filter(actual));
|
||||
|
@ -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 + " : 2" + 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);
|
||||
}
|
||||
}
|
||||
|
@ -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,
|
||||
|
@ -4,27 +4,20 @@
|
||||
|
||||
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.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
import org.junit.Test;
|
||||
|
||||
import net.sourceforge.pmd.FooRule;
|
||||
import net.sourceforge.pmd.Report;
|
||||
import net.sourceforge.pmd.ReportTest;
|
||||
import net.sourceforge.pmd.RuleContext;
|
||||
import net.sourceforge.pmd.RulePriority;
|
||||
import net.sourceforge.pmd.RuleViolation;
|
||||
import net.sourceforge.pmd.lang.ast.DummyNode;
|
||||
import net.sourceforge.pmd.lang.ast.Node;
|
||||
import net.sourceforge.pmd.lang.rule.AbstractRule;
|
||||
import net.sourceforge.pmd.lang.rule.ParametricRuleViolation;
|
||||
import net.sourceforge.pmd.Rule;
|
||||
|
||||
public class SarifRendererTest extends AbstractRendererTest {
|
||||
@Override
|
||||
@ -74,47 +67,38 @@ 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 <a href="https://github.com/pmd/pmd/issues/3768"> [core] SARIF formatter reports multiple locations
|
||||
* when it should report multiple results #3768</a>
|
||||
*/
|
||||
@Test
|
||||
public void testRendererMultiple() throws Exception {
|
||||
// Setup
|
||||
Report rep = reportTwoViolations();
|
||||
|
||||
// Exercise
|
||||
public void testRendererMultipleLocations() throws Exception {
|
||||
Report rep = reportThreeViolationsTwoRules();
|
||||
String actual = ReportTest.render(getRenderer(), rep);
|
||||
|
||||
// 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 Report reportTwoViolations() {
|
||||
private Report reportThreeViolationsTwoRules() {
|
||||
Rule fooRule = createFooRule();
|
||||
Rule booRule = createBooRule();
|
||||
|
||||
Report report = new Report();
|
||||
RuleViolation informationalRuleViolation = newRuleViolation(1, "Foo");
|
||||
informationalRuleViolation.getRule().setPriority(RulePriority.LOW);
|
||||
report.addRuleViolation(informationalRuleViolation);
|
||||
RuleViolation severeRuleViolation = newRuleViolation(2, "Boo");
|
||||
severeRuleViolation.getRule().setPriority(RulePriority.HIGH);
|
||||
report.addRuleViolation(severeRuleViolation);
|
||||
report.addRuleViolation(newRuleViolation(1, 1, 1, 10, fooRule));
|
||||
report.addRuleViolation(newRuleViolation(5, 1, 5, 11, fooRule));
|
||||
report.addRuleViolation(newRuleViolation(2, 2, 3, 1, booRule));
|
||||
return report;
|
||||
}
|
||||
|
||||
private RuleViolation newRuleViolation(int endColumn, String ruleName) {
|
||||
DummyNode node = createNode(endColumn);
|
||||
RuleContext ctx = new RuleContext();
|
||||
ctx.setSourceCodeFile(new File(getSourceCodeFilename()));
|
||||
AbstractRule fooRule = new FooRule();
|
||||
fooRule.setName(ruleName);
|
||||
return new ParametricRuleViolation<Node>(fooRule, ctx, node, "blah");
|
||||
}
|
||||
|
||||
private String readFile(String name) {
|
||||
try (InputStream in = SarifRendererTest.class.getResourceAsStream("sarif/" + name)) {
|
||||
String asd = IOUtils.toString(in, StandardCharsets.UTF_8);
|
||||
|
@ -71,7 +71,8 @@ public class SummaryHTMLRendererTest extends AbstractRendererTest {
|
||||
return "<html><head><title>PMD</title></head><body>" + PMD.EOL + "<center><h2>Summary</h2></center>" + PMD.EOL
|
||||
+ "<table align=\"center\" cellspacing=\"0\" cellpadding=\"3\">" + PMD.EOL
|
||||
+ "<tr><th>Rule name</th><th>Number of violations</th></tr>" + PMD.EOL
|
||||
+ "<tr><td>Foo</td><td align=center>2</td></tr>" + PMD.EOL + "</table>" + PMD.EOL
|
||||
+ "<tr><td>Boo</td><td align=center>1</td></tr>" + PMD.EOL
|
||||
+ "<tr><td>Foo</td><td align=center>1</td></tr>" + PMD.EOL + "</table>" + PMD.EOL
|
||||
+ "<center><h2>Detail</h2></center><table align=\"center\" cellspacing=\"0\" cellpadding=\"3\"><tr>"
|
||||
+ PMD.EOL
|
||||
+ "<center><h3>PMD report</h3></center><center><h3>Problems found</h3></center><table align=\"center\" cellspacing=\"0\" cellpadding=\"3\"><tr>"
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -93,8 +93,4 @@ public class VBHTMLRendererTest extends AbstractRendererTest {
|
||||
+ "--></style><body><center><br><table border=\"0\" width=\"80%\"><tr id=TableHeader><td colspan=\"2\"><font class=title> Configuration problems found</font></td></tr><tr id=RowColor2><td><font class=body>"
|
||||
+ error.rule().getName() + "</font></td><td><font class=body>" + error.issue() + "</font></td></tr></table></center></body></html>" + PMD.EOL;
|
||||
}
|
||||
|
||||
public static junit.framework.Test suite() {
|
||||
return new junit.framework.JUnit4TestAdapter(VBHTMLRendererTest.class);
|
||||
}
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user