From ae9dec9c5ee80d8ca85a683724e523fae75dda43 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Thu, 13 Feb 2020 18:40:25 +0100 Subject: [PATCH 1/6] [doc] Add github issue templates Refs #2249 --- .../bug_report.md} | 25 ++++++++++++++-- .github/ISSUE_TEMPLATE/config.yml | 8 +++++ .github/ISSUE_TEMPLATE/feature_request.md | 20 +++++++++++++ .github/ISSUE_TEMPLATE/new_rule.md | 27 +++++++++++++++++ .github/ISSUE_TEMPLATE/question.md | 14 +++++++++ .github/ISSUE_TEMPLATE/rule_violation.md | 29 +++++++++++++++++++ 6 files changed, 120 insertions(+), 3 deletions(-) rename .github/{ISSUE_TEMPLATE.md => ISSUE_TEMPLATE/bug_report.md} (54%) create mode 100644 .github/ISSUE_TEMPLATE/config.yml create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md create mode 100644 .github/ISSUE_TEMPLATE/new_rule.md create mode 100644 .github/ISSUE_TEMPLATE/question.md create mode 100644 .github/ISSUE_TEMPLATE/rule_violation.md diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE/bug_report.md similarity index 54% rename from .github/ISSUE_TEMPLATE.md rename to .github/ISSUE_TEMPLATE/bug_report.md index f71366f7bf..f667e0584b 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -1,20 +1,39 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: bug +assignees: '' + +--- - - **Affects PMD Version:** -**Rule:** +Make sure, to test with the latest PMD version. **Description:** +A clear and concise description of what the bug is. + +**Exception Stacktrace:** + +``` +# Copy-paste the stack trace here +``` + **Code Sample demonstrating the issue:** ``` ``` +**Steps to reproduce:** + +1. Compile the project: `mvn verify` +2. Run PMD: `run.sh pmd -d src -f xml -R ruleset.xml` + **Running PMD through:** *[CLI | Ant | Maven | Gradle | Designer | Other]* diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000000..56a5a13ccb --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,8 @@ +blank_issues_enabled: false +contact_links: + - name: PMD Designer Issues + url: https://github.com/pmd/pmd-designer/issues + about: Issues about the rule designer + - name: PMD Eclipse Plugin Issues + url: https://github.com/pmd/pmd-eclipse-plugin/issues + about: Issues about the PMD Eclipse Plugin diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000000..5efb987e38 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,20 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: enhancement +assignees: '' + +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context about the feature request here. diff --git a/.github/ISSUE_TEMPLATE/new_rule.md b/.github/ISSUE_TEMPLATE/new_rule.md new file mode 100644 index 0000000000..ec48bd982c --- /dev/null +++ b/.github/ISSUE_TEMPLATE/new_rule.md @@ -0,0 +1,27 @@ +--- +name: New Rule +about: You have an idea for a new rule? Great! +title: '' +labels: new-rule +assignees: '' + +--- + + +**Proposed Rule Name:** + +**Proposed Category:** One of [Best Practices | Code Style | Design | Documentation | Error Prone | Multithreading | Performance | Security] + +**Description:** + +**Code Sample:** This should include code, that should be flagged by the rule. If possible, the "correct" code +according to this new rule should also be demonstrated. + +``` + +``` + +**Possible Properties:** + +* Should this rule be customizable via properties? + diff --git a/.github/ISSUE_TEMPLATE/question.md b/.github/ISSUE_TEMPLATE/question.md new file mode 100644 index 0000000000..9389f8c3ba --- /dev/null +++ b/.github/ISSUE_TEMPLATE/question.md @@ -0,0 +1,14 @@ +--- +name: Question +about: Feel free to ask any question about PMD and its usage +title: '' +labels: question +assignees: '' + +--- + + + +**Description:** + diff --git a/.github/ISSUE_TEMPLATE/rule_violation.md b/.github/ISSUE_TEMPLATE/rule_violation.md new file mode 100644 index 0000000000..3a13db905b --- /dev/null +++ b/.github/ISSUE_TEMPLATE/rule_violation.md @@ -0,0 +1,29 @@ +--- +name: Rule violation +about: Let us know about a false positive/false negative +title: '' +labels: bug +assignees: '' + +--- + + +**Affects PMD Version:** + +**Rule:** + +**Description:** + +**Code Sample demonstrating the issue:** + +``` + +``` + +**Expected outcome:** + +* Does PMD report a violation, where there shouldn't be one? -> false-positive +* Is PMD missing to report a violation, where there should be one? -> false-negative + + +**Running PMD through:** *[CLI | Ant | Maven | Gradle | Designer | Other]* From 9cec4c3ac716c9feb3c25720cba5500e400f9b5d Mon Sep 17 00:00:00 2001 From: Pham Hai Trung Date: Thu, 27 Feb 2020 09:38:43 +0100 Subject: [PATCH 2/6] Add version to plugin The maven configuration will generate an issue if we don't specify the maven-pmd-plugin's version. Without the version, maven wouldn't be able to find the pmd plugin in central. --- docs/pages/pmd/userdocs/tools/maven.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/pages/pmd/userdocs/tools/maven.md b/docs/pages/pmd/userdocs/tools/maven.md index 2d07e1a07c..267c0fc429 100644 --- a/docs/pages/pmd/userdocs/tools/maven.md +++ b/docs/pages/pmd/userdocs/tools/maven.md @@ -58,6 +58,7 @@ PMD finds some violations. Therefore the `check` goal is used: org.apache.maven.plugins maven-pmd-plugin + 3.8 true true From 843f473252031ee9ccce6f999c36f34a533fab50 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Sat, 21 Mar 2020 11:27:40 +0100 Subject: [PATCH 3/6] Fix formatting --- docs/pages/pmd/projectdocs/trivia/news.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/pages/pmd/projectdocs/trivia/news.md b/docs/pages/pmd/projectdocs/trivia/news.md index 2729f89bcb..52f114c4af 100644 --- a/docs/pages/pmd/projectdocs/trivia/news.md +++ b/docs/pages/pmd/projectdocs/trivia/news.md @@ -11,7 +11,7 @@ author: Tom Copeland * March 2020 - [Helping Salesforce developers create readable and maintainable Apex code](https://gearset.com/blog/helping-sf-developers-create-readable-and-maintainable-apex-code) -* July 2019 - [Apex PMD | Static code analysis - Apex Hours](https://youtu.be/34PxAHtAavU) +* July 2019 - [Apex PMD \| Static code analysis - Apex Hours](https://youtu.be/34PxAHtAavU) * June 2019 - [Pluralsight](https://www.pluralsight.com/authors/don-robins) Course about leveraging PMD usage for Salesforce by [Robert Sösemann](https://github.com/rsoesemann) (Apex Language Module Contributor) [Play by Play: Automated Code Analysis in Salesforce - a Tools Deep-Dive](https://www.pluralsight.com/courses/play-by-play-automated-code-analysis-in-salesforce) From 40d7d27665659bf12b9aece15cd66b8da6cb76e1 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Sat, 21 Mar 2020 11:44:22 +0100 Subject: [PATCH 4/6] [doc] Update issue template for bug reports and rule violations --- .github/ISSUE_TEMPLATE/bug_report.md | 6 ++++-- .github/ISSUE_TEMPLATE/rule_violation.md | 3 +++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index f667e0584b..0bd4d2f99f 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -31,8 +31,10 @@ A clear and concise description of what the bug is. **Steps to reproduce:** -1. Compile the project: `mvn verify` -2. Run PMD: `run.sh pmd -d src -f xml -R ruleset.xml` +Please provide detailed steps for how we can reproduce the bug. + +1. ... (e.g. if you're using maven: `mvn clean verify`) +2. ... **Running PMD through:** *[CLI | Ant | Maven | Gradle | Designer | Other]* diff --git a/.github/ISSUE_TEMPLATE/rule_violation.md b/.github/ISSUE_TEMPLATE/rule_violation.md index 3a13db905b..92404bd43b 100644 --- a/.github/ISSUE_TEMPLATE/rule_violation.md +++ b/.github/ISSUE_TEMPLATE/rule_violation.md @@ -12,6 +12,9 @@ assignees: '' **Rule:** +Please provide the rule name and a link to the rule documentation: + + **Description:** **Code Sample demonstrating the issue:** From 4f392c9d255950187eb5022fd80f8a44fe2645d4 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Sat, 21 Mar 2020 12:12:24 +0100 Subject: [PATCH 5/6] [doc] maven - add "Choosing the plugin version" --- docs/pages/pmd/userdocs/tools/maven.md | 57 +++++++++++++++++++++++--- 1 file changed, 51 insertions(+), 6 deletions(-) diff --git a/docs/pages/pmd/userdocs/tools/maven.md b/docs/pages/pmd/userdocs/tools/maven.md index 267c0fc429..0a1d45691b 100644 --- a/docs/pages/pmd/userdocs/tools/maven.md +++ b/docs/pages/pmd/userdocs/tools/maven.md @@ -2,7 +2,8 @@ title: Maven PMD Plugin tags: [userdocs, tools] permalink: pmd_userdocs_tools_maven.html -last_updated: August 2017 +last_updated: March 2020 +mpmd_version: 3.13.0 author: > Miguel Griffa , Romain PELISSE , @@ -13,6 +14,36 @@ author: > ### Running the pmd plugin +#### Choosing the plugin version + +When adding the maven-pmd-plugin to your pom.xml, you need to select a version. To figure out the +latest available version, have a look at the official [maven-pmd-plugin documentation](https://maven.apache.org/plugins/maven-pmd-plugin/). + +As of {{ page.last_updated }}, the current plugin version is **{{ page.mpmd_version }}**. + +The version of the plugin should be specified in `` and if using the project +report additionally in `` elements. Here's an example for the pluginManagement +section: + +```xml + + + + + org.apache.maven.plugins + maven-pmd-plugin + {{ page.mpmd_version }} + + + + +``` + +When defining the version in the pluginManagment section, then it doesn't need to be specified in the normal plugins +section. However, it should additionally be specified in the reporting section. + +More information, see [Guide to Configuring Plugin-ins](https://maven.apache.org/guides/mini/guide-configuring-plugins.html). + #### Generating a project report To include the PMD report in the project reports section add the following lines under @@ -26,6 +57,7 @@ the reports element in your pom.xml: org.apache.maven.plugins maven-pmd-plugin + {{ page.mpmd_version }} @@ -58,9 +90,11 @@ PMD finds some violations. Therefore the `check` goal is used: org.apache.maven.plugins maven-pmd-plugin - 3.8 + {{ page.mpmd_version }} - true + + true + true @@ -88,11 +122,13 @@ you add `cpd-check` as a goal. To specify a ruleset, simply edit the previous configuration: +``` xml org.apache.maven.plugins maven-pmd-plugin + {{ page.mpmd_version }} /rulesets/java/braces.xml @@ -104,6 +140,7 @@ To specify a ruleset, simply edit the previous configuration: +``` The value of the 'ruleset' element can either be a relative address, an absolute address or even an url. @@ -119,23 +156,30 @@ will be able to resolve those other ruleset references. When using the Maven PMD plugin 3.8 or later along with PMD 5.6.0 or later, you can enable incremental analysis to speed up PMD's execution while retaining the quality of the analysis. You can additionally customize where the cache is stored:: +```xml org.apache.maven.plugins maven-pmd-plugin + {{ page.mpmd_version }} - true - ${project.build.directory}/pmd/pmd.cache + + true + + ${project.build.directory}/pmd/pmd.cache +``` #### Other configurations The Maven PMD plugin allows you to configure CPD, targetJDK, and the use of XRef to link the report to html source files, and the file encoding: +```xml org.apache.maven.plugins maven-pmd-plugin + {{ page.mpmd_version }} true ISO-8859-1 @@ -143,6 +187,7 @@ the report to html source files, and the file encoding: 1.4 +``` #### Upgrading the PMD version at runtime @@ -164,7 +209,7 @@ Maven plugin will use and benefit from the latest bugfixes and enhancements: org.apache.maven.plugins maven-pmd-plugin - 3.8 + {{ page.mpmd_version }} net.sourceforge.pmd From ce07c9b7570c5b683154944173be8ed44e68e854 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Sat, 21 Mar 2020 12:13:23 +0100 Subject: [PATCH 6/6] [doc] Update release notes, refs #2314 --- docs/pages/release_notes.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index a6b5973f9e..055c82fa00 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -135,6 +135,7 @@ methods on {% jdoc apex::lang.apex.ast.ApexParserVisitor %} and its implementati * [#2278](https://github.com/pmd/pmd/pull/2278): \[java] fix UnusedImports rule for ambiguous static on-demand imports - [Kris Scheibe](https://github.com/kris-scheibe) * [#2279](https://github.com/pmd/pmd/pull/2279): \[apex] Add support for suppressing violations using the // NOPMD comment - [Gwilym Kuiper](https://github.com/gwilymatgearset) * [#2297](https://github.com/pmd/pmd/pull/2297): \[apex] Cognitive complexity metrics - [Gwilym Kuiper](https://github.com/gwilymatgearset) +* [#2314](https://github.com/pmd/pmd/pull/2314): \[doc] maven integration - Add version to plugin - [Pham Hai Trung](https://github.com/gpbp) {% endtocmaker %}