You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by rf...@apache.org on 2012/01/14 17:54:13 UTC

svn commit: r1231525 - in /maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd: PmdFileInfo.java PmdReport.java PmdReportListener.java PmdViolationCheckMojo.java

Author: rfscholte
Date: Sat Jan 14 16:54:12 2012
New Revision: 1231525

URL: http://svn.apache.org/viewvc?rev=1231525&view=rev
Log:
Add more generics

Modified:
    maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdFileInfo.java
    maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdReport.java
    maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdReportListener.java
    maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdViolationCheckMojo.java

Modified: maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdFileInfo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdFileInfo.java?rev=1231525&r1=1231524&r2=1231525&view=diff
==============================================================================
--- maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdFileInfo.java (original)
+++ maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdFileInfo.java Sat Jan 14 16:54:12 2012
@@ -33,7 +33,6 @@ public class PmdFileInfo
     private File sourceDir;
     private String xref;
 
-
     public PmdFileInfo( MavenProject project,
                        File dir,
                        String x )
@@ -50,7 +49,6 @@ public class PmdFileInfo
         this.xref = x;
     }
 
-
     public String getXrefLocation()
     {
         return xref;
@@ -66,5 +64,4 @@ public class PmdFileInfo
         return project;
     }
 
-
-}
+}
\ No newline at end of file

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=1231525&r1=1231524&r2=1231525&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 Sat Jan 14 16:54:12 2012
@@ -19,6 +19,20 @@ package org.apache.maven.plugin.pmd;
  * under the License.
  */
 
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStreamWriter;
+import java.io.Reader;
+import java.io.UnsupportedEncodingException;
+import java.io.Writer;
+import java.util.Locale;
+import java.util.Map;
+import java.util.ResourceBundle;
+
 import net.sourceforge.pmd.IRuleViolation;
 import net.sourceforge.pmd.PMD;
 import net.sourceforge.pmd.PMDException;
@@ -33,6 +47,7 @@ import net.sourceforge.pmd.renderers.HTM
 import net.sourceforge.pmd.renderers.Renderer;
 import net.sourceforge.pmd.renderers.TextRenderer;
 import net.sourceforge.pmd.renderers.XMLRenderer;
+
 import org.apache.maven.doxia.sink.Sink;
 import org.apache.maven.reporting.MavenReportException;
 import org.codehaus.plexus.resource.ResourceManager;
@@ -44,21 +59,6 @@ import org.codehaus.plexus.util.IOUtil;
 import org.codehaus.plexus.util.ReaderFactory;
 import org.codehaus.plexus.util.StringUtils;
 
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStreamWriter;
-import java.io.Reader;
-import java.io.UnsupportedEncodingException;
-import java.io.Writer;
-import java.util.Iterator;
-import java.util.Locale;
-import java.util.Map;
-import java.util.ResourceBundle;
-
 /**
  * Creates a PMD report.
  *
@@ -243,7 +243,7 @@ public class PmdReport
             throw new MavenReportException( e.getMessage(), e );
         }
 
-        Map files;
+        Map<File, PmdFileInfo> files;
         try
         {
             files = getFilesToProcess();
@@ -259,11 +259,10 @@ public class PmdReport
                                + ", i.e. build is platform dependent!" );
         }
 
-        for ( Iterator i = files.entrySet().iterator(); i.hasNext(); )
+        for ( Map.Entry<File, PmdFileInfo> entry : files.entrySet() )
         {
-            Map.Entry entry = (Map.Entry) i.next();
-            File file = (File) entry.getKey();
-            PmdFileInfo fileInfo = (PmdFileInfo) entry.getValue();
+            File file = entry.getKey();
+            PmdFileInfo fileInfo = entry.getValue();
 
             // TODO: lazily call beginFile in case there are no rules
 
@@ -611,4 +610,4 @@ public class PmdReport
             return null;
         }
     }
-}
+}
\ No newline at end of file

Modified: maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdReportListener.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdReportListener.java?rev=1231525&r1=1231524&r2=1231525&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 Sat Jan 14 16:54:12 2012
@@ -23,7 +23,6 @@ import java.io.File;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Comparator;
-import java.util.Iterator;
 import java.util.List;
 import java.util.ResourceBundle;
 
@@ -53,7 +52,7 @@ public class PmdReportListener
 
     private PmdFileInfo fileInfo;
 
-    private List violations = new ArrayList();
+    private List<IRuleViolation> violations = new ArrayList<IRuleViolation>();
 
     private boolean aggregate;
 
@@ -109,20 +108,17 @@ public class PmdReportListener
     private void processViolations()
     {
         fileCount++;
-        Collections.sort( violations, new Comparator()
+        Collections.sort( violations, new Comparator<IRuleViolation>()
         {
             /** {@inheritDoc} */
-            public int compare( Object o1, Object o2 )
+            public int compare( IRuleViolation o1, IRuleViolation o2 )
             {
-                return ( (IRuleViolation) o1 ).getBeginLine()
-                    - ( (IRuleViolation) o2 ).getBeginLine();
+                return o1.getBeginLine() - o2.getBeginLine();
             }
         } );
 
-        for ( Iterator it = violations.iterator(); it.hasNext(); )
+        for ( IRuleViolation ruleViolation : violations )
         {
-            IRuleViolation ruleViolation = (IRuleViolation) it.next();
-
             sink.tableRow();
             sink.tableCell();
             sink.text( ruleViolation.getDescription() );
@@ -304,4 +300,4 @@ public class PmdReportListener
 
         sink.close();
     }
-}
+}
\ No newline at end of file

Modified: maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdViolationCheckMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdViolationCheckMojo.java?rev=1231525&r1=1231524&r2=1231525&view=diff
==============================================================================
--- maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdViolationCheckMojo.java (original)
+++ maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdViolationCheckMojo.java Sat Jan 14 16:54:12 2012
@@ -71,7 +71,7 @@ public class PmdViolationCheckMojo
     }
 
     /** {@inheritDoc} */
-    protected void printError( Map item, String severity )
+    protected void printError( Map<String, String> item, String severity )
     {
 
         StringBuffer buff = new StringBuffer( 100 );
@@ -99,12 +99,12 @@ public class PmdViolationCheckMojo
     }
 
     /** {@inheritDoc} */
-    protected Map getErrorDetails( XmlPullParser xpp )
+    protected Map<String, String> getErrorDetails( XmlPullParser xpp )
         throws XmlPullParserException, IOException
     {
         int index = 0;
         int attributeCount = 0;
-        HashMap msgs = new HashMap();
+        Map<String, String> msgs = new HashMap<String, String>();
 
         attributeCount = xpp.getAttributeCount();
         while ( index < attributeCount )
@@ -122,4 +122,4 @@ public class PmdViolationCheckMojo
         }
         return msgs;
     }
-}
+}
\ No newline at end of file