You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ad...@apache.org on 2023/01/17 18:33:16 UTC

[maven-pmd-plugin] branch pmd7 updated (0266383 -> 6eb1886)

This is an automated email from the ASF dual-hosted git repository.

adangel pushed a change to branch pmd7
in repository https://gitbox.apache.org/repos/asf/maven-pmd-plugin.git


 discard 0266383  Fix deprecate rule reference
 discard 8a2aa0c  Add separate testcase to detect deprecated rules
 discard e0ecdc6  Fix integration test MPMD-243-excludeFromFailureFile
 discard 36db393  Improve logging integration
 discard 264d738  Fix integration tests
 discard be6b013  Upgrade to PMD 7
     add 66aa083  Bump animal-sniffer-maven-plugin from 1.16 to 1.21
     add cc79513  Bump plexus-resources from 1.1.0 to 1.2.0
     add 94b6da1  Bump commons-lang3 from 3.8.1 to 3.12.0
     add b97b2a4  [MPMD-345] - Upgrade to PMD 6.47.0
     add 2404708  [SECURITY] Fix Partial Path Traversal Vulnerability
     add 5a0ae88  Bump maven-plugins from 36 to 37
     add 10d345c  [MPMD-347] - Upgrade to PMD 6.48.0
     add 2ecd578  [MPMD-348] - Support Java 19
     add 1740f00  (doc) Update releasenotes.md
     add 2b7d2d7  [MPMD-349] Upgrade Maven Reporting API to 3.1.1/Maven Reporting Impl to 3.2.0
     add a28c27d  [MPMD-350] Upgrade Maven Shared Utils to 3.3.4
     add b62992f  [MPMD-351] Upgrade Maven Artifact Transfer to 0.13.1
     add 614f1a9  [MPMD-352] Upgrade Maven Common Artifact Filters to 3.3.1
     add 23f5f39  [maven-release-plugin] prepare release maven-pmd-plugin-3.18.0
     add 37c12f6  [maven-release-plugin] prepare for next development iteration
     add b55fb9a  (doc) Update releasenotes.md
     add 584ac6d  Bump release-drafter/release-drafter from 5.20.0 to 5.20.1 (#86)
     add 1d7a2fb  Set next dev version to 3.19.0-SNAPSHOT
     add 7b4c330  [MPMD-353] - API incompatibility with jansi after upgrading m-shared-utils (#91)
     add ebd3579  [MPMD-354] - Upgrade to PMD 6.49.0 (#92)
     add 68b7ed9  Bump wiremock from 1.49 to 2.27.2 (#57)
     add e8b49f4  Bump animal-sniffer-maven-plugin from 1.21 to 1.22 (#88)
     add d9be919  (doc) Update releasenotes.md
     add 0781fc8  (doc) Update release notes [skip ci]
     add 7033e9d  [maven-release-plugin] prepare release maven-pmd-plugin-3.19.0
     add 5634604  [maven-release-plugin] prepare for next development iteration
     add e947369  Bump release-drafter/release-drafter from 5.20.1 to 5.21.0 (#93)
     add 2ca4c8f  Bump maven-common-artifact-filters from 3.3.1 to 3.3.2 (#95)
     add 1d1116e  [MPMD-356] - Upgrade to PMD 6.50.0 (#98)
     add 8db6bb5  Bump release-drafter/release-drafter from 5.21.0 to 5.21.1 (#99)
     add 7b6623b  [MPMD-357] - Upgrade to PMD 6.51.0 (#100)
     add 92434d0  add Reproducible Builds badge
     add cd954cc  [MPMD-335] - Aggregate mode doesn't use additional repositories
     add 255a35a  (doc) Update releasenotes.md
     add 1dcc7c1  Set next development version to 3.20.0-SNAPSHOT
     add 6ee27fc  [MPMD-358] - Upgrade to PMD 6.52.0 (#104)
     add 3c7a47e  Remove method available from super class
     add b65c7a6  [MPMD-360] - Upgrade to PMD 6.53.0 (#109)
     add f3e188a  [MPMD-361] Explicitly start and end tables with Doxia Sinks in report renderers
     add 55c4d40  [maven-release-plugin] prepare release maven-pmd-plugin-3.20.0
     add e6f88da  [maven-release-plugin] prepare for next development iteration
     add 806c49d  (doc) Update releasenotes.md [skip ci]
     new 98539a1  Upgrade to PMD 7
     new 815723c  Fix integration tests
     new f7e7c78  Improve logging integration
     new 7f96dcf  Fix integration test MPMD-243-excludeFromFailureFile
     new a8db485  Add separate testcase to detect deprecated rules
     new e142d5b  Fix deprecate rule reference
     new 3119228  Fix compile errors and test failures
     new 6eb1886  Fix integration tests

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (0266383)
            \
             N -- N -- N   refs/heads/pmd7 (6eb1886)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 8 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .github/workflows/release-drafter.yml              |   2 +-
 README.md                                          |   1 +
 pom.xml                                            |  76 ++++--
 src/it/MPMD-128-xref-link/pom.xml                  |   2 +-
 src/it/MPMD-172/pom.xml                            |   2 +-
 src/it/MPMD-219-pmd-processing-error/verify.groovy |   3 +-
 src/it/MPMD-244-logging/verify.groovy              |   6 +-
 src/it/MPMD-253-xref-link-multi-module/pom.xml     |   2 +-
 src/it/MPMD-268-deprecated-rules/verify.groovy     |   2 +-
 src/it/MPMD-270-325-JDK11/pom.xml                  |   1 -
 src/it/MPMD-280-JDK12/pom.xml                      |   1 -
 src/it/MPMD-289-format-html-check/pom.xml          |   5 +-
 src/it/MPMD-295-JDK13/pom.xml                      |   1 -
 src/it/MPMD-302-JDK14/pom.xml                      |   1 -
 src/it/MPMD-302-JDK15/pom.xml                      |   1 -
 src/it/MPMD-304-toolchain-support/pom.xml          |   1 -
 src/it/MPMD-312-JDK16/pom.xml                      |   1 -
 src/it/MPMD-312-JDK17/pom.xml                      |   1 -
 src/it/MPMD-332-JDK18/pom.xml                      |   1 -
 .../invoker.properties}                            |   2 +-
 .../mpmd335-module1}/pom.xml                       |  32 +--
 .../src/main/java/org/example/Foo.java}            |   5 +-
 .../pom.xml                                        |  36 +--
 .../mpmd335-dependency1-1.0.0-SNAPSHOT.pom}        |  19 +-
 .../verify.groovy                                  |   7 +-
 .../invoker.properties                             |  11 +-
 .../pom.xml                                        |  20 +-
 .../src/main/java/com/mycompany/app/App.java       |   0
 .../src/main/java/com/mycompany/app/Foo.java       |   0
 .../verify.groovy                                  |   0
 src/it/empty-rulesets/pom.xml                      |   1 -
 src/it/mpmd-168-empty-report/pom.xml               |   7 +-
 src/it/mpmd-168/pom.xml                            |   7 +-
 .../maven/plugins/pmd/AbstractPmdReport.java       |  82 +-----
 .../org/apache/maven/plugins/pmd/CpdReport.java    |  60 +----
 .../maven/plugins/pmd/CpdReportGenerator.java      |   2 +
 .../maven/plugins/pmd/PmdCollectingRenderer.java   |   6 +-
 .../org/apache/maven/plugins/pmd/PmdReport.java    |  54 +---
 .../maven/plugins/pmd/PmdReportGenerator.java      |   6 +
 .../apache/maven/plugins/pmd/exec/CpdExecutor.java |   2 +-
 .../apache/maven/plugins/pmd/exec/CpdRequest.java  |  11 -
 .../apache/maven/plugins/pmd/exec/Executor.java    |   4 +-
 .../apache/maven/plugins/pmd/exec/PmdExecutor.java |   2 +-
 .../apache/maven/plugins/pmd/exec/PmdRequest.java  |  11 -
 .../apt/examples/upgrading-PMD-at-runtime.apt.vm   |   6 +
 src/site/apt/usage.apt.vm                          |   4 +-
 src/site/markdown/releasenotes.md                  |  84 ++++++
 .../maven/plugins/pmd/AbstractPmdReportTest.java   | 113 --------
 .../plugins/pmd/AbstractPmdReportTestCase.java     | 168 ++++++++++++
 .../apache/maven/plugins/pmd/CpdReportTest.java    | 147 ++++-------
 .../plugins/pmd/CpdViolationCheckMojoTest.java     |  26 +-
 .../plugins/pmd/DependencyArtifactStubFactory.java |  69 +++++
 .../apache/maven/plugins/pmd/PmdReportTest.java    | 289 +++++++--------------
 .../plugins/pmd/PmdViolationCheckMojoTest.java     |  40 +--
 .../stubs/CustomConfigurationMavenProjectStub.java |   3 +-
 .../DefaultConfigurationMavenProjectStub.java      |   3 +-
 .../pmd/stubs/InvalidFormatMavenProjectStub.java   |   3 +-
 ...rtifactHandlerStub.java => PmdProjectStub.java} |  35 +--
 .../cpd-custom-configuration-plugin-config.xml     |   3 +-
 .../cpd-txt-format-configuration-plugin-config.xml |   4 +-
 .../custom-configuration-plugin-config.xml         |   6 +-
 .../custom-configuration/skip-plugin-config.xml    |   4 +-
 .../cpd-default-configuration-plugin-config.xml    |   4 +-
 .../cpd-encoding-configuration-plugin-config.xml   |   4 +-
 .../cpd-javascript-plugin-config.xml               |   4 +-
 .../cpd-jsp-plugin-config.xml                      |   4 +-
 ...-cpd-exclusions-configuration-plugin-config.xml |   4 +-
 ...pd-report-include-xml-in-site-plugin-config.xml |   4 +-
 .../default-configuration-plugin-config.xml        |   4 +-
 .../javascript-configuration-plugin-config.xml     |   3 +-
 .../jsp-configuration-plugin-config.xml            |   3 +-
 .../pmd-report-custom-rules.xml                    |   3 +-
 ...md-report-include-xml-in-site-plugin-config.xml |   4 +-
 ...pmd-report-no-render-violations-by-priority.xml |   4 +-
 ...port-not-render-rule-priority-plugin-config.xml |   5 +-
 ...-pmd-exclusions-configuration-plugin-config.xml |   4 +-
 .../pmd-report-resolve-rulesets.xml                |   3 +-
 .../pmd-with-analysis-cache-plugin-config.xml      |   4 +-
 ...with-suppressMarker-no-render-plugin-config.xml |   5 +-
 .../pmd-with-suppressMarker-plugin-config.xml      |   5 +-
 .../cpd-empty-report-plugin-config.xml             |   3 +-
 .../cpd-skip-empty-report-plugin-config.xml        |   2 +-
 .../empty-report/empty-report-plugin-config.xml    |   3 +-
 .../skip-empty-report-plugin-config.xml            |   2 +-
 .../pmd-exclude-roots-plugin-config.xml            |   5 +-
 .../invalid-format-plugin-config.xml               |   2 +-
 .../invalid-target-jdk-plugin-config.xml           |   3 +-
 ...md-processing-error-no-report-plugin-config.xml |   3 +-
 .../pmd-processing-error-plugin-config.xml         |   2 +-
 .../pmd-processing-error-skip-plugin-config.xml    |   3 +-
 90 files changed, 748 insertions(+), 855 deletions(-)
 copy src/it/{MPMD-172/src/main/resources/my.properties => MPMD-335-aggregate-classpath-repositories/invoker.properties} (97%)
 copy src/it/{MPMD-259-analysis-cache-auxclasspath/missing-compile => MPMD-335-aggregate-classpath-repositories/mpmd335-module1}/pom.xml (65%)
 copy src/it/{MPMD-187/src/main/java/App.java => MPMD-335-aggregate-classpath-repositories/mpmd335-module1/src/main/java/org/example/Foo.java} (95%)
 copy src/it/{MPMD-323-ruleset-basedir-jgitver => MPMD-335-aggregate-classpath-repositories}/pom.xml (63%)
 copy src/it/{mpmd-138/mod-2/pom.xml => MPMD-335-aggregate-classpath-repositories/private-repo/org/apache/maven/plugins/pmd/it/mpmd335-dependency1/1.0.0-SNAPSHOT/mpmd335-dependency1-1.0.0-SNAPSHOT.pom} (78%)
 copy src/it/{MPMD-163 => MPMD-335-aggregate-classpath-repositories}/verify.groovy (73%)
 copy src/it/{MPMD-304-toolchain-support => MPMD-348-JDK19}/invoker.properties (76%)
 copy src/it/{MPMD-304-toolchain-support => MPMD-348-JDK19}/pom.xml (86%)
 copy src/it/{MPMD-270-325-JDK11 => MPMD-348-JDK19}/src/main/java/com/mycompany/app/App.java (100%)
 copy src/it/{MPMD-270-325-JDK11 => MPMD-348-JDK19}/src/main/java/com/mycompany/app/Foo.java (100%)
 copy src/it/{MPMD-270-325-JDK11 => MPMD-348-JDK19}/verify.groovy (100%)
 delete mode 100644 src/test/java/org/apache/maven/plugins/pmd/AbstractPmdReportTest.java
 create mode 100644 src/test/java/org/apache/maven/plugins/pmd/AbstractPmdReportTestCase.java
 create mode 100644 src/test/java/org/apache/maven/plugins/pmd/DependencyArtifactStubFactory.java
 copy src/test/java/org/apache/maven/plugins/pmd/stubs/{DefaultArtifactHandlerStub.java => PmdProjectStub.java} (50%)


[maven-pmd-plugin] 07/08: Fix compile errors and test failures

Posted by ad...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

adangel pushed a commit to branch pmd7
in repository https://gitbox.apache.org/repos/asf/maven-pmd-plugin.git

commit 31192283f3b8ed6e7b3fff5f5032bbaa8005dd96
Author: Andreas Dangel <ad...@apache.org>
AuthorDate: Tue Jan 17 19:18:17 2023 +0100

    Fix compile errors and test failures
---
 .../org/apache/maven/plugins/pmd/PmdCollectingRenderer.java  |  6 ++++--
 .../java/org/apache/maven/plugins/pmd/PmdReportTest.java     | 12 ++++++++----
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/src/main/java/org/apache/maven/plugins/pmd/PmdCollectingRenderer.java b/src/main/java/org/apache/maven/plugins/pmd/PmdCollectingRenderer.java
index 2f712cd..0818d83 100644
--- a/src/main/java/org/apache/maven/plugins/pmd/PmdCollectingRenderer.java
+++ b/src/main/java/org/apache/maven/plugins/pmd/PmdCollectingRenderer.java
@@ -23,8 +23,8 @@ import net.sourceforge.pmd.Report;
 import net.sourceforge.pmd.Report.ProcessingError;
 import net.sourceforge.pmd.Report.SuppressedViolation;
 import net.sourceforge.pmd.RuleViolation;
+import net.sourceforge.pmd.lang.document.TextFile;
 import net.sourceforge.pmd.renderers.AbstractRenderer;
-import net.sourceforge.pmd.util.datasource.DataSource;
 import org.codehaus.plexus.util.StringUtils;
 
 import java.io.IOException;
@@ -147,10 +147,12 @@ public class PmdCollectingRenderer extends AbstractRenderer
     public void start() throws IOException
     {
     }
+
     @Override
-    public void startFileAnalysis( DataSource dataSource )
+    public void startFileAnalysis( TextFile textFile )
     {
     }
+
     @Override
     public void end() throws IOException
     {
diff --git a/src/test/java/org/apache/maven/plugins/pmd/PmdReportTest.java b/src/test/java/org/apache/maven/plugins/pmd/PmdReportTest.java
index 159da40..e3c4209 100644
--- a/src/test/java/org/apache/maven/plugins/pmd/PmdReportTest.java
+++ b/src/test/java/org/apache/maven/plugins/pmd/PmdReportTest.java
@@ -559,11 +559,13 @@ public class PmdReportTest
         assertTrue( FileUtils.fileExists( generatedFile.getAbsolutePath() ) );
         String str = readFile( generatedFile );
         // The parse exception must be in the XML report
-        assertTrue( str.contains( "ParseException: Encountered  at line 23, column 5." ) );
+        assertTrue( str.contains( "ParseException:" ) );
+        assertTrue( str.contains( "Encountered  at line 23, column 5." ) );
 
         str = readFile( generatedReport );
         // The parse exception must also be in the HTML report
-        assertTrue( str.contains( "ParseException: Encountered  at line 23, column 5." ) );
+        assertTrue( str.contains( "ParseException:" ) );
+        assertTrue( str.contains( "Encountered  at line 23, column 5." ) );
     }
 
     public void testPMDProcessingErrorWithDetailsNoReport()
@@ -579,11 +581,13 @@ public class PmdReportTest
         assertTrue( FileUtils.fileExists( generatedFile.getAbsolutePath() ) );
         String str = readFile( generatedFile );
         // The parse exception must be in the XML report
-        assertTrue( str.contains( "ParseException: Encountered  at line 23, column 5." ) );
+        assertTrue( str.contains( "ParseException:" ) );
+        assertTrue( str.contains( "Encountered  at line 23, column 5." ) );
 
         str = readFile( generatedReport );
         // The parse exception must NOT be in the HTML report, since reportProcessingErrors is false
-        assertFalse( str.contains( "ParseException: Encountered \"\" at line 23, column 5." ) );
+        assertFalse( str.contains( "ParseException:" ) );
+        assertFalse( str.contains( "Encountered  at line 23, column 5." ) );
     }
 
     public void testPMDExcludeRootsShouldExcludeSubdirectories()


[maven-pmd-plugin] 06/08: Fix deprecate rule reference

Posted by ad...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

adangel pushed a commit to branch pmd7
in repository https://gitbox.apache.org/repos/asf/maven-pmd-plugin.git

commit e142d5bb2ac6911fa7016076fa7dfa931b406d1d
Author: Andreas Dangel <ad...@apache.org>
AuthorDate: Fri Jun 10 11:59:21 2022 +0200

    Fix deprecate rule reference
---
 src/it/MPMD-89-232-typeresolution/src/main/pmd/ruleset.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/it/MPMD-89-232-typeresolution/src/main/pmd/ruleset.xml b/src/it/MPMD-89-232-typeresolution/src/main/pmd/ruleset.xml
index fcd6bc4..05c8abd 100644
--- a/src/it/MPMD-89-232-typeresolution/src/main/pmd/ruleset.xml
+++ b/src/it/MPMD-89-232-typeresolution/src/main/pmd/ruleset.xml
@@ -24,5 +24,5 @@ under the License.
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 http://pmd.sourceforge.net/ruleset_2_0_0.xsd">
     <description>Custom Ruleset for test case MPMD-89 and MPMP-232</description>
-  <rule ref="rulesets/java/junit.xml/TestClassWithoutTestCases"/>
+  <rule ref="category/java/errorprone.xml/TestClassWithoutTestCases"/>
 </ruleset>


[maven-pmd-plugin] 05/08: Add separate testcase to detect deprecated rules

Posted by ad...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

adangel pushed a commit to branch pmd7
in repository https://gitbox.apache.org/repos/asf/maven-pmd-plugin.git

commit a8db48594833a597ab04fc7c50074d28e30d52f8
Author: Andreas Dangel <ad...@apache.org>
AuthorDate: Fri Jun 10 11:42:49 2022 +0200

    Add separate testcase to detect deprecated rules
---
 .../org/apache/maven/plugins/pmd/RuleSetTest.java  | 51 ++++++++++++++++++++++
 1 file changed, 51 insertions(+)

diff --git a/src/test/java/org/apache/maven/plugins/pmd/RuleSetTest.java b/src/test/java/org/apache/maven/plugins/pmd/RuleSetTest.java
new file mode 100644
index 0000000..3aea015
--- /dev/null
+++ b/src/test/java/org/apache/maven/plugins/pmd/RuleSetTest.java
@@ -0,0 +1,51 @@
+package org.apache.maven.plugins.pmd;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import junit.framework.TestCase;
+import net.sourceforge.pmd.PMDConfiguration;
+import net.sourceforge.pmd.RuleSetLoader;
+
+public class RuleSetTest extends TestCase {
+
+    private RuleSetLoader ruleSetLoader = RuleSetLoader.fromPmdConfig(new PMDConfiguration()).warnDeprecated(true);
+
+    public void setUp() {
+        CapturingPrintStream.init( true );
+    }
+
+    public void testDefaultRuleset() {
+        ruleSetLoader.loadFromResource("rulesets/java/maven-pmd-plugin-default.xml");
+        assertNoDeprecatedRules( CapturingPrintStream.getOutput() );
+    }
+
+    public void testMavenRuleset() {
+        ruleSetLoader.loadFromResource("rulesets/maven.xml");
+        assertNoDeprecatedRules( CapturingPrintStream.getOutput() );
+    }
+
+    private void assertNoDeprecatedRules( String output )
+    {
+        // there must be no warnings (like deprecated rules) in the log output
+        assertFalse( output.contains( "deprecated Rule name" ) );
+        assertFalse( output.contains( "Discontinue using Rule name" ) );
+        assertFalse( output.contains( "is referenced multiple times" ) );
+    }
+}


[maven-pmd-plugin] 08/08: Fix integration tests

Posted by ad...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

adangel pushed a commit to branch pmd7
in repository https://gitbox.apache.org/repos/asf/maven-pmd-plugin.git

commit 6eb188612db2ab7303ce13826116e3f1332e1695
Author: Andreas Dangel <ad...@apache.org>
AuthorDate: Tue Jan 17 19:26:54 2023 +0100

    Fix integration tests
---
 src/it/MPMD-219-pmd-processing-error/verify.groovy | 3 ++-
 src/it/MPMD-244-logging/verify.groovy              | 6 +++---
 src/it/MPMD-268-deprecated-rules/verify.groovy     | 2 +-
 3 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/it/MPMD-219-pmd-processing-error/verify.groovy b/src/it/MPMD-219-pmd-processing-error/verify.groovy
index 9cf76cc..b9212f2 100644
--- a/src/it/MPMD-219-pmd-processing-error/verify.groovy
+++ b/src/it/MPMD-219-pmd-processing-error/verify.groovy
@@ -20,4 +20,5 @@
 File buildLog = new File( basedir, 'build.log' )
 assert buildLog.exists()
 assert buildLog.text.contains( "PMD processing errors" )
-assert buildLog.text.contains( "BrokenFile.java: ParseException: Encountered" )
+assert buildLog.text.contains( "BrokenFile.java: ParseException: Parse exception in file")
+assert buildLog.text.contains( "Encountered" )
diff --git a/src/it/MPMD-244-logging/verify.groovy b/src/it/MPMD-244-logging/verify.groovy
index daa1091..b3d0d7e 100644
--- a/src/it/MPMD-244-logging/verify.groovy
+++ b/src/it/MPMD-244-logging/verify.groovy
@@ -26,13 +26,13 @@ String disabledPath = new File( basedir, 'logging-disabled/src/main/java/BrokenF
 String enabledPath = new File( basedir, 'logging-enabled/src/main/java/BrokenFile.java' ).getCanonicalPath()
 
 // logging disabled: the pmd exception is only output through the processing error reporting (since MPMD-246)
-assert 1 == buildLog.text.count( "${disabledPath}: ParseException: Encountered" )
+assert 1 == buildLog.text.count( "${disabledPath}: ParseException: Parse exception in file" )
 
 // TODO: with PMD 7, the parse exception is not logged through PMD's logging anymore, it is only added as a processing error
 // in the report. is this correct?
 // logging enabled: the pmd exception is output twice: through the processing error reporting (since MPMD-246) and through PMD's own logging
-// assert 2 == buildLog.text.count( "${enabledPath}: ParseException: Encountered" )
-assert 1 == buildLog.text.count( "${enabledPath}: ParseException: Encountered" )
+// assert 2 == buildLog.text.count( "${enabledPath}: ParseException: Parse exception in file" )
+assert 1 == buildLog.text.count( "${enabledPath}: ParseException: Parse exception in file" )
 
 // logging disabled module is executed first, which disables the logging
 // even when logging-enabled is executed afterwards in the same JVM, the logger are not reinitialized
diff --git a/src/it/MPMD-268-deprecated-rules/verify.groovy b/src/it/MPMD-268-deprecated-rules/verify.groovy
index 009a5dd..5c41672 100644
--- a/src/it/MPMD-268-deprecated-rules/verify.groovy
+++ b/src/it/MPMD-268-deprecated-rules/verify.groovy
@@ -19,4 +19,4 @@
 
 File buildLog = new File( basedir, 'build.log' )
 assert buildLog.exists()
-assert buildLog.text.contains( "[WARNING] Use Rule name category/java/codestyle.xml/ControlStatementBraces instead of the deprecated" )
+assert buildLog.text.contains( "Use Rule name category/java/codestyle.xml/ControlStatementBraces instead of the deprecated" )


[maven-pmd-plugin] 04/08: Fix integration test MPMD-243-excludeFromFailureFile

Posted by ad...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

adangel pushed a commit to branch pmd7
in repository https://gitbox.apache.org/repos/asf/maven-pmd-plugin.git

commit 7f96dcf60026c29b03874f2bbea439040809cf5d
Author: Andreas Dangel <ad...@apache.org>
AuthorDate: Fri Jun 10 11:23:58 2022 +0200

    Fix integration test MPMD-243-excludeFromFailureFile
---
 src/it/MPMD-243-excludeFromFailureFile/invoker.properties | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/it/MPMD-243-excludeFromFailureFile/invoker.properties b/src/it/MPMD-243-excludeFromFailureFile/invoker.properties
index 1e595ef..c630e55 100644
--- a/src/it/MPMD-243-excludeFromFailureFile/invoker.properties
+++ b/src/it/MPMD-243-excludeFromFailureFile/invoker.properties
@@ -15,5 +15,5 @@
 # specific language governing permissions and limitations
 # under the License.
 
-invoker.goals = clean pmd:check
+invoker.goals = clean verify
 invoker.maven.version = 3+


[maven-pmd-plugin] 01/08: Upgrade to PMD 7

Posted by ad...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

adangel pushed a commit to branch pmd7
in repository https://gitbox.apache.org/repos/asf/maven-pmd-plugin.git

commit 98539a1975b471882c02a29043635e2f7c2befaa
Author: Andreas Dangel <ad...@apache.org>
AuthorDate: Thu Jun 9 18:50:10 2022 +0200

    Upgrade to PMD 7
---
 pom.xml                                            | 14 +++++++++--
 .../maven/plugins/pmd/PmdCollectingRenderer.java   | 28 +++++-----------------
 .../apache/maven/plugins/pmd/exec/PmdExecutor.java |  2 +-
 .../apache/maven/plugins/pmd/PmdReportTest.java    | 12 ++++------
 .../def/configuration/App.java                     |  2 +-
 .../def/configuration/AppSample.java               |  2 +-
 6 files changed, 26 insertions(+), 34 deletions(-)

diff --git a/pom.xml b/pom.xml
index f0f7a11..56d0640 100644
--- a/pom.xml
+++ b/pom.xml
@@ -30,7 +30,7 @@ under the License.
   </parent>
 
   <artifactId>maven-pmd-plugin</artifactId>
-  <version>3.20.1-SNAPSHOT</version>
+  <version>3.20.1-pmd-7-SNAPSHOT</version>
   <packaging>maven-plugin</packaging>
 
   <name>Apache Maven PMD Plugin</name>
@@ -89,7 +89,7 @@ under the License.
     <doxiaVersion>1.11.1</doxiaVersion>
     <doxiaSitetoolsVersion>1.11.1</doxiaSitetoolsVersion>
     <javaVersion>8</javaVersion><!-- Because PMD 6.35.0+ requires Java 8 -->
-    <pmdVersion>6.53.0</pmdVersion>
+    <pmdVersion>7.0.0-SNAPSHOT</pmdVersion>
     <slf4jVersion>1.7.36</slf4jVersion>
     <aetherVersion>1.0.0.v20140518</aetherVersion>
     <sitePluginVersion>3.12.1</sitePluginVersion>
@@ -304,6 +304,16 @@ under the License.
     </dependency>
   </dependencies>
 
+  <repositories>
+    <repository>
+      <id>ossrh</id>
+      <releases>
+        <enabled>false</enabled>
+      </releases>
+      <url>https://oss.sonatype.org/content/repositories/snapshots</url>
+    </repository>
+  </repositories>
+
   <build>
     <pluginManagement>
       <plugins>
diff --git a/src/main/java/org/apache/maven/plugins/pmd/PmdCollectingRenderer.java b/src/main/java/org/apache/maven/plugins/pmd/PmdCollectingRenderer.java
index d95f54c..2f712cd 100644
--- a/src/main/java/org/apache/maven/plugins/pmd/PmdCollectingRenderer.java
+++ b/src/main/java/org/apache/maven/plugins/pmd/PmdCollectingRenderer.java
@@ -19,21 +19,18 @@ package org.apache.maven.plugins.pmd;
  * under the License.
  */
 
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.codehaus.plexus.util.StringUtils;
-
 import net.sourceforge.pmd.Report;
 import net.sourceforge.pmd.Report.ProcessingError;
 import net.sourceforge.pmd.Report.SuppressedViolation;
 import net.sourceforge.pmd.RuleViolation;
 import net.sourceforge.pmd.renderers.AbstractRenderer;
 import net.sourceforge.pmd.util.datasource.DataSource;
+import org.codehaus.plexus.util.StringUtils;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
 
 
 /**
@@ -136,19 +133,6 @@ public class PmdCollectingRenderer extends AbstractRenderer
         {
             report.addError( e );
         }
-        Map<Integer, String> suppressedLines = new HashMap<Integer, String>();
-        for ( SuppressedViolation s : suppressed )
-        {
-            if ( s.suppressedByNOPMD() )
-            {
-                suppressedLines.put( s.getRuleViolation().getBeginLine(), s.getUserMessage() );
-            }
-        }
-        report.suppress( suppressedLines );
-        for ( SuppressedViolation s : suppressed )
-        {
-            report.addRuleViolation( s.getRuleViolation() );
-        }
         return report;
     }
 
diff --git a/src/main/java/org/apache/maven/plugins/pmd/exec/PmdExecutor.java b/src/main/java/org/apache/maven/plugins/pmd/exec/PmdExecutor.java
index cc25c80..2c036bd 100644
--- a/src/main/java/org/apache/maven/plugins/pmd/exec/PmdExecutor.java
+++ b/src/main/java/org/apache/maven/plugins/pmd/exec/PmdExecutor.java
@@ -31,6 +31,7 @@ import java.io.Writer;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Objects;
+import java.util.function.Predicate;
 
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugins.pmd.ExcludeViolationsFromFile;
@@ -58,7 +59,6 @@ import net.sourceforge.pmd.renderers.HTMLRenderer;
 import net.sourceforge.pmd.renderers.Renderer;
 import net.sourceforge.pmd.renderers.TextRenderer;
 import net.sourceforge.pmd.renderers.XMLRenderer;
-import net.sourceforge.pmd.util.Predicate;
 
 /**
  * Executes PMD with the configuration provided via {@link PmdRequest}.
diff --git a/src/test/java/org/apache/maven/plugins/pmd/PmdReportTest.java b/src/test/java/org/apache/maven/plugins/pmd/PmdReportTest.java
index d53ba48..159da40 100644
--- a/src/test/java/org/apache/maven/plugins/pmd/PmdReportTest.java
+++ b/src/test/java/org/apache/maven/plugins/pmd/PmdReportTest.java
@@ -468,7 +468,7 @@ public class PmdReportTest
         // check that there is no violation reported for "unusedVar2" - as it is suppressed
         assertFalse( str.contains( "Avoid unused private fields such as 'unusedVar2'.\n </violation>" ) );
         // but it appears as suppressed
-        assertTrue( str.contains( "suppressiontype=\"nopmd\" msg=\"Avoid unused private fields such as 'unusedVar2'.\"" ));
+        assertTrue( str.contains( "suppressiontype=\"//nopmd\" msg=\"Avoid unused private fields such as 'unusedVar2'.\"" ));
 
         // check if there's a link to the JXR files
         str = readFile( generatedReport );
@@ -493,7 +493,7 @@ public class PmdReportTest
         // check that there is no violation reported for "unusedVar2" - as it is suppressed
         assertFalse( str.contains( "Avoid unused private fields such as 'unusedVar2'.\n </violation>" ) );
         // but it appears as suppressed
-        assertTrue( str.contains( "suppressiontype=\"nopmd\" msg=\"Avoid unused private fields such as 'unusedVar2'.\"" ));
+        assertTrue( str.contains( "suppressiontype=\"//nopmd\" msg=\"Avoid unused private fields such as 'unusedVar2'.\"" ));
 
         // check if there's a link to the JXR files
         str = readFile( generatedReport );
@@ -558,13 +558,12 @@ public class PmdReportTest
         File generatedFile = new File( getBasedir(), "target/test/unit/parse-error/target/pmd.xml" );
         assertTrue( FileUtils.fileExists( generatedFile.getAbsolutePath() ) );
         String str = readFile( generatedFile );
-        assertTrue( str.contains( "Error while parsing" ) );
         // The parse exception must be in the XML report
-        assertTrue( str.contains( "ParseException: Encountered \"\" at line 23, column 5." ) );
+        assertTrue( str.contains( "ParseException: Encountered  at line 23, column 5." ) );
 
         str = readFile( generatedReport );
         // The parse exception must also be in the HTML report
-        assertTrue( str.contains( "ParseException: Encountered \"\" at line 23, column 5." ) );
+        assertTrue( str.contains( "ParseException: Encountered  at line 23, column 5." ) );
     }
 
     public void testPMDProcessingErrorWithDetailsNoReport()
@@ -579,9 +578,8 @@ public class PmdReportTest
         File generatedFile = new File( getBasedir(), "target/test/unit/parse-error/target/pmd.xml" );
         assertTrue( FileUtils.fileExists( generatedFile.getAbsolutePath() ) );
         String str = readFile( generatedFile );
-        assertTrue( str.contains( "Error while parsing" ) );
         // The parse exception must be in the XML report
-        assertTrue( str.contains( "ParseException: Encountered \"\" at line 23, column 5." ) );
+        assertTrue( str.contains( "ParseException: Encountered  at line 23, column 5." ) );
 
         str = readFile( generatedReport );
         // The parse exception must NOT be in the HTML report, since reportProcessingErrors is false
diff --git a/src/test/resources/unit/default-configuration/def/configuration/App.java b/src/test/resources/unit/default-configuration/def/configuration/App.java
index da53df0..04025d5 100644
--- a/src/test/resources/unit/default-configuration/def/configuration/App.java
+++ b/src/test/resources/unit/default-configuration/def/configuration/App.java
@@ -77,7 +77,7 @@ public class App
 
         for( int i = 0; i < str.length(); i++ )
         {
-            if ( i != ( str.length() -1 ) )
+            if ( i != ( ( str.length() -1 ) ) )
             {
                 tmp = tmp + str.substring( i, i + 1);
             }
diff --git a/src/test/resources/unit/default-configuration/def/configuration/AppSample.java b/src/test/resources/unit/default-configuration/def/configuration/AppSample.java
index 201bf19..6d67d27 100644
--- a/src/test/resources/unit/default-configuration/def/configuration/AppSample.java
+++ b/src/test/resources/unit/default-configuration/def/configuration/AppSample.java
@@ -55,7 +55,7 @@ public class AppSample
 
         for( int i = 0; i < str.length(); i++ )
         {
-            if ( i != ( str.length() -1 ) )
+            if ( i != ( ( str.length() -1 ) ) )
             {
                 tmp = tmp + str.substring( i, i + 1);
             }


[maven-pmd-plugin] 02/08: Fix integration tests

Posted by ad...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

adangel pushed a commit to branch pmd7
in repository https://gitbox.apache.org/repos/asf/maven-pmd-plugin.git

commit 815723ccee6843c53d61943185af42b0d71d8b89
Author: Andreas Dangel <ad...@apache.org>
AuthorDate: Fri Jun 10 09:03:20 2022 +0200

    Fix integration tests
---
 src/it/MPMD-219-pmd-processing-error/verify.groovy        | 3 +--
 src/it/MPMD-243-excludeFromFailureFile/config/ruleset.xml | 2 +-
 src/it/MPMD-244-logging/verify.groovy                     | 6 +++---
 src/it/MPMD-304-toolchain-support/verify.groovy           | 4 ++--
 src/it/mpmd-138/verify.groovy                             | 2 +-
 5 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/it/MPMD-219-pmd-processing-error/verify.groovy b/src/it/MPMD-219-pmd-processing-error/verify.groovy
index 0656c50..9cf76cc 100644
--- a/src/it/MPMD-219-pmd-processing-error/verify.groovy
+++ b/src/it/MPMD-219-pmd-processing-error/verify.groovy
@@ -20,5 +20,4 @@
 File buildLog = new File( basedir, 'build.log' )
 assert buildLog.exists()
 assert buildLog.text.contains( "PMD processing errors" )
-assert buildLog.text.contains( "Error while parsing" )
-assert buildLog.text.contains( "BrokenFile.java" )
+assert buildLog.text.contains( "BrokenFile.java: ParseException: Encountered" )
diff --git a/src/it/MPMD-243-excludeFromFailureFile/config/ruleset.xml b/src/it/MPMD-243-excludeFromFailureFile/config/ruleset.xml
index c337933..47daac1 100644
--- a/src/it/MPMD-243-excludeFromFailureFile/config/ruleset.xml
+++ b/src/it/MPMD-243-excludeFromFailureFile/config/ruleset.xml
@@ -26,5 +26,5 @@ under the License.
     MPMD-243
   </description>
 
-  <rule ref="rulesets/java/imports.xml/TooManyStaticImports"/>
+  <rule ref="category/java/codestyle.xml/TooManyStaticImports"/>
 </ruleset>
diff --git a/src/it/MPMD-244-logging/verify.groovy b/src/it/MPMD-244-logging/verify.groovy
index 459b2b9..e561fb8 100644
--- a/src/it/MPMD-244-logging/verify.groovy
+++ b/src/it/MPMD-244-logging/verify.groovy
@@ -20,12 +20,12 @@
 File buildLog = new File( basedir, 'build.log' )
 assert buildLog.exists()
 assert buildLog.text.contains( "PMD processing errors" )
-assert buildLog.text.contains( "Error while parsing" )
+assert buildLog.text.contains( "ParseException" )
 
 String disabledPath = new File( basedir, 'logging-disabled/src/main/java/BrokenFile.java' ).getCanonicalPath()
 String enabledPath = new File( basedir, 'logging-enabled/src/main/java/BrokenFile.java' ).getCanonicalPath()
 
 // logging disabled: the pmd exception is only output through the processing error reporting (since MPMD-246)
-assert 1 == buildLog.text.count( "net.sourceforge.pmd.PMDException: Error while parsing ${disabledPath}" )
+assert 1 == buildLog.text.count( "${disabledPath}: ParseException: Encountered" )
 // logging enabled: the pmd exception is output twice: through the processing error reporting (since MPMD-246) and through PMD's own logging
-assert 2 == buildLog.text.count( "net.sourceforge.pmd.PMDException: Error while parsing ${enabledPath}" )
+assert 2 == buildLog.text.count( "${enabledPath}: ParseException: Encountered" )
diff --git a/src/it/MPMD-304-toolchain-support/verify.groovy b/src/it/MPMD-304-toolchain-support/verify.groovy
index 7370225..21aa349 100644
--- a/src/it/MPMD-304-toolchain-support/verify.groovy
+++ b/src/it/MPMD-304-toolchain-support/verify.groovy
@@ -29,8 +29,8 @@ assert buildLog.text.contains( '[INFO] You have 1 CPD duplication' )
 
 File pmdReport = new File( basedir, 'target/pmd.xml' )
 assert pmdReport.exists()
-assert pmdReport.text.contains( '<violation beginline="24" endline="24" begincolumn="29" endcolumn="34" rule="ExtendsObject"' )
-assert pmdReport.text.contains( '<violation beginline="36" endline="36" begincolumn="9" endcolumn="31" rule="DontCallThreadRun"' )
+assert pmdReport.text.contains( '<violation beginline="24" endline="24" begincolumn="29" endcolumn="35" rule="ExtendsObject"' )
+assert pmdReport.text.contains( '<violation beginline="36" endline="36" begincolumn="9" endcolumn="32" rule="DontCallThreadRun"' )
 
 File pmdSite = new File( basedir, 'target/site/pmd.html' )
 assert pmdSite.exists()
diff --git a/src/it/mpmd-138/verify.groovy b/src/it/mpmd-138/verify.groovy
index 0a3a32b..2f6d345 100644
--- a/src/it/mpmd-138/verify.groovy
+++ b/src/it/mpmd-138/verify.groovy
@@ -23,7 +23,7 @@ assert buildLog.exists()
 
 // Module 1
 assert 1 == buildLog.getText().count('[INFO] PMD Failure: test.MyClass:27 Rule:UnnecessarySemicolon Priority:3 Unnecessary semicolon')
-assert 1 == buildLog.getText().count('[INFO] PMD Failure: test.MyClass:28 Rule:UnnecessaryReturn Priority:3 Avoid unnecessary return statements')
+assert 1 == buildLog.getText().count('[INFO] PMD Failure: test.MyClass:28 Rule:UnnecessaryReturn Priority:3 Unnecessary return statement')
 assert 1 == buildLog.getText().count('[INFO] You have 2 PMD violations. For more details see:')
 
 // Module 2


[maven-pmd-plugin] 03/08: Improve logging integration

Posted by ad...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

adangel pushed a commit to branch pmd7
in repository https://gitbox.apache.org/repos/asf/maven-pmd-plugin.git

commit f7e7c789f3695435664450bf06903ed428570c5f
Author: Andreas Dangel <ad...@apache.org>
AuthorDate: Fri Jun 10 11:11:01 2022 +0200

    Improve logging integration
---
 src/it/MPMD-244-logging/invoker.properties              |  1 +
 src/it/MPMD-244-logging/verify.groovy                   | 16 +++++++++++++++-
 .../org/apache/maven/plugins/pmd/exec/Executor.java     | 17 +++++++++++++++++
 3 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/src/it/MPMD-244-logging/invoker.properties b/src/it/MPMD-244-logging/invoker.properties
index d57dce3..38b6d74 100644
--- a/src/it/MPMD-244-logging/invoker.properties
+++ b/src/it/MPMD-244-logging/invoker.properties
@@ -16,5 +16,6 @@
 # under the License.
 
 invoker.goals = clean pmd:check
+invoker.goals.2 = pmd:check --projects logging-enabled --log-file build2.log
 invoker.maven.version = 3.1.0+
 invoker.debug = true
diff --git a/src/it/MPMD-244-logging/verify.groovy b/src/it/MPMD-244-logging/verify.groovy
index e561fb8..daa1091 100644
--- a/src/it/MPMD-244-logging/verify.groovy
+++ b/src/it/MPMD-244-logging/verify.groovy
@@ -27,5 +27,19 @@ String enabledPath = new File( basedir, 'logging-enabled/src/main/java/BrokenFil
 
 // logging disabled: the pmd exception is only output through the processing error reporting (since MPMD-246)
 assert 1 == buildLog.text.count( "${disabledPath}: ParseException: Encountered" )
+
+// TODO: with PMD 7, the parse exception is not logged through PMD's logging anymore, it is only added as a processing error
+// in the report. is this correct?
 // logging enabled: the pmd exception is output twice: through the processing error reporting (since MPMD-246) and through PMD's own logging
-assert 2 == buildLog.text.count( "${enabledPath}: ParseException: Encountered" )
+// assert 2 == buildLog.text.count( "${enabledPath}: ParseException: Encountered" )
+assert 1 == buildLog.text.count( "${enabledPath}: ParseException: Encountered" )
+
+// logging disabled module is executed first, which disables the logging
+// even when logging-enabled is executed afterwards in the same JVM, the logger are not reinitialized
+// everywhere, so logging is most likely still disabled.
+assert 0 == buildLog.text.count( "[DEBUG] Rules loaded from" )
+
+// only in the second invoker run, when only logging-enabled is executed, the logs from PMD are visible
+File build2Log = new File( basedir, 'build2.log' )
+assert build2Log.exists()
+assert 1 == build2Log.text.count( "[DEBUG] Rules loaded from" )
diff --git a/src/main/java/org/apache/maven/plugins/pmd/exec/Executor.java b/src/main/java/org/apache/maven/plugins/pmd/exec/Executor.java
index 3b3679c..150eb6f 100644
--- a/src/main/java/org/apache/maven/plugins/pmd/exec/Executor.java
+++ b/src/main/java/org/apache/maven/plugins/pmd/exec/Executor.java
@@ -55,6 +55,23 @@ abstract class Executor
 
     protected void setupPmdLogging( boolean showPmdLog, String logLevel )
     {
+
+        // TODO: enabling/disabling the log doesn't work reliably, because
+        // the log level is cached at each logger and the logger instances
+        // are usually static.
+        if ( !showPmdLog )
+        {
+            System.setProperty( "org.slf4j.simpleLogger.log.net.sourceforge.pmd", "off" );
+        }
+        else
+        {
+            System.clearProperty( "org.slf4j.simpleLogger.log.net.sourceforge.pmd" );
+        }
+        ILoggerFactory slf4jLoggerFactory = LoggerFactory.getILoggerFactory();
+        Slf4jConfiguration slf4jConfiguration = Slf4jConfigurationFactory
+                .getConfiguration( slf4jLoggerFactory );
+        slf4jConfiguration.activate();
+
         if ( !showPmdLog )
         {
             return;