maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1341176 - in /maven/plugins/trunk/maven-pmd-plugin/src: main/java/org/apache/maven/plugin/pmd/ test/java/org/apache/maven/plugin/pmd/
Date Mon, 21 May 2012 19:59:06 GMT
Author: olamy
Date: Mon May 21 19:59:06 2012
New Revision: 1341176

URL: http://svn.apache.org/viewvc?rev=1341176&view=rev
Log:
code formatting

Modified:
    maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/CpdReport.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/test/java/org/apache/maven/plugin/pmd/CpdReportTest.java
    maven/plugins/trunk/maven-pmd-plugin/src/test/java/org/apache/maven/plugin/pmd/PmdViolationCheckMojoTest.java

Modified: maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/CpdReport.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/CpdReport.java?rev=1341176&r1=1341175&r2=1341176&view=diff
==============================================================================
--- maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/CpdReport.java
(original)
+++ maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/CpdReport.java
Mon May 21 19:59:06 2012
@@ -19,18 +19,6 @@ package org.apache.maven.plugin.pmd;
  * under the License.
  */
 
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStreamWriter;
-import java.io.UnsupportedEncodingException;
-import java.io.Writer;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Properties;
-import java.util.ResourceBundle;
-
 import net.sourceforge.pmd.cpd.CPD;
 import net.sourceforge.pmd.cpd.CPDConfiguration;
 import net.sourceforge.pmd.cpd.CSVRenderer;
@@ -38,13 +26,24 @@ import net.sourceforge.pmd.cpd.JavaLangu
 import net.sourceforge.pmd.cpd.JavaTokenizer;
 import net.sourceforge.pmd.cpd.Renderer;
 import net.sourceforge.pmd.cpd.XMLRenderer;
-
 import org.apache.maven.reporting.MavenReportException;
 import org.codehaus.plexus.util.FileUtils;
 import org.codehaus.plexus.util.IOUtil;
 import org.codehaus.plexus.util.StringUtils;
 import org.codehaus.plexus.util.WriterFactory;
 
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.io.UnsupportedEncodingException;
+import java.io.Writer;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Properties;
+import java.util.ResourceBundle;
+
 /**
  * Creates a report for PMD's CPD tool.  See
  * <a href="http://pmd.sourceforge.net/cpd.html">http://pmd.sourceforge.net/cpd.html</a>
@@ -52,9 +51,9 @@ import org.codehaus.plexus.util.WriterFa
  *
  * @author Mike Perham
  * @version $Id$
- * @since 2.0
  * @goal cpd
  * @threadSafe
+ * @since 2.0
  */
 public class CpdReport
     extends AbstractPmdReport
@@ -93,19 +92,25 @@ public class CpdReport
      */
     private boolean ignoreIdentifiers;
 
-    /** {@inheritDoc} */
+    /**
+     * {@inheritDoc}
+     */
     public String getName( Locale locale )
     {
         return getBundle( locale ).getString( "report.cpd.name" );
     }
 
-    /** {@inheritDoc} */
+    /**
+     * {@inheritDoc}
+     */
     public String getDescription( Locale locale )
     {
         return getBundle( locale ).getString( "report.cpd.description" );
     }
 
-    /** {@inheritDoc} */
+    /**
+     * {@inheritDoc}
+     */
     public void executeReport( Locale locale )
         throws MavenReportException
     {
@@ -186,25 +191,28 @@ public class CpdReport
         }
         cpd.go();
 
-        CpdReportGenerator gen =
-            new CpdReportGenerator( getSink(), files, getBundle( locale ), aggregate );
+        CpdReportGenerator gen = new CpdReportGenerator( getSink(), files, getBundle( locale
), aggregate );
         gen.generate( cpd.getMatches() );
 
         return cpd;
     }
 
