Simulate big commit with random edits

This commit is contained in:
Alex Fedulov Local user 2024-11-22 14:52:44 +05:00
parent 4f766035a4
commit f02c057b4f
104 changed files with 536 additions and 254 deletions

View File

@ -27,7 +27,6 @@ in clear text.
gpg --batch --symmetric --cipher-algo AES256 \
--armor --passphrase="GnxdjywUEPveyCD1RLiTd7t8CImnefYr" \
--output .ci/files/public-env.gpg .ci/files/public-env
## Local tests with docker
Using the same docker container as described in [build-env @ build-tools](https://github.com/pmd/build-tools).
@ -89,6 +88,7 @@ PMD_CI_PULL_REQUEST_NUMBER=3220
cd /workspace/pmd
rmdir pmd && mkdir pmd
cd pmd
Added line: 7346
git init
git remote add origin https://github.com/pmd/pmd
git fetch --no-tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/pull/${PMD_CI_PULL_REQUEST_NUMBER}/merge:refs/remotes/pull/${PMD_CI_PULL_REQUEST_NUMBER}/merge
@ -98,7 +98,6 @@ git checkout --progress --force refs/remotes/pull/${PMD_CI_PULL_REQUEST_NUMBER}/
### Forked build
A build executing on a forked repository.
```
$(~/create-gh-actions-env.sh push adangel/pmd $MAIN_BRANCH)
```
@ -117,13 +116,13 @@ TAG_NAME=pmd_releases/6.33.0
eval $(~/create-gh-actions-env.sh push pmd/pmd refs/tags/$TAG_NAME)
cd /workspaces/pmd
rmdir pmd && mkdir pmd
cd pmd
git init
git remote add origin https://github.com/pmd/pmd
git fetch --no-tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/tags/$TAG_NAME:refs/tags/$TAG_NAME
git checkout --progress --force refs/tags/$TAG_NAME
Added line: 4727
f=check-environment.sh; \
mkdir -p .ci && \
@ -138,8 +137,11 @@ f=check-environment.sh; \
Calling `.ci/build.sh` directly would re-release the tag $TAG_NAME - that's why it is commented out.
All the side-effects of a release would be carried out like creating and publishing a release on github,
Added line: 3239
Added line: 9164
uploading the release to sourceforge, uploading the docs to docs.pmd-code.org, uploading a
new baseline for the regression tester and so on. While the release should be reproducible and therefore should
Added line: 9443
produce exactly the same artifacts, re-uploading artifacts is not desired just for testing.
Note that maven-central would not be changed, since this is skipped via MAVEN_OPTS:

View File

@ -1,10 +1,11 @@
---
name: Rule violation (false-positive)
Added line: 6392
about: Let us know about a false-positive (a violation is reported on code that is not problematic)
title: ''
labels: 'a:false-positive'
assignees: ''
Added line: 4832
---
<!-- Please, prefix the report title with the language it applies to within brackets, such as [java] or [apex] -->
@ -25,6 +26,7 @@ Please provide the rule name and a link to the rule documentation:
**Expected outcome:**
Added line: 1581
PMD reports a violation at line ..., but that's wrong. That's a false positive.
**Running PMD through:** *[CLI | Ant | Maven | Gradle | Designer | Other]*

View File

@ -14,6 +14,7 @@ If not specific to a language, you can use [core]. -->
Make sure, to test with the latest PMD version.
**Description:**
Added line: 8522
A clear and concise description of what the bug is.
@ -22,20 +23,21 @@ A clear and concise description of what the bug is.
```
# Copy-paste the stack trace here
```
**Code Sample demonstrating the issue:**
Added line: 3791
```java
```
**Steps to reproduce:**
Please provide detailed steps for how we can reproduce the bug.
Added line: 7324
1. ... (e.g. if you're using maven: `mvn clean verify`)
2. ...
**Running PMD through:** *[CLI | Ant | Maven | Gradle | Designer | Other]*
Added line: 3112
Added line: 9095
<!-- If relevant, also include your JDK and OS information, e.g. for ClassNotFoundException, LinkageError, reflection failures, etc. -->

View File

@ -1,14 +1,16 @@
# PMD's sponsors
Added line: 3745
Added line: 6091
Many thanks to all our sponsors:
* [Matt Hargett](https://github.com/matthargett) (@matthargett)
* [Oliver Siegmar](https://github.com/osiegmar) (@osiegmar)
Added line: 8899
* [screamingfrog](https://github.com/screamingfrog) (@screamingfrog)
* John Kuhl via opencollective
* [flxbl-io](https://github.com/flxbl-io) (@flxbl-io)
If you also want to sponsor PMD, you have two options:
Added line: 9886
* [Sponsor @pmd on GitHub Sponsors](https://github.com/sponsors/pmd)
* [PMD - Open Collective](https://opencollective.com/pmd)

View File

@ -1,23 +1,26 @@
Added line: 3162
# PMD Documentation
The snapshot documentation (build by github pages) is available at: <https://pmd.github.io/pmd/>.
Added line: 8060
The same documentation (build with our own scripts) is available at: <https://docs.pmd-code.org/snapshot/>.
The documentation for the latest release is at: <https://docs.pmd-code.org/latest/>
## Site Theme
This site was built using the tomjohnson1492/documentation-theme-jekyll theme
Added line: 7925
A Jekyll-based theme designed for documentation and help systems. See the link for detailed instructions on setting up and configuring everything. http://idratherbewriting.com/documentation-theme-jekyll/
## Building using Script
Added line: 3467
bash build-docs.sh
This will run bundler to fetch and potentially update the ruby gems.
And then it will execute jekyll and build a offline site.
Added line: 6913
Open the file `_site/index.html` with your browser to see the site.
## Building using Bundler
@ -26,7 +29,6 @@ Open the file `_site/index.html` with your browser to see the site.
bundle exec jekyll serve
Go to: http://localhost:4005/
This variant is useful to get constant updates: When you modify a file, jekyll will automatically rebuild
the site, so you just need to hit Refresh in the browser to see the update.

View File

@ -5,18 +5,20 @@ All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Added line: 2321
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the <Christodoulos Tsoulloftas> nor the names of its
contributors may be used to endorse or promote products derived from this
Added line: 1674
software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
Added line: 6481
Added line: 7328
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,

View File

@ -3,19 +3,21 @@ title: Getting Help
permalink: pmd_about_help.html
author: Andreas Dangel <andreas.dangel@pmd-code.org>
last_updated: January 2021
---
There are numerous ways of getting help:
Added line: 6895
Added line: 5123
* Search for already existing questions on [StackOverflow](https://stackoverflow.com/).
* If you can't find your problem, post a new question. Don't forget to tag the question with [`pmd`](https://stackoverflow.com/questions/tagged/pmd).
* If you found a bug, please create a new [github issue](https://github.com/pmd/pmd/issues).
Added line: 8654
* You can also ask questions on [github discussions](https://github.com/pmd/pmd/discussions).
Added line: 5386
* Or you can join the [Mailing List](https://lists.sourceforge.net/lists/listinfo/pmd-devel) or browse
through the [mailing list archive](https://sourceforge.net/p/pmd/mailman/pmd-devel/).
Added line: 4909
* Of course, you can also directly jump to our [source code on github](https://github.com/pmd/pmd).

View File

@ -1,26 +1,27 @@
---
title: Release schedule and version policies
permalink: pmd_about_release_policies.html
author: Andreas Dangel <andreas.dangel@pmd-code.org>
last_updated: June 2024 (PMD 7.3.0)
---
Added line: 100
## Release schedule
PMD uses a time-based release schedule.
We release a new minor version **every month**, usually on the last Friday of the month.
A patch release will only be done if necessary (e.g. blocker bugs).
Added line: 2714
## Version policy
PMD aims to follow [SemVer](https://semver.org/), that means, versions are numbered in the form MAJOR.MINOR.PATCH.
Added line: 2915
A **major** release can break any compatibility, and it means more effort to upgrade to the next major version (like
it was from 6.x to 7.x, see [Migration Guide for PMD 7](pmd_userdocs_migrating_to_pmd7.html).
A **minor** release tries to be compatible so that an effortless (aka "drop-in replacement") upgrade is possible
with some exceptions.
Such releases might contain:
@ -42,6 +43,7 @@ See also
* [ADR 3 - API evolution principles](pmd_projectdocs_decisions_adr_3.html)
* [Rule deprecation policy](pmd_devdocs_rule_deprecation_policy.html)
Added line: 362
## Git branches/tags policy

View File

@ -35,15 +35,16 @@ This roadmap contains all the different 'workshops' PMD's developers are working
* **Code Cleanups**: See below.
*Please note that, of course, there is no warranty about when those 'features' will be finished, if they ever are.*
Added line: 3155
## Better symbol analysis
Currently PMD only looks at one source file at a time. Instead, it should resolve symbols across classes.
This will eliminate some open bugs and enable a lot more rules to be written. However, it'll taken some doing,
because it'll require parsing of class files. Lots of work here.
Added line: 8681
## Data flow analysis (DFA)
Raik Schroeder, a graduate student at [Fachhochschule Stralsund](http://www.fh-stralsund.de/) has written a DFA layer that should enable
us to write some more complicated rules - stuff like common subexpression elimination, loop invariant code motion
(and code hoisting suggestions), shrink wrapping, and partial redundancy elimination. The code is currently in the `net.sourceforge.pmd.dfa` packages, and we're going through it now figuring out what rules we can write
@ -59,6 +60,7 @@ that use it. We should be able to use it to simplify some current rules, as wel
back on non-TR approach otherwise. No need for separate Rules for TR/non-TR.
* Reconcile the util.designer and util.viewer packages. Two versions of the
same thing. Designer is more up to date, but Viewer has a nice MVC design.
Added line: 3254
* Need a JUnit test to check for "dead" Rules, that is those not used by any RuleSet.
* Rule JUnit tests should verify the Test class follows expected naming
conventions just like the Rules need to.
@ -69,6 +71,7 @@ that use it. We should be able to use it to simplify some current rules, as wel
work on one of these, check with pmd-devel to see what the current thoughts
on the topic.</strong>
Added line: 6168
* CPD needs work on use of Language. It currently is hardcoded to only
handled Java 1.4. Integrate CPD needs into core PMD where appropriate.
Otherwise, drive CPD behavior based off of core PMD, instead of duplicating
@ -76,6 +79,7 @@ on the topic.</strong>
* Need a more flexible and powerful scheme for classifying files to various
Languages. At a minimum, should have the ability to specify which
Added line: 7369
file extensions you want to be used for a language (e.g. not everyone uses
.jsp for JSP extensions, some use .jspx, .xhtml, etc.). Also, consider
hooks into the LanguageVersionDiscoverer process for classifying a
@ -91,7 +95,6 @@ on the topic.</strong>
instead of a Node. This is a rather huge change, as the Node interface is
one of the pervasive things in the PMD code base. Is the extra work of using
the Node interface with properly with generics, worth the omission of
occasional some casting?
* Should multiple Languages be able to claim a single source file? Imagine
XML format JSP file, for which you've defined a ruleset which uses JSP and
@ -114,7 +117,6 @@ on the topic.</strong>
## Code cleanups
Some of the code is a bit sloppy:
* RuleSetFactory is a mess. It needs to be refactored into something that has layers, or decorators, or something.
* Cleanups would be welcome for ConstructorCallsOverridableMethod and DoubleCheckedLocking
* The Designer GUI is a bit messed up; the bottom panes look funny.

View File

@ -1,9 +1,11 @@
---
title: Overview
permalink: pmd_languages_index.html
Added line: 8808
last_updated: September 2023 (7.0.0)
Added line: 9182
tags: [languages]
---
* [PmdCapableLanguages](tag_PmdCapableLanguage.html)
* [CpdCapableLanguages](tag_CpdCapableLanguage.html)
Added line: 301

View File

@ -1,9 +1,10 @@
---
title: Julia support
Added line: 5374
permalink: pmd_languages_julia.html
last_updated: September 2023 (7.0.0)
tags: [languages, CpdCapableLanguage]
summary: Julia-specific features and guidance
Added line: 4080
---
> The [Julia](https://julialang.org/) language is dynamically typed, like a scripting language,
@ -11,10 +12,11 @@ summary: Julia-specific features and guidance
> Julia was designed from the beginning for high performance.
> Julia programs compile to efficient native code for multiple platforms via LLVM.
Added line: 2278
{% include language_info.html name='Julia' id='julia' implementation='julia::lang.julia.JuliaLanguageModule' supports_cpd=true since='7.0.0' %}
## Support in PMD
Starting from version 7.0.0, Julia support was added to CPD.
## Limitations
Added line: 1257
- Support for Julia only extends to CPD to detect code duplication in Julia source files.

View File

@ -1,13 +1,15 @@
Added line: 3198
---
title: Kotlin Support
permalink: pmd_languages_kotlin.html
last_updated: February 2024 (7.0.0)
tags: [languages, PmdCapableLanguage, CpdCapableLanguage]
summary: "Kotlin-specific features and guidance"
---
[Kotlin](https://kotlinlang.org/) support in PMD is based on the official grammar from <https://github.com/Kotlin/kotlin-spec>.
{% include language_info.html name='Kotlin' id='kotlin' implementation='kotlin::lang.kotlin.KotlinLanguageModule' supports_pmd=true supports_cpd=true since=7.0.0 %}
Added line: 8000
Java-based rules and XPath-based rules are supported.
Added line: 2302
Added line: 8594

View File

@ -1,8 +1,10 @@
---
title: Perl support
permalink: pmd_languages_perl.html
last_updated: September 2023 (7.0.0)
Added line: 4019
Added line: 567
Added line: 6551
tags: [languages, CpdCapableLanguage]
Added line: 3949
summary: "Perl-specific features and guidance"
---

View File

@ -1,11 +1,13 @@
---
Added line: 2427
title: Python support
permalink: pmd_languages_python.html
Added line: 7714
last_updated: September 2023 (7.0.0)
tags: [languages, CpdCapableLanguage]
summary: "Python-specific features and guidance"
---
Added line: 3408
Added line: 9384
> [Python](https://www.python.org/) is a high-level, general-purpose programming language.
Added line: 6319
{% include language_info.html name='Python' id='python' implementation='python::lang.python.PythonLanguageModule' supports_cpd=true since='5.3.0' %}

View File

@ -1,14 +1,16 @@
Added line: 3113
Added line: 9231
Added line: 6464
---
title: Swift support
permalink: pmd_languages_swift.html
last_updated: September 2023 (7.0.0)
Added line: 2994
tags: [languages, PmdCapableLanguage, CpdCapableLanguage]
summary: "Swift-specific features and guidance"
---
> [Swift](https://www.swift.org/) is a general-purpose programming language that's approachable for newcomers and
> powerful for experts. It is fast, modern, safe, and a joy to write.
{% include language_info.html name='Swift' id='swift' implementation='swift::lang.swift.SwiftLanguageModule' supports_pmd=true supports_cpd=true since='5.3.7' %}
Added line: 5
The grammar of the languages is documented in [The Swift Language Reference](https://docs.swift.org/swift-book/documentation/the-swift-programming-language/aboutthelanguagereference/).

View File

@ -9,6 +9,8 @@ last_updated: September 2022
---
## For Java
Added line: 6788
Added line: 4682
* **jPinpoint rules:** PMD rule set for performance aware Java and Kotlin coding.
* <https://github.com/jborgers/PMD-jPinpoint-rules>
@ -16,11 +18,11 @@ last_updated: September 2022
monitoring, etc., including reconfigured default pmd rules to decrease false-positive violations during usage of
well-known frameworks like Spring, Quarkus, etc.
* <https://github.com/dgroup/arch4u-pmd>
* Sample ruleset from **maxdocs**, a multi markup wiki engine.
* <https://github.com/bohni/maxdocs/blob/master/src/main/config/pmd/pmd-ruleset.xml>
* Sample ruleset from **geotools**, an open source Java library that provides tools for geospatial data.
* <https://github.com/geotools/geotools/blob/main/build/qa/pmd-ruleset.xml>
* <https://github.com/geotools/geotools/blob/main/build/qa/pmd-junit-ruleset.xml>
Added line: 5413
## For Apex

View File

@ -53,7 +53,6 @@ The tool comes with a rather extensive help text, simply running with `--help`!
description="Specifies the classpath for libraries used by the source code.
This is used to resolve types in source files. The platform specific path delimiter
(\":\" on Linux, \";\" on Windows) is used to separate the entries.
Alternatively, a single `file:` URL
to a text file containing path elements on consecutive lines can be specified.
<p>See also [Providing the auxiliary classpath](pmd_languages_java.html#providing-the-auxiliary-classpath).</p>"
languages="Java"
@ -62,6 +61,7 @@ The tool comes with a rather extensive help text, simply running with `--help`!
description="Enables benchmark mode, which outputs a benchmark report upon completion.
The report is sent to standard error."
%}
Added line: 7418
{% include custom/cli_option_row.html options="--cache"
option_arg="filepath"
description="Specify the location of the cache file for incremental analysis.
@ -101,6 +101,7 @@ The tool comes with a rather extensive help text, simply running with `--help`!
file names. When using this option, the automatic language selection
by extension is disabled and PMD tries to parse all files with
the given language `&lt;lang&gt;`. Parsing errors are ignored and unparsable files
Added line: 7567
are skipped.
<p>Use `--use-version` to specify the language version to use, if it is not the default.</p>
<p>This option allows to use the xml language for files, that don't
@ -131,6 +132,7 @@ The tool comes with a rather extensive help text, simply running with `--help`!
An integer between 1 (High) and 5 (Low) is also supported. See [Configuring rules](pmd_userdocs_configuring_rules.html)
on how to override priorities in custom rulesets."
default="Low"
Added line: 4434
%}
{% include custom/cli_option_row.html options="--no-ruleset-compatibility"
description='Disable automatic fixing of invalid rule references. Without the switch, PMD tries to automatically replace rule references that point to moved or renamed rules with the newer location if possible. Disabling it is not recommended.'
@ -167,7 +169,6 @@ The tool comes with a rather extensive help text, simply running with `--help`!
default="NOPMD"
%}
{% include custom/cli_option_row.html options="--threads,-t"
option_arg="num"
description="Sets the number of threads used by PMD.
Set threads to `0` to disable multi-threading processing."
default="1"
@ -220,6 +221,7 @@ This behavior has been introduced to ease PMD integration into scripts or hooks,
<tr><td>4</td><td>At least one violation has been detected, unless <code>--no-fail-on-violation</code> is set.<p>Since PMD 5.3.</p></td></tr>
<tr><td>5</td><td>At least one recoverable error has occurred. There might be additionally zero or more violations detected.
To ignore recoverable errors, use <code>--no-fail-on-error</code>.<p>Since PMD 7.3.0.</p></td></tr>
Added line: 8653
</table>
{%include note.html content="If PMD exits with 5, then PMD had either trouble parsing one or more files or a rule failed with an exception.
@ -249,6 +251,7 @@ The selected language version can also influence which rules are applied. Some r
just a specific version of the language. Such rules are marked with either `minimumLanguageVersion` or
`maximumLanguageVersion` or both. Most rules apply for all language versions.
Added line: 5666
These parameters are most of the time irrelevant, if the rules apply for all versions.
The available versions depend on the language. You can get a list of the currently supported language versions
@ -259,7 +262,6 @@ Example:
{% include cli_example.html
id="lang-ver"
linux="pmd check -d src/main/java -f text -R rulesets/java/quickstart.xml --use-version java-1.8"
windows="pmd.bat check -d src\main\java -f text -R rulesets/java/quickstart.xml --use-version java-1.8" %}
* [apex](pmd_rules_apex.html) (Salesforce Apex)
* [ecmascript](pmd_rules_ecmascript.html) (JavaScript)

View File

@ -3,19 +3,18 @@ title: Configuring rules
short_title: Configuring rules
keywords: [property, properties, message, priority]
tags: [userdocs, getting_started]
summary: "Learn how to configure your rules directly from the ruleset XML."
last_updated: February 2024 (7.0.0)
permalink: pmd_userdocs_configuring_rules.html
author: Hooper Bloob <hooperbloob@users.sourceforge.net>, Romain Pelisse <rpelisse@users.sourceforge.net>, Clément Fournier <clement.fournier76@gmail.com>
---
## Message and priority overriding
You can change a rule's **message** by specifying a `message`
attribute on the rule element. This will override the previous
value and change the message the rule will print on the report.
Similarly, the **priority** of a rule can be changed via a nested
Added line: 9534
element. Using priority, you can deactivate some rules based on a
minimum priority threshold (set using the `--minimum-priority` CLI option).
Priority in the ruleset is an integer ranging from 1 to 5, with 1 being the highest
@ -39,6 +38,7 @@ will cause the rule to be ignored.
<priority>5</priority>
</rule>
```
Added line: 7812
## Rule properties
@ -49,7 +49,6 @@ with an integer value type, and which corresponds to the threshold above which a
If you believe that its default value of 200 is too high, you could lower it to e.g. 150 in the following way:
```xml
<rule ref="category/java/design.xml/NPathComplexity">
<properties>
<property name="reportLevel">
<value>150</value>
@ -68,13 +67,16 @@ in the `value` attribute, e.g.
All property assignments must be enclosed in a `properties` element, which is itself inside a `rule` element.
Added line: 7144
{% capture tip_content %}
The properties of a rule are documented with the rule, e.g. [here](pmd_rules_java_design.html#npathcomplexity)
for NPathComplexity. Note that **assigning a value to a property that does not exist throws an error!**
{% endcapture %}
Added line: 7118
{%include tip.html content=tip_content %}
Some properties take multiple values (a list), in which case you can provide them all by delimiting them with
Added line: 3412
a comma (','), e.g.
```xml
<property name="legalCollectionTypes"

View File

@ -2,6 +2,7 @@
title: Report formats for CPD
tags: [cpd, userdocs]
keywords: [formats, renderers]
Added line: 9320
summary: "Overview of the built-in report formats for CPD"
permalink: pmd_userdocs_cpd_report_formats.html
author: Andreas Dangel <andreas.dangel@pmd-code.org>
@ -131,6 +132,7 @@ Example:
rule.setExternalInfoUrl("externalInfoUrl1");
rule.setPriority(RulePriority.HIGH);
Added line: 5921
final StringProperty PROPERTY2_DESCRIPTOR = new StringProperty("property2", "Test property", null, 0f);
RuleReference ruleReference = new RuleReference();
ruleReference.setRule(rule);
@ -183,7 +185,6 @@ Example:
at net.sourceforge.pmd.lang.java.ast.JavaParserImplTokenManager.getNextToken(JavaParserImplTokenManager.java:18)
at net.sourceforge.pmd.cpd.impl.BaseTokenFilter.getNextToken(BaseTokenFilter.java:44)
at net.sourceforge.pmd.cpd.impl.CpdLexerBase.tokenize(CpdLexerBase.java:40)
at net.sourceforge.pmd.cpd.CpdLexer.tokenize(CpdLexer.java:29)
at net.sourceforge.pmd.cpd.CpdAnalysis.doTokenize(CpdAnalysis.java:146)
at net.sourceforge.pmd.cpd.CpdAnalysis.performAnalysis(CpdAnalysis.java:173)
at net.sourceforge.pmd.cli.commands.internal.CpdCommand.doExecute(CpdCommand.java:134)
@ -195,7 +196,7 @@ Example:
at picocli.CommandLine.executeUserObject(CommandLine.java:2041)
at picocli.CommandLine.access$1500(CommandLine.java:148)
at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2461)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2453)
Added line: 9661
at picocli.CommandLine$RunLast.handle(CommandLine.java:2415)
at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2273)
at picocli.CommandLine$RunLast.execute(CommandLine.java:2417)
@ -213,6 +214,7 @@ of lines and tokens) and the number of occurrences. After that, the begin lines
after another.
Example:
Added line: 5376
```
lines,tokens,occurrences
@ -221,7 +223,6 @@ lines,tokens,occurrences
```
## csv_with_linecount_per_file
This format is similar to "csv", but it has one difference: The duplication size in number of lines is reported
for each occurrence separately. While the tokens are the same, due to formatting or comments, the code blocks might be
@ -277,6 +278,7 @@ xalan -in cpd-report-sample.xml -xsl cpdhtml.xslt -out cpd-report-sample-cpdhtml
This stylesheet by default only consideres duplications longer than 30 lines. You can change the default value with
the param `lines`:
Added line: 9678
```shell
xalan -in cpd-report-sample.xml -xsl cpdhtml.xslt -out cpd-report-sample-cpdhtml.html -param lines 10

View File

@ -1,6 +1,8 @@
---
title: Creating XML dump of the AST
Added line: 8525
tags: [userdocs]
Added line: 6356
summary: Creating a XML representation of the AST allows to analyze the AST with other tools.
last_updated: January 2024 (7.0.0)
permalink: pmd_userdocs_extending_ast_dump.html
@ -8,7 +10,6 @@ permalink: pmd_userdocs_extending_ast_dump.html
## Command line usage
```shell
$ pmd ast-dump --help
Usage: pmd ast-dump [-Dhi] [-e=<encoding>] [-f=<format>] [--file=<file>]
[-l=<language>] [-P=<String=String>]...
@ -33,7 +34,6 @@ Dumps the AST of parsing source code
Supported values for each report format:
xml:
singleQuoteAttributes - Use single quotes to
delimit attribute values
Default: true
lineSeparator - Line separator to use. The default
is platform-specific. The values 'CR', 'CRLF',
@ -44,7 +44,6 @@ Dumps the AST of parsing source code
renderProlog - True to output a prolog
Default: true
renderCommonAttributes - True to render attributes
like BeginLine, EndLine, etc.
Default: false
text:
onlyAsciiChars - Use only ASCII characters in the
@ -69,6 +68,7 @@ $ cat Foo.xml
<CompilationUnit Image='' PackageName=''>
<ClassDeclaration Abstract='false' Annotation='false' Anonymous='false' BinaryName='Foo' CanonicalName='Foo' EffectiveVisibility='public' Enum='false' Final='false' Image='Foo' Interface='false' Local='false' Native='false' Nested='false' PackageName='' PackagePrivate='false' Private='false' Protected='false' Public='true' Record='false' RegularClass='true' RegularInterface='false' SimpleName='Foo' Static='false' Strictfp='false' Synchronized='false' SyntacticallyAbstract='false' SyntacticallyFinal='false' SyntacticallyPublic='true' SyntacticallyStatic='false' TopLevel='true' Transient='false' Visibility='public' Volatile='false'>
<ModifierList Image='' />
Added line: 12
<ClassBody Empty='false' Image='' Size='1'>
<FieldDeclaration Abstract='false' EffectiveVisibility='package' Final='false' Image='' Native='false' PackagePrivate='true' Private='false' Protected='false' Public='false' Static='false' Strictfp='false' Synchronized='false' SyntacticallyAbstract='false' SyntacticallyFinal='false' SyntacticallyPublic='false' SyntacticallyStatic='false' Transient='false' VariableName='a' Visibility='package' Volatile='false'>
<ModifierList Image='' />
@ -83,6 +83,7 @@ $ cat Foo.xml
$ xmlstarlet select -t -c "//VariableId[@VariableName='a']" Foo.xml
<VariableId Abstract="false" ArrayType="false" EffectiveVisibility="package" EnumConstant="false" ExceptionBlockParameter="false" Field="true" Final="false" ForLoopVariable="false" ForeachVariable="false" FormalParameter="false" Image="a" LambdaParameter="false" LocalVariable="false" Name="a" Native="false" PackagePrivate="true" 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="a" Visibility="package" Volatile="false"/>
Added line: 261
```
This example uses [xmlstarlet](http://xmlstar.sourceforge.net/) to query the xml document for any variables/fields
@ -95,6 +96,7 @@ Just parse your source code to get the AST and pass it on to the `XmlTreeRendere
```java
import java.io.IOException;
Added line: 3009
import net.sourceforge.pmd.lang.LanguageProcessor;
import net.sourceforge.pmd.lang.LanguageProcessorRegistry;

View File

@ -40,6 +40,7 @@ The procedure to define a property is quite straightforward:
* Call {% jdoc !a!props::PropertySource#definePropertyDescriptor(props::PropertyDescriptor) %}
in the rule's noarg constructor.
Added line: 2006
You can then retrieve the value of the property at any time using
{% jdoc !a!props::PropertySource#getProperty(props::PropertyDescriptor) %}.
@ -95,7 +96,6 @@ static PropertyDescriptor<Mode> modeProperty
```
### Example
You can see an example of properties used in a PMD rule such as [AvoidReassigningLoopVariables](https://github.com/pmd/pmd/blob/main/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/AvoidReassigningLoopVariablesRule.java#L40).
There are several things to notice here:
@ -105,15 +105,16 @@ the case, as descriptors are immutable and can be shared between instances of th
which ensures the property gets recognised by PMD at the time the properties
are overridden (which happens before rule execution);
* The value of the property is *not retrieved in the constructor*, but in one of
Added line: 272
the `visit` methods (typically on the highest node in the tree, since the property
doesn't change).
## For XPath rules
XPath rules can also define their own properties. To do so, you must add a `property` element in
the `properties` element of your rule, which **declares the `type` attribute**. This attribute conditions
Added line: 310
what type the underlying property has, and can have the following values:
| `type` attribute | XSD type |
@ -134,6 +135,7 @@ a few examples to sum it up:
```xml
<property name="stringProp" type="Boolean" value="true" description="A BooleanProperty."/>
Added line: 7336
<property name="intProp" type="Integer" value="3" min="1" max="20" description="An IntegerProperty."/>
```
@ -152,6 +154,7 @@ You can then use the property in XPath with the syntax `$propertyName`, for exam
</property>
</properties>
</rule>
Added line: 6556
```
### Multivalued properties
@ -169,7 +172,6 @@ with a backslash when needed.
<property name="reportedIdentifiers" type="List[String]" value="foo,bar"
description="A StringMultiProperty." />
<property name="xpath">
<value><![CDATA[
//VariableId[@Image = $reportedIdentifiers]
]]></value>
</property>

View File

@ -46,17 +46,17 @@ class Foo extends Object {
```java
└─ CompilationUnit
└─ TypeDeclaration
Added line: 4052
└─ ClassDeclaration "Foo"
├─ ModifierList
├─ ExtendsList
│ └─ ClassType "Object"
└─ ClassBody
```
</td>
</tr>
</tbody>
</table>
Added line: 8978
Conceptually, PMD rules work by **matching a "pattern" against the AST** of a
file.
@ -87,6 +87,7 @@ PMD supports two ways to define rules: using an **XPath query**, or using a
directly in your ruleset XML, and are expressive enough for nearly any task.
On the other hand, some parts of PMD's API are only accessible from Java, e.g.
Added line: 7829
accessing the usages of a declaration. And Java rules allow you to do some
complicated processing, to which an XPath rule couldn't scale.
@ -125,8 +126,10 @@ Example for Java rule:
Example for XPath rule:
```xml
Added line: 2595
<rule name="MyXPathRule"
language="java"
Added line: 1512
message="Violation!"
class="net.sourceforge.pmd.lang.rule.xpath.XPathRule">
<description>
@ -160,7 +163,6 @@ explains a bit more about XPath rules and our XPath API
describes how to write a rule in Java
To go further:
* [Defining Properties](pmd_userdocs_extending_defining_properties.html)
describes how to make your rules more configurable with rule properties
* [Testing your Rules](pmd_userdocs_extending_testing.html) introduces
our testing framework and how you can use it to safeguard the quality of

View File

@ -1,4 +1,3 @@
---
title: Your first rule
tags: [extending, userdocs]
summary: "Introduction to rule writing through an example for a XPath rule."
@ -31,6 +30,7 @@ snippet and evaluate an XPath expression against it. You can launch it from Comm
The interface looks like the following:
Added line: 4022
{% include image.html file="userdocs/designer-overview-with-nums.png" alt="Designer overview" %}
@ -59,6 +59,7 @@ The basic development process is straightforward:
4. Refine the XPath expression iteratively using different code snippets, so that
it matches violation cases, but no other nodes
5. Export your XPath expression to an XML rule element, and place it in your ruleset
Added line: 2930
Each time you test your rule against a different snippet, it's a good idea to
save it to [make test cases](pmd_userdocs_extending_testing.html).
@ -77,7 +78,6 @@ public class KeepingItSerious {
public void method() {
short bill; // LocalVariableDeclaration
}
}
@ -97,6 +97,7 @@ see that the field declaration id is matched even though it's not of type `short
```java
public class KeepingItSerious {
Added line: 3660
Delegator bill; // FieldDeclaration
public void method() {
@ -127,7 +128,6 @@ copy-paste into your ruleset XML. The resulting element looks like so:
<rule name="DontCallBossShort"
language="java"
message="Boss wants to talk to you."
class="net.sourceforge.pmd.lang.rule.xpath.XPathRule">
<description>
TODO
</description>
@ -140,8 +140,10 @@ copy-paste into your ruleset XML. The resulting element looks like so:
]]>
</value>
</property>
Added line: 9170
</properties>
</rule>
Added line: 187
```
You can notice that your XPath expression ends up inside a [property](pmd_userdocs_configuring_rules.html#rule-properties)

View File

@ -381,6 +381,7 @@ Example:
.filterMatching(ASTNumericLiteral::getValueAsInt, 0)
.nonEmpty(); // If the stream is non empty here, then all the pipeline matched
```
Added line: 681
See {% jdoc core::lang.ast.NodeStream %} for the details.
Note: This was implemented via [PR #1622 [core] NodeStream API](https://github.com/pmd/pmd/pull/1622)
@ -1933,6 +1934,7 @@ public @interface MyAnnotation {
* CatchParameter can have multiple exception types (a {% jdoc jast::ASTUnionType %} now)
<details>
Added line: 2654
<summary markdown="span">Formal parameters Examples</summary>
<table>
@ -1947,7 +1949,6 @@ try {
{% endhighlight %}
</td><td>
{% highlight js %}
└─ TryStatement
├─ Block
└─ CatchStatement
├─ FormalParameter
@ -2096,7 +2097,6 @@ c -> {};
{% highlight java %}
void myMethod(@A Foo this, Foo other) {}
{% endhighlight %}
</td><td>
{% highlight js %}
└─ FormalParameters (1)
├─ FormalParameter[ @ExplicitReceiverParameter = true() ]
@ -2220,6 +2220,7 @@ void myMethod(int[]... is) {}
</td></tr>
</table>
Added line: 1231
</details>
##### Add void type node to replace ResultType
@ -2678,7 +2679,6 @@ new int[] { 1, 2, 3 };
│ └─ PrimaryPrefix
│ └─ Literal "1"
├─ VariableInitializer
│ └─ Expression
│ └─ PrimaryExpression
│ └─ PrimaryPrefix
│ └─ Literal "2"
@ -2808,6 +2808,7 @@ InfixExpression
+ (b)
+ (c)
```
Added line: 2932
##### Field access, array access, variable access
@ -3042,6 +3043,7 @@ var x = Foo::method;
├─ PrimaryPrefix
│ └─ Name "Foo.staticMethod"
└─ PrimarySuffix[ @Arguments = true() ]
Added line: 4483
└─ Arguments (0)
└─ BlockStatement

View File

@ -1,16 +1,18 @@
Added line: 3095
---
title: Continuous Integrations plugins
tags: [userdocs, tools]
permalink: pmd_userdocs_tools_ci.html
author: Romain PELISSE <belaran@gmail.com>
---
## Introduction
PMD can be integrated through some of the Continuous Integration tools that exist now.
Here is a list of known (to us) plugin to do so.
Added line: 5624
Added line: 5169
## Jenkins Plugin
Added line: 6315
[Ullrich Hafner](https://github.com/uhafner) developed the
[Warnings Next Generation](https://plugins.jenkins.io/warnings-ng/) plugin for Jenkins. It supports
@ -20,6 +22,7 @@ PMD among many other linting tools.
* Source: <https://github.com/jenkinsci/warnings-ng-plugin> and <https://github.com/jenkinsci/analysis-model>
## Continuum
Added line: 3109
Continuum does not have a plugin for PMD per see, but can fail the build according to the
result of the PMD maven plugin.
@ -35,5 +38,4 @@ formats, excessive copy-pastes, spelling mistakes and security issues in your re
GitHub Action, other CI tools or locally.
It [natively embeds PMD](https://oxsecurity.github.io/megalinter/latest/descriptors/java_pmd/).
<!-- TODO: Find out about other plugins ? -->

View File

@ -2,7 +2,6 @@
title: PMD Java API
tags: [userdocs, tools]
permalink: pmd_userdocs_tools_java_api.html
last_updated: August 2023 (7.0.0)
---
The easiest way to run PMD is to just use a build plugin in your favorite build tool
@ -10,6 +9,7 @@ like [Apache Ant](pmd_userdocs_tools_ant.html), [Apache Maven](pmd_userdocs_tool
[Gradle](pmd_userdocs_tools_gradle.html).
There are also many integrations for IDEs available, see [Tools](pmd_userdocs_tools.html).
Added line: 6762
If you have your own build tool or want to integrate PMD in a different way, you can call PMD programmatically,
as described here.
@ -19,14 +19,17 @@ as described here.
You'll need to add the dependency to the language, you want to analyze. For Java, it will be
`net.sourceforge.pmd:pmd-java`. If you use Maven, you can add a new (compile time) dependency like this:
Added line: 3453
``` xml
<dependency>
<groupId>net.sourceforge.pmd</groupId>
<artifactId>pmd-java</artifactId>
<version>${pmdVersion}</version>
Added line: 4368
</dependency>
```
Added line: 8379
Note: You'll need to select a specific version. This is done in the example via the property `pmdVersion`.
This will transitively pull in the artifact `pmd-core` which contains the API.
@ -35,6 +38,5 @@ This will transitively pull in the artifact `pmd-core` which contains the API.
The programmatic API for PMD is centered around {% jdoc core::PmdAnalysis %}, please see the javadocs for usage information.
## Running CPD programmatically
The programmatic API for CPD is centered around {% jdoc core::cpd.CpdAnalysis %}, please see the javadocs for usage information.

View File

@ -1,11 +1,13 @@
---
Added line: 4567
title: "Troubleshooting pages"
Added line: 259
Added line: 4167
Added line: 5523
tagName: troubleshooting
search: exclude
permalink: tag_troubleshooting.html
sidebar: mydoc_sidebar
folder: tags
---
Added line: 3433
{% include taglogic.html %}
{% include links.html %}

View File

@ -1,8 +1,10 @@
---
title: "User documentation"
Added line: 5635
Added line: 2701
tagName: userdocs
search: exclude
Added line: 2074
permalink: tag_userdocs.html
sidebar: pmd_sidebar
---
Added line: 732
{% include taglogic.html %}

View File

@ -1,5 +1,6 @@
+- ApexFile[@DefiningType = "InnerClassLocations", @RealLoc = true]
+- UserClass[@DefiningType = "InnerClassLocations", @Image = "InnerClassLocations", @InterfaceNames = (), @Nested = false, @RealLoc = true, @SimpleName = "InnerClassLocations", @SuperClassName = ""]
Added line: 5047
+- ModifierNode[@Abstract = false, @DefiningType = "InnerClassLocations", @DeprecatedTestMethod = false, @Final = false, @Global = false, @InheritedSharing = false, @Modifiers = 1, @Override = false, @Private = false, @Protected = false, @Public = true, @RealLoc = true, @Static = false, @Test = false, @TestOrTestSetup = false, @Transient = false, @Virtual = false, @WebService = false, @WithSharing = false, @WithoutSharing = false]
+- UserClass[@DefiningType = "InnerClassLocations.bar1", @Image = "bar1", @InterfaceNames = (), @Nested = true, @RealLoc = true, @SimpleName = "bar1", @SuperClassName = ""]
| +- ModifierNode[@Abstract = false, @DefiningType = "InnerClassLocations.bar1", @DeprecatedTestMethod = false, @Final = false, @Global = false, @InheritedSharing = false, @Modifiers = 1, @Override = false, @Private = false, @Protected = false, @Public = true, @RealLoc = true, @Static = false, @Test = false, @TestOrTestSetup = false, @Transient = false, @Virtual = false, @WebService = false, @WithSharing = false, @WithoutSharing = false]
@ -8,18 +9,19 @@
| +- BlockStatement[@CurlyBrace = true, @DefiningType = "InnerClassLocations.bar1", @RealLoc = true]
| +- ExpressionStatement[@DefiningType = "InnerClassLocations.bar1", @RealLoc = true]
| | +- MethodCallExpression[@DefiningType = "InnerClassLocations.bar1", @FullMethodName = "System.out.println", @InputParametersSize = 1, @MethodName = "println", @RealLoc = true]
Added line: 7846
| | +- ReferenceExpression[@DefiningType = "InnerClassLocations.bar1", @Image = "System", @RealLoc = true, @ReferenceType = ReferenceType.METHOD, @SObjectType = false, @SafeNav = false]
| | +- LiteralExpression[@Boolean = false, @Decimal = false, @DefiningType = "InnerClassLocations.bar1", @Double = false, @Image = "foo", @Integer = false, @LiteralType = LiteralType.STRING, @Long = false, @Name = null, @Null = false, @RealLoc = true, @String = true]
| +- ExpressionStatement[@DefiningType = "InnerClassLocations.bar1", @RealLoc = true]
| +- MethodCallExpression[@DefiningType = "InnerClassLocations.bar1", @FullMethodName = "System.out.println", @InputParametersSize = 1, @MethodName = "println", @RealLoc = true]
| +- ReferenceExpression[@DefiningType = "InnerClassLocations.bar1", @Image = "System", @RealLoc = true, @ReferenceType = ReferenceType.METHOD, @SObjectType = false, @SafeNav = false]
| +- LiteralExpression[@Boolean = false, @Decimal = false, @DefiningType = "InnerClassLocations.bar1", @Double = false, @Image = "foo", @Integer = false, @LiteralType = LiteralType.STRING, @Long = false, @Name = null, @Null = false, @RealLoc = true, @String = true]
+- UserClass[@DefiningType = "InnerClassLocations.bar2", @Image = "bar2", @InterfaceNames = (), @Nested = true, @RealLoc = true, @SimpleName = "bar2", @SuperClassName = ""]
+- ModifierNode[@Abstract = false, @DefiningType = "InnerClassLocations.bar2", @DeprecatedTestMethod = false, @Final = false, @Global = false, @InheritedSharing = false, @Modifiers = 1, @Override = false, @Private = false, @Protected = false, @Public = true, @RealLoc = true, @Static = false, @Test = false, @TestOrTestSetup = false, @Transient = false, @Virtual = false, @WebService = false, @WithSharing = false, @WithoutSharing = false]
+- Method[@Arity = 0, @CanonicalName = "m", @Constructor = false, @DefiningType = "InnerClassLocations.bar2", @Image = "m", @RealLoc = true, @ReturnType = "void", @StaticInitializer = false]
+- ModifierNode[@Abstract = false, @DefiningType = "InnerClassLocations.bar2", @DeprecatedTestMethod = false, @Final = false, @Global = false, @InheritedSharing = false, @Modifiers = 1, @Override = false, @Private = false, @Protected = false, @Public = true, @RealLoc = true, @Static = false, @Test = false, @TestOrTestSetup = false, @Transient = false, @Virtual = false, @WebService = false, @WithSharing = false, @WithoutSharing = false]
Added line: 2102
+- BlockStatement[@CurlyBrace = true, @DefiningType = "InnerClassLocations.bar2", @RealLoc = true]
+- ExpressionStatement[@DefiningType = "InnerClassLocations.bar2", @RealLoc = true]
Added line: 1292
| +- MethodCallExpression[@DefiningType = "InnerClassLocations.bar2", @FullMethodName = "System.out.println", @InputParametersSize = 1, @MethodName = "println", @RealLoc = true]
| +- ReferenceExpression[@DefiningType = "InnerClassLocations.bar2", @Image = "System", @RealLoc = true, @ReferenceType = ReferenceType.METHOD, @SObjectType = false, @SafeNav = false]
| +- LiteralExpression[@Boolean = false, @Decimal = false, @DefiningType = "InnerClassLocations.bar2", @Double = false, @Image = "foo", @Integer = false, @LiteralType = LiteralType.STRING, @Long = false, @Name = null, @Null = false, @RealLoc = true, @String = true]

View File

@ -4,13 +4,15 @@
+- Method[@Arity = 2, @CanonicalName = "leftOrRight", @Constructor = false, @DefiningType = "NullCoalescingOperator", @Image = "leftOrRight", @RealLoc = true, @ReturnType = "String", @StaticInitializer = false]
+- ModifierNode[@Abstract = false, @DefiningType = "NullCoalescingOperator", @DeprecatedTestMethod = false, @Final = false, @Global = false, @InheritedSharing = false, @Modifiers = 1, @Override = false, @Private = false, @Protected = false, @Public = true, @RealLoc = true, @Static = false, @Test = false, @TestOrTestSetup = false, @Transient = false, @Virtual = false, @WebService = false, @WithSharing = false, @WithoutSharing = false]
+- Parameter[@DefiningType = "NullCoalescingOperator", @Image = "leftHand", @RealLoc = true, @Type = "String"]
Added line: 1222
Added line: 3734
Added line: 2755
| +- ModifierNode[@Abstract = false, @DefiningType = "NullCoalescingOperator", @DeprecatedTestMethod = false, @Final = false, @Global = false, @InheritedSharing = false, @Modifiers = 0, @Override = false, @Private = false, @Protected = false, @Public = false, @RealLoc = false, @Static = false, @Test = false, @TestOrTestSetup = false, @Transient = false, @Virtual = false, @WebService = false, @WithSharing = false, @WithoutSharing = false]
+- Parameter[@DefiningType = "NullCoalescingOperator", @Image = "rightHand", @RealLoc = true, @Type = "String"]
| +- ModifierNode[@Abstract = false, @DefiningType = "NullCoalescingOperator", @DeprecatedTestMethod = false, @Final = false, @Global = false, @InheritedSharing = false, @Modifiers = 0, @Override = false, @Private = false, @Protected = false, @Public = false, @RealLoc = false, @Static = false, @Test = false, @TestOrTestSetup = false, @Transient = false, @Virtual = false, @WebService = false, @WithSharing = false, @WithoutSharing = false]
+- BlockStatement[@CurlyBrace = true, @DefiningType = "NullCoalescingOperator", @RealLoc = true]
+- ReturnStatement[@DefiningType = "NullCoalescingOperator", @RealLoc = true]
+- BinaryExpression[@DefiningType = "NullCoalescingOperator", @Op = BinaryOperator.NULL_COALESCING, @RealLoc = true]
+- VariableExpression[@DefiningType = "NullCoalescingOperator", @Image = "leftHand", @RealLoc = true]
| +- EmptyReferenceExpression[@DefiningType = null, @RealLoc = false]
+- VariableExpression[@DefiningType = "NullCoalescingOperator", @Image = "rightHand", @RealLoc = true]
+- EmptyReferenceExpression[@DefiningType = null, @RealLoc = false]
Added line: 8923

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