Skip to content

Commit

Permalink
Merge branch 'master' into pr/4191
Browse files Browse the repository at this point in the history
  • Loading branch information
oowekyala committed Nov 16, 2022
2 parents dcbc48b + bdbeef6 commit 382dea5
Show file tree
Hide file tree
Showing 36 changed files with 909 additions and 244 deletions.
18 changes: 18 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -6988,6 +6988,24 @@
"contributions": [
"doc"
]
},
{
"login": "jvwilge",
"name": "Jeroen van Wilgenburg",
"avatar_url": "https://avatars.githubusercontent.com/u/251901?v=4",
"profile": "https://vanwilgenburg.wordpress.com/",
"contributions": [
"doc"
]
},
{
"login": "Eldrick19",
"name": "Eldrick Wega",
"avatar_url": "https://avatars.githubusercontent.com/u/26189114?v=4",
"profile": "https://github.com/Eldrick19",
"contributions": [
"doc"
]
}
],
"contributorsPerLine": 7,
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ It uses JavaCC and Antlr to parse source files into abstract syntax trees (AST)
Rules can be written in Java or using a XPath query.

It supports Java, JavaScript, Salesforce.com Apex and Visualforce,
Modelica, PLSQL, Apache Velocity, XML, XSL, Scala.
Modelica, PLSQL, Apache Velocity, XML, XSL.
Scala is supported, but there are currently no Scala rules available.

Additionally it includes **CPD**, the copy-paste-detector. CPD finds duplicated code in
C/C++, C#, Dart, Fortran, Go, Groovy, Java, JavaScript, JSP, Kotlin, Lua, Matlab, Modelica,
Expand Down
314 changes: 159 additions & 155 deletions docs/pages/pmd/projectdocs/credits.md

Large diffs are not rendered by default.

