maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1159144 - in /maven/plugins/trunk/maven-pmd-plugin/src: main/java/org/apache/maven/plugin/pmd/PmdReport.java test/java/org/apache/maven/plugin/pmd/PmdReportTest.java
Date Thu, 18 Aug 2011 10:28:18 GMT
Author: olamy
Date: Thu Aug 18 10:28:18 2011
New Revision: 1159144

URL: http://svn.apache.org/viewvc?rev=1159144&view=rev
Log:
[MPMD-127] Report cannot correctly handle external PMD ruleset as exported by Sonar QA Dashboard
Submitted by Tjerk Stroband

Modified:
    maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdReport.java
    maven/plugins/trunk/maven-pmd-plugin/src/test/java/org/apache/maven/plugin/pmd/PmdReportTest.java

Modified: maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdReport.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdReport.java?rev=1159144&r1=1159143&r2=1159144&view=diff
==============================================================================
--- maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdReport.java
(original)
+++ maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdReport.java
Thu Aug 18 10:28:18 2011
@@ -380,7 +380,7 @@ public class PmdReport
      * @param name the name of the file whose location is to be resolved
      * @return a String that contains the absolute file name of the file
      */
-    private String getLocationTemp( String name )
+    protected String getLocationTemp( String name )
     {
         String loc = name;
         if ( loc.indexOf( '/' ) != -1 )
@@ -391,6 +391,13 @@ public class PmdReport
         {
             loc = loc.substring( loc.lastIndexOf( '\\' ) + 1 );
         }
+        
+        // MPMD-127 in the case that the rules are defined externally on a url
+        // we need to replace some special url characters that cannot be
+        // used in filenames on disk or produce ackward filenames.
+        // replace all occurrences of the following characters:  ? : & = %
+        loc = loc.replaceAll("[\\?\\:\\&\\=\\%]", "_");
+        
         getLog().debug( "Before: " + name + " After: " + loc );
         return loc;
     }

Modified: maven/plugins/trunk/maven-pmd-plugin/src/test/java/org/apache/maven/plugin/pmd/PmdReportTest.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/test/java/org/apache/maven/plugin/pmd/PmdReportTest.java?rev=1159144&r1=1159143&r2=1159144&view=diff
==============================================================================
--- maven/plugins/trunk/maven-pmd-plugin/src/test/java/org/apache/maven/plugin/pmd/PmdReportTest.java
(original)
+++ maven/plugins/trunk/maven-pmd-plugin/src/test/java/org/apache/maven/plugin/pmd/PmdReportTest.java
Thu Aug 18 10:28:18 2011
@@ -255,5 +255,23 @@ public class PmdReportTest
         return str.toString();
     }
 
+    /**
+     * Verify the correct working of the localtionTemp method
+     * 
+     * @throws Exception
+     */
+    public void testLocationTemp()
+        throws Exception
+    {
+
+        File testPom = new File( getBasedir(),
+                                 "src/test/resources/unit/default-configuration/default-configuration-plugin-config.xml"
);
+        PmdReport mojo = (PmdReport) lookupMojo( "pmd", testPom );
+
+        assertEquals( "locationTemp is not correctly encoding filename",
+                      "export_format_pmd_language_java_name_some_2520name", mojo.getLocationTemp(
+            "http://nemo.sonarsource.org/sonar/profiles/export?format=pmd&language=java&name=some%2520name"
) );
+
+    }
 
 }



Mime
View raw message