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 2018/06/23 15:52:14 UTC

[maven-pmd-plugin] branch master updated (ae7f9c7 -> a52aead)

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

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


    from ae7f9c7  [INFRA-16467] move components documentation out of CMS space
     new b4895cd  (doc) fix links to pmd
     new a52aead  [MPMD-268] - Missing warnings about deprecated rules

The 2 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:
 .../invoker.properties                             |  3 ++-
 .../pom.xml                                        | 26 ++++++++++++----------
 .../pmd => MPMD-268-deprecated-rules}/ruleset.xml  |  8 +++++--
 .../src/main/java/sample/Sample.java}              |  7 +++---
 .../verify.groovy                                  |  4 +---
 .../maven/plugins/pmd/CpdReportGenerator.java      |  2 +-
 .../org/apache/maven/plugins/pmd/PmdReport.java    | 21 +++++++++++++----
 .../maven/plugins/pmd/PmdReportGenerator.java      |  2 +-
 8 files changed, 46 insertions(+), 27 deletions(-)
 copy src/it/{MPMD-244-logging => MPMD-268-deprecated-rules}/invoker.properties (94%)
 copy src/it/{MPMD-258-multiple-executions => MPMD-268-deprecated-rules}/pom.xml (78%)
 copy src/it/{MPMD-89-232-typeresolution/src/main/pmd => MPMD-268-deprecated-rules}/ruleset.xml (79%)
 copy src/it/{MPMD-187/src/main/java/App.java => MPMD-268-deprecated-rules/src/main/java/sample/Sample.java} (95%)
 copy src/it/{MPMD-258-multiple-executions => MPMD-268-deprecated-rules}/verify.groovy (86%)


[maven-pmd-plugin] 01/02: (doc) fix links to pmd

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

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

commit b4895cde7fbab20d527d1f307bda8dfeb517f434
Author: Andreas Dangel <ad...@apache.org>
AuthorDate: Sat Jun 23 17:19:33 2018 +0200

    (doc) fix links to pmd
---
 src/main/java/org/apache/maven/plugins/pmd/CpdReportGenerator.java | 2 +-
 src/main/java/org/apache/maven/plugins/pmd/PmdReport.java          | 4 ++--
 src/main/java/org/apache/maven/plugins/pmd/PmdReportGenerator.java | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/main/java/org/apache/maven/plugins/pmd/CpdReportGenerator.java b/src/main/java/org/apache/maven/plugins/pmd/CpdReportGenerator.java
index 78b5d44..389d6ca 100644
--- a/src/main/java/org/apache/maven/plugins/pmd/CpdReportGenerator.java
+++ b/src/main/java/org/apache/maven/plugins/pmd/CpdReportGenerator.java
@@ -86,7 +86,7 @@ public class CpdReportGenerator
 
         sink.paragraph();
         sink.text( bundle.getString( "report.cpd.cpdlink" ) + " " );
-        sink.link( "http://pmd.sourceforge.net/cpd.html" );
+        sink.link( "https://pmd.github.io/latest/pmd_userdocs_cpd.html" );
         sink.text( "CPD" );
         sink.link_();
         sink.text( " " + AbstractPmdReport.getPmdVersion() + "." );
diff --git a/src/main/java/org/apache/maven/plugins/pmd/PmdReport.java b/src/main/java/org/apache/maven/plugins/pmd/PmdReport.java
index caab072..84d56ff 100644
--- a/src/main/java/org/apache/maven/plugins/pmd/PmdReport.java
+++ b/src/main/java/org/apache/maven/plugins/pmd/PmdReport.java
@@ -84,7 +84,7 @@ public class PmdReport
     /**
      * The target JDK to analyze based on. Should match the source used in the compiler plugin. Valid values are
      * currently <code>1.3</code>, <code>1.4</code>, <code>1.5</code>, <code>1.6</code>, <code>1.7</code>,
-     * <code>1.8</code> and <code>9</code>.
+     * <code>1.8</code>, <code>9</code>, and <code>10</code>.
      * <p>
      *   <b>Note:</b> this parameter is only used if the language parameter is set to <code>java</code>.
      * </p>
@@ -156,7 +156,7 @@ public class PmdReport
     /**
      * Source level marker used to indicate whether a RuleViolation should be suppressed. If it is not set, PMD's
      * default will be used, which is <code>NOPMD</code>. See also <a
-     * href="https://pmd.github.io/latest/usage/suppressing.html">PMD &#x2013; Suppressing warnings</a>.
+     * href="https://pmd.github.io/latest/pmd_userdocs_suppressing_warnings.html">PMD &#x2013; Suppressing warnings</a>.
      *
      * @since 3.4
      */