-    private String determineEncoding(boolean showWarn) throws UnsupportedEncodingException
{
+    private String determineEncoding( boolean showWarn )
+        throws UnsupportedEncodingException
+    {
         String encoding = WriterFactory.FILE_ENCODING;
-        if ( StringUtils.isNotEmpty( getSourceEncoding() ) ) {
+        if ( StringUtils.isNotEmpty( getSourceEncoding() ) )
+        {
 
             encoding = getSourceEncoding();
             // test encoding as CPD will convert exception into a RuntimeException
             WriterFactory.newWriter( new ByteArrayOutputStream(), encoding );
 
-        } else if ( showWarn ) {
-            getLog().warn(
-                    "File encoding has not been set, using platform encoding "
-                        + WriterFactory.FILE_ENCODING + ", i.e. build is platform dependent!"
);
+        }
+        else if ( showWarn )
+        {
+            getLog().warn( "File encoding has not been set, using platform encoding " + WriterFactory.FILE_ENCODING
+                               + ", i.e. build is platform dependent!" );
             encoding = WriterFactory.FILE_ENCODING;
         }
         return encoding;
@@ -247,7 +255,9 @@ public class CpdReport
         }
     }
 
-    /** {@inheritDoc} */
+    /**
+     * {@inheritDoc}
+     */
     public String getOutputName()
     {
         return "cpd";
@@ -272,7 +282,7 @@ public class CpdReport
         if ( "xml".equals( format ) )
         {
             //TODO: pmd should provide a better way to specify the output encoding (getOutputEncoding());
-            System.setProperty("file.encoding", getOutputEncoding());
+            System.setProperty( "file.encoding", getOutputEncoding() );
             renderer = new XMLRenderer();
         }
         else if ( "csv".equals( format ) )

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=1341176&r1=1341175&r2=1341176&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
Mon May 21 19:59:06 2012
@@ -19,19 +19,6 @@ package org.apache.maven.plugin.pmd;
  * under the License.
  */
 
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStreamWriter;
-import java.io.Writer;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Properties;
-import java.util.ResourceBundle;
-
 import net.sourceforge.pmd.PMD;
 import net.sourceforge.pmd.PMDConfiguration;
 import net.sourceforge.pmd.Report;
@@ -48,7 +35,6 @@ import net.sourceforge.pmd.renderers.Tex
 import net.sourceforge.pmd.renderers.XMLRenderer;
 import net.sourceforge.pmd.util.datasource.DataSource;
 import net.sourceforge.pmd.util.datasource.FileDataSource;
-
 import org.apache.maven.doxia.sink.Sink;
 import org.apache.maven.reporting.MavenReportException;
 import org.codehaus.plexus.resource.ResourceManager;
@@ -60,6 +46,19 @@ 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.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Properties;
+import java.util.ResourceBundle;
+
 /**
  * Creates a PMD report.
  *
@@ -194,9 +193,11 @@ public class PmdReport
 
         PMDConfiguration pmdConfiguration = getPMDConfiguration();
         final PmdReportListener reportSink = new PmdReportListener( sink, getBundle( locale
), aggregate );
-        RuleContext ruleContext = new RuleContext() {
+        RuleContext ruleContext = new RuleContext()
+        {
             @Override
-            public void setReport(Report report) {
+            public void setReport( Report report )
+            {
                 super.setReport( report );
                 // make sure our listener is added - the Report is created by PMD internally
now
                 report.addListener( reportSink );
@@ -230,7 +231,7 @@ public class PmdReport
         {
             throw new MavenReportException( e.getMessage(), e );
         }
-        pmdConfiguration.setRuleSets( StringUtils.join( sets, "," ));
+        pmdConfiguration.setRuleSets( StringUtils.join( sets, "," ) );
 
         Map<File, PmdFileInfo> files;
         try
@@ -251,7 +252,7 @@ public class PmdReport
         }
         pmdConfiguration.setSourceEncoding( encoding );
 
-        reportSink.setFiles(files);
+        reportSink.setFiles( files );
         List<DataSource> dataSources = new ArrayList<DataSource>( files.size()
);
         for ( File f : files.keySet() )
         {
@@ -268,7 +269,7 @@ public class PmdReport
             // all the violations.
             pmdConfiguration.setThreads( 0 );
 
-            PMD.processFiles(pmdConfiguration, ruleSetFactory, dataSources, ruleContext,
renderers );
+            PMD.processFiles( pmdConfiguration, ruleSetFactory, dataSources, ruleContext,
renderers );
         }
         catch ( Exception e )
         {
@@ -310,7 +311,7 @@ public class PmdReport
         // replace all occurrences of the following characters:  ? : & = %
         loc = loc.replaceAll( "[\\?\\:\\&\\=\\%]", "_" );
 
-        if (!loc.endsWith( ".xml" ))
+        if ( !loc.endsWith( ".xml" ) )
         {
             loc = loc + ".xml";
         }
@@ -435,9 +436,8 @@ public class PmdReport
         {
             try
             {
-                renderer = (Renderer) Class.forName( format )
-                        .getConstructor( Properties.class )
-                            .newInstance( new Properties() );
+                renderer = (Renderer) Class.forName( format ).getConstructor( Properties.class
).newInstance(
+                    new Properties() );
             }
             catch ( Exception e )
             {

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=1341176&r1=1341175&r2=1341176&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
Mon May 21 19:59:06 2012
@@ -19,6 +19,12 @@ package org.apache.maven.plugin.pmd;
  * under the License.
  */
 
+import net.sourceforge.pmd.ReportListener;
+import net.sourceforge.pmd.RuleViolation;
+import net.sourceforge.pmd.stat.Metric;
+import org.apache.maven.doxia.sink.Sink;
+import org.codehaus.plexus.util.StringUtils;
+
 import java.io.File;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -28,13 +34,6 @@ import java.util.List;
 import java.util.Map;
 import java.util.ResourceBundle;
 
-import net.sourceforge.pmd.ReportListener;
-import net.sourceforge.pmd.RuleViolation;
-import net.sourceforge.pmd.stat.Metric;
-
-import org.apache.maven.doxia.sink.Sink;
-import org.codehaus.plexus.util.StringUtils;
-
 /**
  * Handle events from PMD, converting them into Doxia events.
  *
@@ -75,27 +74,31 @@ public class PmdReportListener
         return bundle.getString( "report.pmd.title" );
     }
 
-    /** {@inheritDoc} */
+    /**
+     * {@inheritDoc}
+     */
     public void ruleViolationAdded( RuleViolation ruleViolation )
     {
         violations.add( ruleViolation );
     }
 
-    public List<RuleViolation> getViolations() {
+    public List<RuleViolation> getViolations()
+    {
         return violations;
     }
 
-    private void startFileSection(String currentFilename, PmdFileInfo fileInfo) {
+    private void startFileSection( String currentFilename, PmdFileInfo fileInfo )
+    {
         sink.section2();
         sink.sectionTitle2();
 
         // prepare the filename
-        this.currentFilename = StringUtils.substring( currentFilename,
-                                          fileInfo.getSourceDirectory().getAbsolutePath().length()
+ 1 );
+        this.currentFilename =
+            StringUtils.substring( currentFilename, fileInfo.getSourceDirectory().getAbsolutePath().length()
+ 1 );
         this.currentFilename = StringUtils.replace( this.currentFilename, "\\", "/" );
 
         String title = this.currentFilename;
-        if (aggregate)
+        if ( aggregate )
         {
             title = fileInfo.getProject().getName() + " - " + currentFilename;
         }
@@ -113,12 +116,14 @@ public class PmdReportListener
         sink.tableRow_();
     }
 
-    private void endFileSection() {
+    private void endFileSection()
+    {
         sink.table_();
         sink.section2_();
     }
 
-    private void processSingleRuleViolation(RuleViolation ruleViolation) {
+    private void processSingleRuleViolation( RuleViolation ruleViolation )
+    {
         sink.tableRow();
         sink.tableCell();
         sink.text( ruleViolation.getDescription() );
@@ -128,7 +133,8 @@ public class PmdReportListener
         int beginLine = ruleViolation.getBeginLine();
         outputLineLink( beginLine );
         int endLine = ruleViolation.getEndLine();
-        if (endLine != beginLine) {
+        if ( endLine != beginLine )
+        {
             sink.text( " - " );
             outputLineLink( endLine );
         }
@@ -143,14 +149,18 @@ public class PmdReportListener
     private void processViolations()
     {
         fileCount = files.size();
-        Collections.sort( violations, new Comparator<RuleViolation>() {
+        Collections.sort( violations, new Comparator<RuleViolation>()
+        {
             /** {@inheritDoc} */
-            public int compare(RuleViolation o1, RuleViolation o2) {
+            public int compare( RuleViolation o1, RuleViolation o2 )
+            {
                 int filenames = o1.getFilename().compareTo( o2.getFilename() );
-                if (filenames == 0) {
+                if ( filenames == 0 )
+                {
                     return o1.getBeginLine() - o2.getBeginLine();
                 }
-                else {
+                else
+                {
                     return filenames;
                 }
             }
@@ -204,7 +214,9 @@ public class PmdReportListener
         }
     }
 
-    /** {@inheritDoc} */
+    /**
+     * {@inheritDoc}
+     */
     public void metricAdded( Metric metric )
     {
 //        if ( metric.getCount() != 0 )
@@ -333,7 +345,8 @@ public class PmdReportListener
         sink.close();
     }
 
-    public void setFiles(Map<File, PmdFileInfo> files) {
+    public void setFiles( Map<File, PmdFileInfo> files )
+    {
         this.files = files;
     }
 }
\ No newline at end of file

Modified: maven/plugins/trunk/maven-pmd-plugin/src/test/java/org/apache/maven/plugin/pmd/CpdReportTest.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/test/java/org/apache/maven/plugin/pmd/CpdReportTest.java?rev=1341176&r1=1341175&r2=1341176&view=diff
==============================================================================
--- maven/plugins/trunk/maven-pmd-plugin/src/test/java/org/apache/maven/plugin/pmd/CpdReportTest.java
(original)
+++ maven/plugins/trunk/maven-pmd-plugin/src/test/java/org/apache/maven/plugin/pmd/CpdReportTest.java
Mon May 21 19:59:06 2012
@@ -19,26 +19,24 @@ package org.apache.maven.plugin.pmd;
  * under the License.
  */
 
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
 import net.sourceforge.pmd.cpd.CPD;
 import net.sourceforge.pmd.cpd.CPDConfiguration;
 import net.sourceforge.pmd.cpd.JavaLanguage;
 import net.sourceforge.pmd.cpd.Match;
 import net.sourceforge.pmd.cpd.TokenEntry;
-
 import org.codehaus.plexus.util.FileUtils;
 import org.w3c.dom.Document;
 
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
 /**
  * @author <a href="mailto:oching@apache.org">Maria Odea Ching</a>
  * @version $Id$
@@ -46,7 +44,9 @@ import org.w3c.dom.Document;
 public class CpdReportTest
     extends AbstractPmdReportTest
 {
-    /** {@inheritDoc} */
+    /**
+     * {@inheritDoc}
+     */
     protected void setUp()
         throws Exception
     {
@@ -62,9 +62,8 @@ public class CpdReportTest
     public void testDefaultConfiguration()
         throws Exception
     {
-        File testPom =
-            new File( getBasedir(),
-                      "src/test/resources/unit/default-configuration/cpd-default-configuration-plugin-config.xml"
);
+        File testPom = new File( getBasedir(),
+                                 "src/test/resources/unit/default-configuration/cpd-default-configuration-plugin-config.xml"
);
         CpdReport mojo = (CpdReport) lookupMojo( "cpd", testPom );
         mojo.execute();
 
@@ -100,9 +99,8 @@ public class CpdReportTest
     public void testCustomConfiguration()
         throws Exception
     {
-        File testPom =
-            new File( getBasedir(),
-                      "src/test/resources/unit/custom-configuration/cpd-custom-configuration-plugin-config.xml"
);
+        File testPom = new File( getBasedir(),
+                                 "src/test/resources/unit/custom-configuration/cpd-custom-configuration-plugin-config.xml"
);
         CpdReport mojo = (CpdReport) lookupMojo( "cpd", testPom );
         mojo.execute();
 
@@ -115,8 +113,7 @@ public class CpdReportTest
         assertTrue( FileUtils.fileExists( generatedFile.getAbsolutePath() ) );
 
         // Contents that should NOT be in the report
-        String str =
-            readFile( new File( getBasedir(), "target/test/unit/custom-configuration/target/site/cpd.html"
) );
+        String str = readFile( new File( getBasedir(), "target/test/unit/custom-configuration/target/site/cpd.html"
) );
         assertTrue( str.toLowerCase().indexOf( "/Sample.java".toLowerCase() ) == -1 );
 
         str = readFile( new File( getBasedir(), "target/test/unit/custom-configuration/target/site/cpd.html"
) );
@@ -145,8 +142,7 @@ public class CpdReportTest
         try
         {
             File testPom =
-                new File( getBasedir(),
-                          "src/test/resources/unit/invalid-format/cpd-invalid-format-plugin-config.xml"
);
+                new File( getBasedir(), "src/test/resources/unit/invalid-format/cpd-invalid-format-plugin-config.xml"
);
             CpdReport mojo = (CpdReport) lookupMojo( "cpd", testPom );
             setVariableValueToObject( mojo, "compileSourceRoots", mojo.project.getCompileSourceRoots()
);
             mojo.execute();
@@ -163,8 +159,7 @@ public class CpdReportTest
     /**
      * Read the contents of the specified file object into a string
      *
-     * @param file
-     *            the file to be read
+     * @param file the file to be read
      * @return a String object that contains the contents of the file
      * @throws java.io.IOException
      */
@@ -188,9 +183,8 @@ public class CpdReportTest
     public void testWriteNonHtml()
         throws Exception
     {
-        File testPom =
-            new File( getBasedir(),
-                      "src/test/resources/unit/default-configuration/cpd-default-configuration-plugin-config.xml"
);
+        File testPom = new File( getBasedir(),
+                                 "src/test/resources/unit/default-configuration/cpd-default-configuration-plugin-config.xml"
);
         CpdReport mojo = (CpdReport) lookupMojo( "cpd", testPom );
         assertNotNull( mojo );
 

Modified: maven/plugins/trunk/maven-pmd-plugin/src/test/java/org/apache/maven/plugin/pmd/PmdViolationCheckMojoTest.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/test/java/org/apache/maven/plugin/pmd/PmdViolationCheckMojoTest.java?rev=1341176&r1=1341175&r2=1341176&view=diff
==============================================================================
--- maven/plugins/trunk/maven-pmd-plugin/src/test/java/org/apache/maven/plugin/pmd/PmdViolationCheckMojoTest.java
(original)
+++ maven/plugins/trunk/maven-pmd-plugin/src/test/java/org/apache/maven/plugin/pmd/PmdViolationCheckMojoTest.java
Mon May 21 19:59:06 2012
@@ -31,7 +31,9 @@ import java.io.File;
 public class PmdViolationCheckMojoTest
     extends AbstractMojoTestCase
 {
-    /** {@inheritDoc} */
+    /**
+     * {@inheritDoc}
+     */
     protected void setUp()
         throws Exception
     {
@@ -76,12 +78,12 @@ public class PmdViolationCheckMojoTest
         throws Exception
     {
         File testPom = new File( getBasedir(),
-                "src/test/resources/unit/default-configuration/default-configuration-plugin-config.xml"
);
+                                 "src/test/resources/unit/default-configuration/default-configuration-plugin-config.xml"
);
         PmdReport mojo = (PmdReport) lookupMojo( "pmd", testPom );
         mojo.execute();
 
         testPom = new File( getBasedir(),
-                                 "src/test/resources/unit/default-configuration/pmd-check-failonpriority-plugin-config.xml"
);
+                            "src/test/resources/unit/default-configuration/pmd-check-failonpriority-plugin-config.xml"
);
         PmdViolationCheckMojo pmdViolationMojo = (PmdViolationCheckMojo) lookupMojo( "check",
testPom );
         pmdViolationMojo.execute();
 



Mime
View raw message