You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by br...@apache.org on 2006/02/09 06:04:49 UTC

svn commit: r376186 - in /maven/plugins/trunk/maven-pmd-plugin: pom.xml src/main/java/org/apache/maven/plugin/pmd/PmdReportListener.java

Author: brett
Date: Wed Feb  8 21:04:47 2006
New Revision: 376186

URL: http://svn.apache.org/viewcvs?rev=376186&view=rev
Log:
[MPMD-12] update to PMD-3.5, and change to use non-deprecated API getLine() that was removed

Modified:
    maven/plugins/trunk/maven-pmd-plugin/pom.xml
    maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdReportListener.java

Modified: maven/plugins/trunk/maven-pmd-plugin/pom.xml
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-pmd-plugin/pom.xml?rev=376186&r1=376185&r2=376186&view=diff
==============================================================================
--- maven/plugins/trunk/maven-pmd-plugin/pom.xml (original)
+++ maven/plugins/trunk/maven-pmd-plugin/pom.xml Wed Feb  8 21:04:47 2006
@@ -15,7 +15,7 @@
     <dependency>
       <groupId>pmd</groupId>
       <artifactId>pmd</artifactId>
-      <version>3.4</version>
+      <version>3.5</version>
     </dependency>
     <dependency>
       <groupId>org.apache.maven.reporting</groupId>
@@ -23,11 +23,6 @@
       <version>2.0</version>
     </dependency>
     <dependency>
-      <groupId>saxpath</groupId>
-      <artifactId>saxpath</artifactId>
-      <version>1.0-FCS</version>
-    </dependency>
-    <dependency>
       <groupId>org.codehaus.plexus</groupId>
       <artifactId>plexus-utils</artifactId>
     </dependency>
@@ -37,4 +32,4 @@
       <name>John Allen</name>
     </contributor>
   </contributors>
-</project>
\ No newline at end of file
+</project>

Modified: maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdReportListener.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdReportListener.java?rev=376186&r1=376185&r2=376186&view=diff
==============================================================================
--- maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdReportListener.java (original)
+++ maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdReportListener.java Wed Feb  8 21:04:47 2006
@@ -16,6 +16,12 @@
  * limitations under the License.
  */
 
+import net.sourceforge.pmd.ReportListener;
+import net.sourceforge.pmd.RuleViolation;
+import net.sourceforge.pmd.stat.Metric;
+import org.codehaus.doxia.sink.Sink;
+import org.codehaus.plexus.util.StringUtils;
+
 import java.io.File;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -24,13 +30,6 @@
 import java.util.List;
 import java.util.ResourceBundle;
 
-import net.sourceforge.pmd.ReportListener;
-import net.sourceforge.pmd.RuleViolation;
-import net.sourceforge.pmd.stat.Metric;
-
-import org.codehaus.doxia.sink.Sink;
-import org.codehaus.plexus.util.StringUtils;
-
 /**
  * Handle events from PMD, converting them into Doxia events.
  *
@@ -100,7 +99,8 @@
         {
             public int compare( Object o1, Object o2 )
             {
-                return ( (RuleViolation) o1 ).getLine() - ( (RuleViolation) o2 ).getLine();
+                return ( (RuleViolation) o1 ).getNode().getBeginLine() -
+                    ( (RuleViolation) o2 ).getNode().getBeginLine();
             }
         } );
 
@@ -114,15 +114,13 @@
             sink.tableCell_();
             sink.tableCell();
 
-            if ( getXrefLocation() != null )
-            {
-                sink.link( getXrefLocation() + "/" + currentFilename.replaceAll( "\\.java$", ".html" ) + "#"
-                    + ruleViolation.getLine() );
-            }
-            sink.text( String.valueOf( ruleViolation.getLine() ) );
-            if ( getXrefLocation() != null )
+            int beginLine = ruleViolation.getNode().getBeginLine();
+            outputLineLink( beginLine );
+            int endLine = ruleViolation.getNode().getEndLine();
+            if ( endLine != beginLine )
             {
-                sink.link_();
+                sink.text( " - ");
+                outputLineLink( beginLine );
             }
 
             sink.tableCell_();
@@ -131,6 +129,19 @@
         violations.clear();
     }
 
+    private void outputLineLink( int line )
+    {
+        if ( xrefLocation != null )
+        {
+            sink.link( xrefLocation + "/" + currentFilename.replaceAll( "\\.java$", ".html" ) + "#" + line );
+        }
+        sink.text( String.valueOf( line ) );
+        if ( xrefLocation != null )
+        {
+            sink.link_();
+        }
+    }
+
     public void metricAdded( Metric metric )
     {
         if ( metric.getCount() != 0 )
@@ -229,16 +240,16 @@
             sink.text( met.getMetricName() );
             sink.tableCell_();
             sink.tableCell();
-            sink.text( "" + met.getCount() );
+            sink.text( String.valueOf( met.getCount() ) );
             sink.tableCell_();
             sink.tableCell();
-            sink.text( "" + met.getHighValue() );
+            sink.text( String.valueOf( met.getHighValue() ) );
             sink.tableCell_();
             sink.tableCell();
-            sink.text( "" + met.getLowValue() );
+            sink.text( String.valueOf( met.getLowValue() ) );
             sink.tableCell_();
             sink.tableCell();
-            sink.text( "" + met.getAverage() );
+            sink.text( String.valueOf( met.getAverage() ) );
             sink.tableCell_();
             sink.tableRow_();
         }
@@ -254,7 +265,7 @@
         // For instance, run the coupling ruleset and you will get a boatload
         // of excessive imports metrics, none of which is really any use.
         // TODO Determine if we are going to just ignore metrics.
-        
+
         // processMetrics();
 
         sink.body_();