diff --git a/src/main/java/org/apache/maven/plugins/pmd/PmdReportGenerator.java b/src/main/java/org/apache/maven/plugins/pmd/PmdReportGenerator.java
index 7284583..d76ad73 100644
--- a/src/main/java/org/apache/maven/plugins/pmd/PmdReportGenerator.java
+++ b/src/main/java/org/apache/maven/plugins/pmd/PmdReportGenerator.java
@@ -371,7 +371,7 @@ public class PmdReportGenerator
 
         sink.paragraph();
         sink.text( bundle.getString( "report.pmd.pmdlink" ) + " " );
-        sink.link( "http://pmd.sourceforge.net/" );
+        sink.link( "https://pmd.github.io" );
         sink.text( "PMD" );
         sink.link_();
         sink.text( " " + AbstractPmdReport.getPmdVersion() + "." );


[maven-pmd-plugin] 02/02: [MPMD-268] - Missing warnings about 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 master
in repository https://gitbox.apache.org/repos/asf/maven-pmd-plugin.git

commit a52aeadaea217ace4cb39679a9fa8715ad7af2db
Author: Andreas Dangel <ad...@apache.org>
AuthorDate: Sat Jun 23 17:50:15 2018 +0200

    [MPMD-268] - Missing warnings about deprecated rules
---
 .../MPMD-268-deprecated-rules/invoker.properties   | 20 ++++++++
 src/it/MPMD-268-deprecated-rules/pom.xml           | 60 ++++++++++++++++++++++
 src/it/MPMD-268-deprecated-rules/ruleset.xml       | 32 ++++++++++++
 .../src/main/java/sample/Sample.java               | 24 +++++++++
 src/it/MPMD-268-deprecated-rules/verify.groovy     | 22 ++++++++
 .../org/apache/maven/plugins/pmd/PmdReport.java    | 17 +++++-
 6 files changed, 173 insertions(+), 2 deletions(-)