20 changes: 16 additions & 4 deletions docs/pages/pmd/userdocs/cli_reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ The tool comes with a rather extensive help text, simply running with `--help`!
the given language `<lang>`. Parsing errors are ignored and unparsable files
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
use xml as extension. See [example](#analyze-other-xml-formats) below.</p>"
%}
Expand All @@ -99,6 +101,16 @@ The tool comes with a rather extensive help text, simply running with `--help`!
{% include custom/cli_option_row.html options="--help,-h,-H"
description="Display help on usage."
%}
{% include custom/cli_option_row.html options="--use-version"
option_arg="lang-version"
description="The specific language version PMD should use when parsing source code for a given language.
<p>Values are in the format of *language-version*.</p>
<p>This option can be repeated to configure several languages for the same run.</p>
<p>Note that this option does not change how languages are assigned to files.
It only changes something if the project you analyze contains some files that PMD detects as the given language.
Language detection is only influenced by file extensions and the `--force-language` option.</p>
<p>See also [Supported Languages](#supported-languages).</p>"
%}
{% include custom/cli_option_row.html options="-language,-l"
option_arg="lang"
description="Specify the language PMD should use. Used together with `-version`. See also [Supported Languages](#supported-languages)."
Expand Down Expand Up @@ -184,16 +196,16 @@ This behavior has been introduced to ease PMD integration into scripts or hooks,

The language is determined automatically by PMD from the file extensions. Some languages such as "Java"
however support multiple versions. The default version will be used, which is usually the latest supported
version. If you want to use an older version, so that e.g. rules, that suggest usage of language features,
that are not available yet, won't be executed, you need to specify a specific version via the `-language`
and `-version` parameter.
non-preview version. If you want to use an older version, so that e.g. rules that suggest usage of language features
that are not available yet won't be executed, you need to specify a specific version via the `--use-version`
parameter.

These parameters are irrelevant for languages that don't support different versions.

Example:

``` shell
./run.sh pmd -d src/main/java -f text -R rulesets/java/quickstart.xml -language java -version 8
./run.sh pmd -d src/main/java -f text -R rulesets/java/quickstart.xml --use-version java-1.8
```

* [apex](pmd_rules_apex.html) (Salesforce Apex)
Expand Down
10 changes: 6 additions & 4 deletions docs/pages/pmd/userdocs/cpd/cpd.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Novice as much as advanced readers may want to [read on on Refactoring Guru](htt
description="The minimum token length which should be reported as a duplicate."
required="yes"
%}
{% include custom/cli_option_row.html options="--files"
{% include custom/cli_option_row.html options="--files,--dir,-d"
description="List of files and directories to process"
required="yes"
%}
Expand All @@ -73,10 +73,10 @@ Novice as much as advanced readers may want to [read on on Refactoring Guru](htt
description="Sources code language."
default="java"
%}
{% include custom/cli_option_row.html options="--debug,--verbose"
{% include custom/cli_option_row.html options="--debug,--verbose,-v,-D"
description="Debug mode. Prints more log output."
%}
{% include custom/cli_option_row.html options="--encoding"
{% include custom/cli_option_row.html options="--encoding,-e"
description="Character encoding to use when processing files. If not specified, CPD uses the system default encoding."
%}
{% include custom/cli_option_row.html options="--skip-duplicate-files"
Expand Down Expand Up @@ -220,8 +220,10 @@ This behavior has been introduced to ease CPD integration into scripts or hooks,
* Dart
* EcmaScript (JavaScript)
* Fortran
* Gherkin (Cucumber)
* Go
* Groovy
* Html
* Java
* Jsp
* Kotlin
Expand Down Expand Up @@ -368,7 +370,7 @@ For Windows:

For Linux:

./run.sh cpdgui
./run.sh cpd-gui

Here's a screenshot of CPD after running on the JDK 8 java.lang package:

Expand Down
2 changes: 1 addition & 1 deletion docs/pages/pmd/userdocs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ sidebar: pmd_sidebar
* For Windows: [Winzip](http://winzip.com) or the free [7-zip](http://www.7-zip.org/)
* For Linux / Unix: [InfoZip](http://infozip.sourceforge.net/)

{% include note.html content="For executing the Designer (./run.sh designer) using [OpenJDK](http://jdk.java.net) or Java 11, you need additionally [OpenJFX](https://openjfx.io/). Download it, extract it and set the environment variable JAVAFX_HOME." %}
{% include note.html content="For executing the Designer (./run.sh designer) using [OpenJDK](http://jdk.java.net) or Java 11, you need additionally [JavaFX](https://gluonhq.com/products/javafx/). Download it, extract it and set the environment variable JAVAFX_HOME pointing at that directory." %}


### Installation
Expand Down
62 changes: 62 additions & 0 deletions docs/pages/release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,76 @@ This is a {{ site.pmd.release_type }} release.

### New and noteworthy

#### Modified rules

* The rule {% rule java/codestyle/ClassNamingConventions %} has a new property `testClassPattern`, which is applied
to test classes. By default, test classes should end with the suffix "Test". Test classes are top-level classes, that
either inherit from JUnit 3 TestCase or have at least one method annotated with the Test annotations from
JUnit4/5 or TestNG.

### Fixed Issues
* java
* [#3643](https://github.com/pmd/pmd/issues/3643): \[java] More parser edge cases
* [#4152](https://github.com/pmd/pmd/issues/4152): \[java] Parse error on array type annotations
* java-codestyle
* [#2867](https://github.com/pmd/pmd/issues/2867): \[java] Separate pattern for test classes in ClassNamingConventions rule for Java
* [#4201](https://github.com/pmd/pmd/issues/4201): \[java] CommentDefaultAccessModifier should consider lombok's @<!-- -->Value
* java-design
* [#4200](https://github.com/pmd/pmd/issues/4200): \[java] ClassWithOnlyPrivateConstructorsShouldBeFinal should consider lombok's @<!-- -->Value
* java-errorprone
* [#4185](https://github.com/pmd/pmd/issues/4185): \[java] InvalidLogMessageFormat rule produces a NPE

### API Changes

#### PMD CLI

* PMD now supports a new `--use-version` flag, which receives a language-version pair (such as `java-8` or `apex-54`).
This supersedes the usage of `-language` / `-l` and `-version` / `-v`, allowing for multiple versions to be set in a single run.
PMD 7 will completely remove support for `-language` and `-version` in favor of this new flag.

* Support for `-V` is being deprecated in favor of `--verbose` in preparation for PMD 7.
In PMD 7, `-v` will enable verbose mode and `-V` will show the PMD version for consistency with most Unix/Linux tools.

* Support for `-min` is being deprecated in favor of `--minimum-priority` for consistency with most Unix/Linux tools, where `-min` would be equivalent to `-m -i -n`.

#### CPD CLI

* CPD now supports using `-d` or `--dir` as an alias to `--files`, in favor of consistency with PMD.
PMD 7 will remove support for `--files` in favor of these new flags.

#### Linux run.sh parameters

* Using `run.sh cpdgui` will now warn about it being deprecated. Use `run.sh cpd-gui` instead.

* The old designer (`run.sh designerold`) is completely deprecated and will be removed in PMD 7. Switch to the new JavaFX designer: `run.sh designer`.

* The old visual AST viewer (`run.sh bgastviewer`) is completely deprecated and will be removed in PMD 7. Switch to the new JavaFX designer: `run.sh designer` for a visual tool, or use `run.sh ast-dump` for a text-based aleternative.

#### Deprecated API

The following APIs have been marked as deprecated for removal in PMD 7:

- {% jdoc core::PMD %} and {% jdoc core::PMD.StatusCode %} - PMD 7 will ship with a revamped CLI split from pmd-core. To programatically launch analysis you can use {% jdoc core::PmdAnalysis %}.
- {% jdoc !!core::PMDConfiguration#getAllInputPaths() %} - It is now superceded by {% jdoc !!core::PMDConfiguration#getInputPathList() %}
- {% jdoc !!core::PMDConfiguration#setInputPaths(List) %} - It is now superceded by {% jdoc !!core::PMDConfiguration#setInputPathList(List) %}
- {% jdoc !!core::PMDConfiguration#addInputPath(String) %} - It is now superceded by {% jdoc !!core::PMDConfiguration#addInputPath(Path) %}
- {% jdoc !!core::PMDConfiguration#getInputFilePath() %} - It is now superceded by {% jdoc !!core::PMDConfiguration#getInputFile() %}
- {% jdoc !!core::PMDConfiguration#getIgnoreFilePath() %} - It is now superceded by {% jdoc !!core::PMDConfiguration#getIgnoreFile() %}
- {% jdoc !!core::PMDConfiguration#setInputFilePath(String) %} - It is now superceded by {% jdoc !!core::PMDConfiguration#setInputFilePath(Path) %}
- {% jdoc !!core::PMDConfiguration#setIgnoreFilePath(String) %} - It is now superceded by {% jdoc !!core::PMDConfiguration#setIgnoreFilePath(Path) %}
- {% jdoc !!core::PMDConfiguration#getInputUri() %} - It is now superceded by {% jdoc !!core::PMDConfiguration#getUri() %}
- {% jdoc !!core::PMDConfiguration#setInputUri(String) %} - It is now superceded by {% jdoc !!core::PMDConfiguration#setInputUri(URI) %}
- {% jdoc !!core::PMDConfiguration#getReportFile() %} - It is now superceded by {% jdoc !!core::PMDConfiguration#getReportFilePath() %}
- {% jdoc !!core::PMDConfiguration#setReportFile(String) %} - It is now superceded by {% jdoc !!core::PMDConfiguration#setReportFile(Path) %}
- {% jdoc !!core::PMDConfiguration#isStressTest() %} and {% jdoc !!core::PMDConfiguration#setStressTest(boolean) %} - Will be removed with no replacement.
- {% jdoc !!core::PMDConfiguration#isBenchmark() %} and {% jdoc !!core::PMDConfiguration#setBenchmark(boolean) %} - Will be removed with no replacement, the CLI will still support it.
- {% jdoc core::cpd.CPD %} and {% jdoc core::cpd.CPD.StatusCode %} - PMD 7 will ship with a revamped CLI split from pmd-core. An alterative to programatically launch CPD analysis will be added in due time.

### External Contributions
* [#4184](https://github.com/pmd/pmd/pull/4184): \[java]\[doc] TestClassWithoutTestCases - fix small typo in description - [Valery Yatsynovich](https://github.com/valfirst) (@valfirst)
* [#4198](https://github.com/pmd/pmd/pull/4198): \[doc] Add supported CPD languages - [Jeroen van Wilgenburg](https://github.com/jvwilge) (@jvwilge)
* [#4202](https://github.com/pmd/pmd/pull/4202): \[java] Fix #4200 and #4201: ClassWithOnlyPrivateConstructorsShouldBeFinal, CommentDefaultAccessModifier: Exclude lombok @<!-- -->Value annotation - [Lynn](https://github.com/LynnBroe) (@LynnBroe)
* [#4205](https://github.com/pmd/pmd/pull/4205): \[doc] Clarify Scala support (no built-in rules) - [Eldrick Wega](https://github.com/Eldrick19) (@Eldrick19)

{% endtocmaker %}

5 changes: 5 additions & 0 deletions pmd-core/src/main/java/net/sourceforge/pmd/PMD.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@
*
* <p><strong>Warning:</strong> This class is not intended to be instantiated or subclassed. It will
* be made final in PMD7.
*
* @deprecated This class is to be removed in PMD 7 in favor of a unified PmdCli entry point. {@link PmdAnalysis} should be used for non-CLI use-cases.
*/
@Deprecated
public class PMD {


Expand Down Expand Up @@ -539,7 +542,9 @@ public static StatusCode runPmd(PMDConfiguration configuration) {
* Represents status codes that are used as exit codes during CLI runs.
*
* @see #runPmd(String[])
* @deprecated This class is to be removed in PMD 7 in favor of a unified PmdCli entry point.
*/
@Deprecated
public enum StatusCode {
/** No errors, no violations. This is exit code {@code 0}. */
OK(0),
Expand Down

0 comments on commit 382dea5

Please sign in to comment.