diff --git a/src/it/MPMD-268-deprecated-rules/invoker.properties b/src/it/MPMD-268-deprecated-rules/invoker.properties
new file mode 100644
index 0000000..5ad0800
--- /dev/null
+++ b/src/it/MPMD-268-deprecated-rules/invoker.properties
@@ -0,0 +1,20 @@
+# 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.
+
+invoker.goals = clean verify
+invoker.maven.version = 3.1.0+
+invoker.debug = false
diff --git a/src/it/MPMD-268-deprecated-rules/pom.xml b/src/it/MPMD-268-deprecated-rules/pom.xml
new file mode 100644
index 0000000..1653a46
--- /dev/null
+++ b/src/it/MPMD-268-deprecated-rules/pom.xml
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+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.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.maven.plugins.pmd.its</groupId>
+  <artifactId>MPMD-268-deprecated-rules</artifactId>
+  <version>1.0-SNAPSHOT</version>
+  <packaging>jar</packaging>
+
+  <description>
+    Verify PMD logs deprecated rules
+  </description>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>@project.groupId@</groupId>
+        <artifactId>@project.artifactId@</artifactId>
+        <version>@project.version@</version>
+        <configuration>
+            <rulesets>
+                <ruleset>ruleset.xml</ruleset>
+            </rulesets>
+        </configuration>
+        <executions>
+          <execution>
+            <phase>verify</phase>
+            <goals>
+              <goal>check</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>
diff --git a/src/it/MPMD-268-deprecated-rules/ruleset.xml b/src/it/MPMD-268-deprecated-rules/ruleset.xml
new file mode 100644
index 0000000..2b4f05b
--- /dev/null
+++ b/src/it/MPMD-268-deprecated-rules/ruleset.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+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.
+-->
+
+<ruleset name="Custom ruleset"
+    xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
+    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-268</description>
+
+    <!-- Explicitly marking this rule a deprecated, which should issue a warning when executing PMD -->
+    <rule ref="category/java/codestyle.xml/ControlStatementBraces"
+        deprecated="true" />
+
+</ruleset>
diff --git a/src/it/MPMD-268-deprecated-rules/src/main/java/sample/Sample.java b/src/it/MPMD-268-deprecated-rules/src/main/java/sample/Sample.java
new file mode 100644
index 0000000..af4c55b
--- /dev/null
+++ b/src/it/MPMD-268-deprecated-rules/src/main/java/sample/Sample.java
@@ -0,0 +1,24 @@
+package sample;
+
+/*
+ * 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.
+ */
+
+public class Sample
+{
+}
\ No newline at end of file
diff --git a/src/it/MPMD-268-deprecated-rules/verify.groovy b/src/it/MPMD-268-deprecated-rules/verify.groovy
new file mode 100644
index 0000000..009a5dd
--- /dev/null
+++ b/src/it/MPMD-268-deprecated-rules/verify.groovy
@@ -0,0 +1,22 @@
+/*
+ * 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.
+ */
+
+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" )
diff --git a/src/main/java/org/apache/maven/plugins/pmd/PmdReport.java b/src/main/java/org/apache/maven/plugins/pmd/PmdReport.java
index 84d56ff..fa354a1 100644
--- a/src/main/java/org/apache/maven/plugins/pmd/PmdReport.java
+++ b/src/main/java/org/apache/maven/plugins/pmd/PmdReport.java
@@ -55,6 +55,7 @@ import net.sourceforge.pmd.Report;
 import net.sourceforge.pmd.RuleContext;
 import net.sourceforge.pmd.RulePriority;
 import net.sourceforge.pmd.RuleSetFactory;
+import net.sourceforge.pmd.RuleSetNotFoundException;
 import net.sourceforge.pmd.RuleSetReferenceId;
 import net.sourceforge.pmd.RuleViolation;
 import net.sourceforge.pmd.benchmark.Benchmarker;
@@ -228,6 +229,7 @@ public class PmdReport
     /**
      * {@inheritDoc}
      */
+    @Override
     public String getName( Locale locale )
     {
         return getBundle( locale ).getString( "report.pmd.name" );
@@ -236,6 +238,7 @@ public class PmdReport
     /**
      * {@inheritDoc}
      */
+    @Override
     public String getDescription( Locale locale )
     {
         return getBundle( locale ).getString( "report.pmd.description" );
@@ -502,12 +505,21 @@ public class PmdReport
             throws MavenReportException
     {
         RuleSetFactory ruleSetFactory = new RuleSetFactory( new ResourceLoader(),
-                RulePriority.valueOf( this.minimumPriority ), false, true );
-        RuleContext ruleContext = new RuleContext();
+                RulePriority.valueOf( this.minimumPriority ), true, true );
+        try
+        {
+            // load the ruleset once to log out any deprecated rules as warnings
+            ruleSetFactory.createRuleSets( pmdConfiguration.getRuleSets() );
+        }
+        catch ( RuleSetNotFoundException e1 )
+        {
+            throw new MavenReportException( "The ruleset could not be loaded", e1 );
+        }
 
         try
         {
             getLog().debug( "Executing PMD..." );
+            RuleContext ruleContext = new RuleContext();
             PMD.processFiles( pmdConfiguration, ruleSetFactory, dataSources, ruleContext,
                               Arrays.<Renderer>asList( renderer ) );
 
@@ -700,6 +712,7 @@ public class PmdReport
     /**
      * {@inheritDoc}
      */
+    @Override
     public String getOutputName()
     {
         return "pmd";