Author: dantran Date: Tue Jan 20 19:54:03 2015 New Revision: 1653350 URL: http://svn.apache.org/r1653350 Log: Code format
Modified: maven/plugins/trunk/maven-pmd-plugin/src/it/empty-rulesets/src/main/java/com/mycompany/app/App.java maven/plugins/trunk/maven-pmd-plugin/src/it/empty-rulesets/src/main/java/com/mycompany/app/Foo.java maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-138/mod-3/pom.xml maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-138/mod-4/pom.xml maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-142/pom.xml maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168-empty-report/pom.xml maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168/pom.xml maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-89/pom.xml maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/AbstractPmdReport.java maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/AbstractPmdViolationCheckMojo.java 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/CpdReportGenerator.java maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/CpdViolationCheckMojo.java 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/PmdReportGenerator.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 maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/rules/DummyRule.java maven/plugins/trunk/maven-pmd-plugin/src/main/resources/rulesets/maven.xml maven/plugins/trunk/maven-pmd-plugin/src/test/java/org/apache/maven/plugin/pmd/AbstractPmdReportTest.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/CpdViolationCheckMojoTest.java maven/plugins/trunk/maven-pmd-plugin/src/test/java/org/apache/maven/plugin/pmd/PmdReportTest.java maven/plugins/trunk/maven-pmd-plugin/src/test/java/org/apache/maven/plugin/pmd/PmdViolationCheckMojoTest.java maven/plugins/trunk/maven-pmd-plugin/src/test/java/org/apache/maven/plugin/pmd/stubs/CustomConfigurationMavenProjectStub.java maven/plugins/trunk/maven-pmd-plugin/src/test/java/org/apache/maven/plugin/pmd/stubs/DefaultConfigurationMavenProjectStub.java maven/plugins/trunk/maven-pmd-plugin/src/test/java/org/apache/maven/plugin/pmd/stubs/InvalidFormatMavenProjectStub.java Modified: maven/plugins/trunk/maven-pmd-plugin/src/it/empty-rulesets/src/main/java/com/mycompany/app/App.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/it/empty-rulesets/src/main/java/com/mycompany/app/App.java?rev=1653350&r1=1653349&r2=1653350&view=diff ============================================================================== --- maven/plugins/trunk/maven-pmd-plugin/src/it/empty-rulesets/src/main/java/com/mycompany/app/App.java (original) +++ maven/plugins/trunk/maven-pmd-plugin/src/it/empty-rulesets/src/main/java/com/mycompany/app/App.java Tue Jan 20 19:54:03 2015 @@ -19,8 +19,7 @@ package com.mycompany.app; * under the License. */ -public class App +public class App { - } Modified: maven/plugins/trunk/maven-pmd-plugin/src/it/empty-rulesets/src/main/java/com/mycompany/app/Foo.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/it/empty-rulesets/src/main/java/com/mycompany/app/Foo.java?rev=1653350&r1=1653349&r2=1653350&view=diff ============================================================================== --- maven/plugins/trunk/maven-pmd-plugin/src/it/empty-rulesets/src/main/java/com/mycompany/app/Foo.java (original) +++ maven/plugins/trunk/maven-pmd-plugin/src/it/empty-rulesets/src/main/java/com/mycompany/app/Foo.java Tue Jan 20 19:54:03 2015 @@ -18,10 +18,11 @@ */ import java.util.ArrayList; + public class Foo { - public Foo(final ArrayList<String> foo) + public Foo( final ArrayList<String> foo ) { } - + } Modified: maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-138/mod-3/pom.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-138/mod-3/pom.xml?rev=1653350&r1=1653349&r2=1653350&view=diff ============================================================================== --- maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-138/mod-3/pom.xml (original) +++ maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-138/mod-3/pom.xml Tue Jan 20 19:54:03 2015 @@ -31,7 +31,7 @@ under the License. <artifactId>mpmd-138-mod-3</artifactId> <name>Module 3</name> - + <description>Test 3 classes with copy-paste block</description> - + </project> \ No newline at end of file Modified: maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-138/mod-4/pom.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-138/mod-4/pom.xml?rev=1653350&r1=1653349&r2=1653350&view=diff ============================================================================== --- maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-138/mod-4/pom.xml (original) +++ maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-138/mod-4/pom.xml Tue Jan 20 19:54:03 2015 @@ -29,9 +29,9 @@ under the License. </parent> <artifactId>mpmd-138-mod-4</artifactId> - + <name>Module 4</name> - + <description>Test 3 classes with copy-paste block</description> </project> \ No newline at end of file Modified: maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-142/pom.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-142/pom.xml?rev=1653350&r1=1653349&r2=1653350&view=diff ============================================================================== --- maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-142/pom.xml (original) +++ maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-142/pom.xml Tue Jan 20 19:54:03 2015 @@ -25,9 +25,9 @@ under the License. <groupId>org.apache.maven.plugin.pmd.it</groupId> <artifactId>mpmd-142</artifactId> <version>1.0.0-SNAPSHOT</version> - + <description>PMD Report for maven site fails with ClassCastException</description> - + <build> <pluginManagement> <plugins> Modified: maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168-empty-report/pom.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168-empty-report/pom.xml?rev=1653350&r1=1653349&r2=1653350&view=diff ============================================================================== --- maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168-empty-report/pom.xml (original) +++ maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168-empty-report/pom.xml Tue Jan 20 19:54:03 2015 @@ -58,7 +58,7 @@ under the License. </plugin> </plugins> </build> - + <reporting> <plugins> <plugin> Modified: maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168/pom.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168/pom.xml?rev=1653350&r1=1653349&r2=1653350&view=diff ============================================================================== --- maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168/pom.xml (original) +++ maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168/pom.xml Tue Jan 20 19:54:03 2015 @@ -58,7 +58,7 @@ under the License. </plugin> </plugins> </build> - + <reporting> <plugins> <plugin> Modified: maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-89/pom.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-89/pom.xml?rev=1653350&r1=1653349&r2=1653350&view=diff ============================================================================== --- maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-89/pom.xml (original) +++ maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-89/pom.xml Tue Jan 20 19:54:03 2015 @@ -21,7 +21,7 @@ under the License. <project> <modelVersion>4.0.0</modelVersion> - + <groupId>org.apache.maven.plugin.pmd.it</groupId> <artifactId>mpmd-89</artifactId> <version>1.0-SNAPSHOT</version> Modified: maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/AbstractPmdReport.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/AbstractPmdReport.java?rev=1653350&r1=1653349&r2=1653350&view=diff ============================================================================== --- maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/AbstractPmdReport.java (original) +++ maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/AbstractPmdReport.java Tue Jan 20 19:54:03 2015 @@ -19,7 +19,19 @@ package org.apache.maven.plugin.pmd; * under the License. */ +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; + import net.sourceforge.pmd.PMD; + import org.apache.maven.doxia.siterenderer.Renderer; import org.apache.maven.model.ReportPlugin; import org.apache.maven.plugins.annotations.Component; @@ -31,17 +43,6 @@ import org.codehaus.plexus.util.PathTool import org.codehaus.plexus.util.ReaderFactory; import org.codehaus.plexus.util.StringUtils; -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.TreeMap; - /** * Base class for the PMD reports. * @@ -78,17 +79,16 @@ public abstract class AbstractPmdReport protected MavenProject project; /** - * Set the output format type, in addition to the HTML report. Must be one of: "none", - * "csv", "xml", "txt" or the full class name of the PMD renderer to use. - * See the net.sourceforge.pmd.renderers package javadoc for available renderers. - * XML is required if the pmd:check goal is being used. + * Set the output format type, in addition to the HTML report. Must be one of: "none", "csv", "xml", "txt" or the + * full class name of the PMD renderer to use. See the net.sourceforge.pmd.renderers package javadoc for available + * renderers. XML is required if the pmd:check goal is being used. */ @Parameter( property = "format", defaultValue = "xml" ) protected String format = "xml"; /** - * Link the violation line numbers to the source xref. Links will be created - * automatically if the jxr plugin is being used. + * Link the violation line numbers to the source xref. Links will be created automatically if the jxr plugin is + * being used. */ @Parameter( property = "linkXRef", defaultValue = "true" ) private boolean linkXRef; @@ -117,8 +117,8 @@ public abstract class AbstractPmdReport private List<String> excludes; /** - * A list of files to include from checking. Can contain Ant-style wildcards and double wildcards. - * Defaults to **\/*.java. + * A list of files to include from checking. Can contain Ant-style wildcards and double wildcards. Defaults to + * **\/*.java. * * @since 2.2 */ @@ -192,8 +192,8 @@ public abstract class AbstractPmdReport protected boolean includeXmlInSite; /** - * Skip the PMD/CPD report generation if there are no violations or duplications found. - * Defaults to <code>true</code>. + * Skip the PMD/CPD report generation if there are no violations or duplications found. Defaults to + * <code>true</code>. * * @since 3.1 */ @@ -243,7 +243,8 @@ public abstract class AbstractPmdReport else { // Not yet generated - check if the report is on its way - @SuppressWarnings( "unchecked" ) List<ReportPlugin> reportPlugins = project.getReportPlugins(); + @SuppressWarnings( "unchecked" ) + List<ReportPlugin> reportPlugins = project.getReportPlugins(); for ( ReportPlugin plugin : reportPlugins ) { String artifactId = plugin.getArtifactId(); @@ -325,8 +326,8 @@ public abstract class AbstractPmdReport { for ( MavenProject localProject : reactorProjects ) { - @SuppressWarnings( "unchecked" ) List<String> localCompileSourceRoots = - localProject.getCompileSourceRoots(); + @SuppressWarnings( "unchecked" ) + List<String> localCompileSourceRoots = localProject.getCompileSourceRoots(); for ( String root : localCompileSourceRoots ) { File sroot = new File( root ); @@ -338,16 +339,16 @@ public abstract class AbstractPmdReport } if ( includeTests ) { - @SuppressWarnings( "unchecked" ) List<String> localTestCompileSourceRoots = - localProject.getTestCompileSourceRoots(); + @SuppressWarnings( "unchecked" ) + List<String> localTestCompileSourceRoots = localProject.getTestCompileSourceRoots(); for ( String root : localTestCompileSourceRoots ) { File sroot = new File( root ); - if ( sroot.exists() ) - { - String testXref = constructXRefLocation( true ); - directories.add( new PmdFileInfo( localProject, sroot, testXref ) ); - } + if ( sroot.exists() ) + { + String testXref = constructXRefLocation( true ); + directories.add( new PmdFileInfo( localProject, sroot, testXref ) ); + } } } } @@ -367,8 +368,7 @@ public abstract class AbstractPmdReport File sourceDirectory = finfo.getSourceDirectory(); if ( sourceDirectory.isDirectory() && !excludeRootFiles.contains( sourceDirectory ) ) { - List<File> newfiles = - FileUtils.getFiles( sourceDirectory, including, excluding ); + List<File> newfiles = FileUtils.getFiles( sourceDirectory, including, excluding ); for ( File newfile : newfiles ) { files.put( newfile.getCanonicalFile(), finfo ); @@ -405,8 +405,7 @@ public abstract class AbstractPmdReport */ private String getExcludes() { - Collection<String> patterns = - new LinkedHashSet<String>( FileUtils.getDefaultExcludesAsList() ); + Collection<String> patterns = new LinkedHashSet<String>( FileUtils.getDefaultExcludesAsList() ); if ( excludes != null ) { patterns.addAll( excludes ); @@ -418,6 +417,7 @@ public abstract class AbstractPmdReport { return "html".equals( format ); } + protected boolean isXml() { return "xml".equals( format ); Modified: maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/AbstractPmdViolationCheckMojo.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/AbstractPmdViolationCheckMojo.java?rev=1653350&r1=1653349&r2=1653350&view=diff ============================================================================== --- maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/AbstractPmdViolationCheckMojo.java (original) +++ maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/AbstractPmdViolationCheckMojo.java Tue Jan 20 19:54:03 2015 @@ -19,6 +19,11 @@ package org.apache.maven.plugin.pmd; * under the License. */ +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; @@ -27,15 +32,10 @@ import org.apache.maven.project.MavenPro import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - /** * Base class for mojos that check if there were any PMD violations. - * @param <D> type of the check, e.g. {@link Violation} or {@link Duplication}. * + * @param <D> type of the check, e.g. {@link Violation} or {@link Duplication}. * @author <a href="mailto:br...@apache.org">Brett Porter</a> * @version $Id$ */ @@ -83,9 +83,8 @@ public abstract class AbstractPmdViolati private boolean printFailingErrors; /** - * File that lists classes and rules to be excluded from failures - * For PMD, this is a properties file - * For CPD, this is a text file that contains comma-separated lists of classes that are allowed to duplicate + * File that lists classes and rules to be excluded from failures For PMD, this is a properties file For CPD, this + * is a text file that contains comma-separated lists of classes that are allowed to duplicate * * @since 3.0 */ @@ -145,12 +144,14 @@ public abstract class AbstractPmdViolati } catch ( final IOException e ) { - throw new MojoExecutionException( "Unable to read PMD results xml: " + outputFile.getAbsolutePath(), + throw new MojoExecutionException( + "Unable to read PMD results xml: " + outputFile.getAbsolutePath(), e ); } catch ( final XmlPullParserException e ) { - throw new MojoExecutionException( "Unable to read PMD results xml: " + outputFile.getAbsolutePath(), + throw new MojoExecutionException( + "Unable to read PMD results xml: " + outputFile.getAbsolutePath(), e ); } } @@ -245,8 +246,8 @@ public abstract class AbstractPmdViolati { if ( failureCount > 0 ) { - message.append( "You have " ).append( failureCount ).append( " " ).append( key ) - .append( failureCount > 1 ? "s" : "" ); + message.append( "You have " ).append( failureCount ).append( " " ).append( key ). + append( failureCount > 1 ? "s" : "" ); } if ( warningCount > 0 ) @@ -275,8 +276,7 @@ public abstract class AbstractPmdViolati protected abstract void printError( D item, String severity ); /** - * Gets the attributes and text for the violation tag and puts them in a - * HashMap + * Gets the attributes and text for the violation tag and puts them in a HashMap * * @param analisysFile * @throws XmlPullParserException 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=1653350&r1=1653349&r2=1653350&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 Tue Jan 20 19:54:03 2015 @@ -19,6 +19,17 @@ 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.Properties; +import java.util.ResourceBundle; + import net.sourceforge.pmd.cpd.CPD; import net.sourceforge.pmd.cpd.CPDConfiguration; import net.sourceforge.pmd.cpd.CSVRenderer; @@ -26,6 +37,7 @@ 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.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.reporting.MavenReportException; @@ -34,21 +46,9 @@ 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.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> - * for more detail. + * Creates a report for PMD's CPD tool. See <a + * href="http://pmd.sourceforge.net/cpd.html">http://pmd.sourceforge.net/cpd.html</a> for more detail. * * @author Mike Perham * @version $Id$ @@ -65,8 +65,7 @@ public class CpdReport private int minimumTokens; /** - * Skip the CPD report generation. Most useful on the command line - * via "-Dcpd.skip=true". + * Skip the CPD report generation. Most useful on the command line via "-Dcpd.skip=true". * * @since 2.1 */ @@ -74,9 +73,9 @@ public class CpdReport private boolean skip; /** - * If true, CPD ignores literal value differences when evaluating a duplicate block. - * This means that <code>foo=42;</code> and <code>foo=43;</code> will be seen as equivalent. - * You may want to run PMD with this option off to start with and then switch it on to see what it turns up. + * If true, CPD ignores literal value differences when evaluating a duplicate block. This means that + * <code>foo=42;</code> and <code>foo=43;</code> will be seen as equivalent. You may want to run PMD with this + * option off to start with and then switch it on to see what it turns up. * * @since 2.5 */ @@ -346,8 +345,7 @@ public class CpdReport * Create and return the correct renderer for the output type. * * @return the renderer based on the configured output - * @throws org.apache.maven.reporting.MavenReportException - * if no renderer found for the output type + * @throws org.apache.maven.reporting.MavenReportException if no renderer found for the output type */ public Renderer createRenderer() throws MavenReportException @@ -369,8 +367,8 @@ public class CpdReport } catch ( Exception e ) { - throw new MavenReportException( - "Can't find CPD custom format " + format + ": " + e.getClass().getName(), e ); + throw new MavenReportException( "Can't find CPD custom format " + format + ": " + + e.getClass().getName(), e ); } } Modified: maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/CpdReportGenerator.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/CpdReportGenerator.java?rev=1653350&r1=1653349&r2=1653350&view=diff ============================================================================== --- maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/CpdReportGenerator.java (original) +++ maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/CpdReportGenerator.java Tue Jan 20 19:54:03 2015 @@ -19,17 +19,18 @@ package org.apache.maven.plugin.pmd; * under the License. */ +import java.io.File; +import java.util.Iterator; +import java.util.Map; +import java.util.ResourceBundle; + import net.sourceforge.pmd.cpd.Match; import net.sourceforge.pmd.cpd.TokenEntry; + import org.apache.maven.doxia.sink.Sink; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.util.StringUtils; -import java.io.File; -import java.util.Iterator; -import java.util.Map; -import java.util.ResourceBundle; - /** * Class that generated the CPD report. * @@ -131,8 +132,8 @@ public class CpdReportGenerator if ( xrefLocation != null ) { - sink.link( - xrefLocation + "/" + filename.replaceAll( "\\.java$", ".html" ).replace( '\\', '/' ) + "#L" + line ); + sink.link( xrefLocation + "/" + filename.replaceAll( "\\.java$", ".html" ).replace( '\\', '/' ) + "#L" + + line ); } sink.text( String.valueOf( line ) ); if ( xrefLocation != null ) Modified: maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/CpdViolationCheckMojo.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/CpdViolationCheckMojo.java?rev=1653350&r1=1653349&r2=1653350&view=diff ============================================================================== --- maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/CpdViolationCheckMojo.java (original) +++ maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/CpdViolationCheckMojo.java Tue Jan 20 19:54:03 2015 @@ -19,6 +19,15 @@ package org.apache.maven.plugin.pmd; * under the License. */ +import java.io.File; +import java.io.FileReader; +import java.io.IOException; +import java.io.LineNumberReader; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugin.pmd.model.CpdErrorDetail; @@ -31,15 +40,6 @@ import org.apache.maven.plugins.annotati import org.apache.maven.plugins.annotations.Parameter; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; -import java.io.File; -import java.io.FileReader; -import java.io.IOException; -import java.io.LineNumberReader; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - /** * Fail the build if there were any CPD violations in the source code. * @@ -53,8 +53,7 @@ public class CpdViolationCheckMojo { /** - * Skip the CPD violation checks. Most useful on the command line - * via "-Dcpd.skip=true". + * Skip the CPD violation checks. Most useful on the command line via "-Dcpd.skip=true". */ @Parameter( property = "cpd.skip", defaultValue = "false" ) private boolean skip; @@ -69,7 +68,6 @@ public class CpdViolationCheckMojo @Parameter( property = "cpd.failOnViolation", defaultValue = "true", required = true ) protected boolean failOnViolation; - /** * {@inheritDoc} */ 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=1653350&r1=1653349&r2=1653350&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 Tue Jan 20 19:54:03 2015 @@ -19,11 +19,11 @@ package org.apache.maven.plugin.pmd; * under the License. */ -import org.apache.maven.project.MavenProject; - import java.io.File; import java.io.IOException; +import org.apache.maven.project.MavenProject; + /** * @version $Id$ */ 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=1653350&r1=1653349&r2=1653350&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 Tue Jan 20 19:54:03 2015 @@ -19,6 +19,20 @@ package org.apache.maven.plugin.pmd; * under the License. */ +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStreamWriter; +import java.io.PrintStream; +import java.io.Writer; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Locale; +import java.util.Properties; +import java.util.ResourceBundle; + import net.sourceforge.pmd.PMD; import net.sourceforge.pmd.PMDConfiguration; import net.sourceforge.pmd.Report; @@ -37,6 +51,7 @@ 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.plugins.annotations.Component; import org.apache.maven.plugins.annotations.Mojo; @@ -52,20 +67,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.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStreamWriter; -import java.io.PrintStream; -import java.io.Writer; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Locale; -import java.util.Properties; -import java.util.ResourceBundle; - /** * Creates a PMD report. * @@ -79,15 +80,15 @@ public class PmdReport { /** * The target JDK to analyze based on. Should match the target 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> - * and <code>1.7</code>. + * currently <code>1.3</code>, <code>1.4</code>, <code>1.5</code>, <code>1.6</code>, <code>1.7</code> and + * <code>1.7</code>. */ @Parameter( property = "targetJdk", defaultValue = "${maven.compiler.target}" ) private String targetJdk; /** - * The programming language to be analyzed by PMD. Valid values are currently <code>java</code> - * and <code>ecmascript</code> or <code>javascript</code>. + * The programming language to be analyzed by PMD. Valid values are currently <code>java</code> and + * <code>ecmascript</code> or <code>javascript</code>. * <p> * <b>Note:</b> if the parameter targetJdk is given, then this language parameter will be ignored. * </p> @@ -98,8 +99,7 @@ public class PmdReport private String language; /** - * The rule priority threshold; rules with lower priority - * than this will not be evaluated. + * The rule priority threshold; rules with lower priority than this will not be evaluated. * * @since 2.1 */ @@ -107,8 +107,7 @@ public class PmdReport private int minimumPriority = 5; /** - * Skip the PMD report generation. Most useful on the command line - * via "-Dpmd.skip=true". + * Skip the PMD report generation. Most useful on the command line via "-Dpmd.skip=true". * * @since 2.1 */ @@ -120,7 +119,7 @@ public class PmdReport * list of some included. Defaults to the java-basic, java-imports and java-unusedcode rulesets. */ @Parameter - private String[] rulesets = new String[]{ "java-basic", "java-unusedcode", "java-imports" }; + private String[] rulesets = new String[] { "java-basic", "java-unusedcode", "java-imports" }; /** * Controls whether the project's compile/test classpath should be passed to PMD to enable its type resolution @@ -145,13 +144,13 @@ public class PmdReport * @since 3.1 */ @Parameter( property = "pmd.benchmarkOutputFilename", - defaultValue = "${project.build.directory}/pmd-benchmark.txt" ) + defaultValue = "${project.build.directory}/pmd-benchmark.txt" ) private String benchmarkOutputFilename; /** - * 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="http://pmd.sourceforge.net/usage/suppressing.html">PMD - Suppressing warnings</a>. + * 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="http://pmd.sourceforge.net/usage/suppressing.html">PMD - Suppressing warnings</a>. * * @since 3.4 */ @@ -168,6 +167,7 @@ public class PmdReport /** * per default pmd executions error are ignored to not break the whole + * * @since 3.1 */ @Parameter( property = "pmd.skipPmdError", defaultValue = "true" ) @@ -258,7 +258,7 @@ public class PmdReport if ( result ) { getLog().debug( "Skipping report since skipEmptyReport is true and" - + "there are no PMD violations." ); + + "there are no PMD violations." ); } } } @@ -295,7 +295,7 @@ public class PmdReport return; } - //configure ResourceManager + // configure ResourceManager locator.addSearchPath( FileResourceLoader.ID, project.getFile().getParentFile().getAbsolutePath() ); locator.addSearchPath( "url", "" ); locator.setOutputDirectory( targetDirectory ); @@ -309,7 +309,7 @@ public class PmdReport ruleSetFactory.setMinimumPriority( RulePriority.valueOf( this.minimumPriority ) ); // Workaround for https://sourceforge.net/p/pmd/bugs/1155/: add a dummy ruleset. - String[] presentRulesets = rulesets.length > 0 ? rulesets : new String [] { "/rulesets/dummy.xml" }; + String[] presentRulesets = rulesets.length > 0 ? rulesets : new String[] { "/rulesets/dummy.xml" }; String[] sets = new String[presentRulesets.length]; try @@ -346,9 +346,8 @@ public class PmdReport if ( filesToProcess.isEmpty() && !"java".equals( language ) ) { - getLog().warn( - "No files found to process. Did you add your additional source folders like javascript?" - + " (see also build-helper-maven-plugin)" ); + getLog().warn( "No files found to process. Did you add your additional source folders like javascript?" + + " (see also build-helper-maven-plugin)" ); } } catch ( IOException e ) @@ -465,7 +464,7 @@ public class PmdReport // 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: ? : & = % + // replace all occurrences of the following characters: ? : & = % loc = loc.replaceAll( "[\\?\\:\\&\\=\\%]", "_" ); if ( !loc.endsWith( ".xml" ) ) @@ -527,12 +526,10 @@ public class PmdReport } /** - * Constructs the PMD configuration class, passing it an argument - * that configures the target JDK. + * Constructs the PMD configuration class, passing it an argument that configures the target JDK. * * @return the resulting PMD - * @throws org.apache.maven.reporting.MavenReportException - * if targetJdk is not supported + * @throws org.apache.maven.reporting.MavenReportException if targetJdk is not supported */ public PMDConfiguration getPMDConfiguration() throws MavenReportException @@ -601,8 +598,7 @@ public class PmdReport * Create and return the correct renderer for the output type. * * @return the renderer based on the configured output - * @throws org.apache.maven.reporting.MavenReportException - * if no renderer found for the output type + * @throws org.apache.maven.reporting.MavenReportException if no renderer found for the output type */ public final Renderer createRenderer() throws MavenReportException @@ -614,27 +610,27 @@ public class PmdReport } else if ( "txt".equals( format ) ) { - renderer = new TextRenderer( ); + renderer = new TextRenderer(); } else if ( "csv".equals( format ) ) { - renderer = new CSVRenderer( ); + renderer = new CSVRenderer(); } else if ( "html".equals( format ) ) { - renderer = new HTMLRenderer( ); + renderer = new HTMLRenderer(); } else if ( !"".equals( format ) && !"none".equals( format ) ) { 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 ) { - throw new MavenReportException( - "Can't find PMD custom format " + format + ": " + e.getClass().getName(), e ); + throw new MavenReportException( "Can't find PMD custom format " + format + ": " + + e.getClass().getName(), e ); } } Modified: maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdReportGenerator.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdReportGenerator.java?rev=1653350&r1=1653349&r2=1653350&view=diff ============================================================================== --- maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdReportGenerator.java (original) +++ maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdReportGenerator.java Tue Jan 20 19:54:03 2015 @@ -61,7 +61,7 @@ public class PmdReportGenerator private Map<File, PmdFileInfo> files; -// private List<Metric> metrics = new ArrayList<Metric>(); + // private List<Metric> metrics = new ArrayList<Metric>(); public PmdReportGenerator( Log log, Sink sink, ResourceBundle bundle, boolean aggregate ) { @@ -86,15 +86,15 @@ public class PmdReportGenerator return new ArrayList<RuleViolation>( violations ); } -// public List<Metric> getMetrics() -// { -// return metrics; -// } -// -// public void setMetrics( List<Metric> metrics ) -// { -// this.metrics = metrics; -// } + // public List<Metric> getMetrics() + // { + // return metrics; + // } + // + // public void setMetrics( List<Metric> metrics ) + // { + // this.metrics = metrics; + // } private void startFileSection( String currentFilename, PmdFileInfo fileInfo ) { @@ -191,7 +191,7 @@ public class PmdReportGenerator if ( fileInfo == null ) { log.warn( "Couldn't determine PmdFileInfo for file " + currentFn + " (canonical: " + canonicalFilename - + "). XRef links won't be available." ); + + "). XRef links won't be available." ); } if ( !currentFn.equalsIgnoreCase( previousFilename ) && fileSectionStarted ) @@ -270,62 +270,19 @@ public class PmdReportGenerator // TODO files summary } -/* - private void processMetrics() - { - if ( metrics.size() == 0 ) - { - return; - } - - sink.section1(); - sink.sectionTitle1(); - sink.text( "Metrics" ); - sink.sectionTitle1_(); - - sink.table(); - sink.tableRow(); - sink.tableHeaderCell(); - sink.text( "Name" ); - sink.tableHeaderCell_(); - sink.tableHeaderCell(); - sink.text( "Count" ); - sink.tableHeaderCell_(); - sink.tableHeaderCell(); - sink.text( "High" ); - sink.tableHeaderCell_(); - sink.tableHeaderCell(); - sink.text( "Low" ); - sink.tableHeaderCell_(); - sink.tableHeaderCell(); - sink.text( "Average" ); - sink.tableHeaderCell_(); - sink.tableRow_(); - - for ( Metric met : metrics ) - { - sink.tableRow(); - sink.tableCell(); - sink.text( met.getMetricName() ); - sink.tableCell_(); - sink.tableCell(); - sink.text( String.valueOf( met.getCount() ) ); - sink.tableCell_(); - sink.tableCell(); - sink.text( String.valueOf( met.getHighValue() ) ); - sink.tableCell_(); - sink.tableCell(); - sink.text( String.valueOf( met.getLowValue() ) ); - sink.tableCell_(); - sink.tableCell(); - sink.text( String.valueOf( met.getAverage() ) ); - sink.tableCell_(); - sink.tableRow_(); - } - sink.table_(); - sink.section1_(); - } -*/ + /* + * private void processMetrics() { if ( metrics.size() == 0 ) { return; } sink.section1(); sink.sectionTitle1(); + * sink.text( "Metrics" ); sink.sectionTitle1_(); sink.table(); sink.tableRow(); sink.tableHeaderCell(); sink.text( + * "Name" ); sink.tableHeaderCell_(); sink.tableHeaderCell(); sink.text( "Count" ); sink.tableHeaderCell_(); + * sink.tableHeaderCell(); sink.text( "High" ); sink.tableHeaderCell_(); sink.tableHeaderCell(); sink.text( "Low" ); + * sink.tableHeaderCell_(); sink.tableHeaderCell(); sink.text( "Average" ); sink.tableHeaderCell_(); + * sink.tableRow_(); for ( Metric met : metrics ) { sink.tableRow(); sink.tableCell(); sink.text( + * met.getMetricName() ); sink.tableCell_(); sink.tableCell(); sink.text( String.valueOf( met.getCount() ) ); + * sink.tableCell_(); sink.tableCell(); sink.text( String.valueOf( met.getHighValue() ) ); sink.tableCell_(); + * sink.tableCell(); sink.text( String.valueOf( met.getLowValue() ) ); sink.tableCell_(); sink.tableCell(); + * sink.text( String.valueOf( met.getAverage() ) ); sink.tableCell_(); sink.tableRow_(); } sink.table_(); + * sink.section1_(); } + */ public void render() throws IOException @@ -350,7 +307,7 @@ public class PmdReportGenerator // of excessive imports metrics, none of which is really any use. // TODO Determine if we are going to just ignore metrics. -// processMetrics(); + // processMetrics(); sink.body_(); 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=1653350&r1=1653349&r2=1653350&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 Tue Jan 20 19:54:03 2015 @@ -36,7 +36,7 @@ public class PmdReportListener { private HashSet<RuleViolation> violations = new HashSet<RuleViolation>(); -// private List<Metric> metrics = new ArrayList<Metric>(); + // private List<Metric> metrics = new ArrayList<Metric>(); /** * {@inheritDoc} @@ -74,10 +74,10 @@ public class PmdReportListener */ public void metricAdded( Metric metric ) { -// if ( metric.getCount() != 0 ) -// { -// // Skip metrics which have no data -// metrics.add( metric ); -// } + // if ( metric.getCount() != 0 ) + // { + // // Skip metrics which have no data + // metrics.add( metric ); + // } } } \ 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=1653350&r1=1653349&r2=1653350&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 Tue Jan 20 19:54:03 2015 @@ -19,6 +19,19 @@ package org.apache.maven.plugin.pmd; * under the License. */ +import java.io.File; +import java.io.FileInputStream; +import java.io.FileReader; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Properties; +import java.util.Set; + import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugin.pmd.model.PmdErrorDetail; @@ -33,19 +46,6 @@ import org.codehaus.plexus.util.IOUtil; import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileReader; -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Properties; -import java.util.Set; - /** * Fail the build if there were any PMD violations in the source code. * @@ -58,17 +58,15 @@ public class PmdViolationCheckMojo extends AbstractPmdViolationCheckMojo<Violation> { /** - * What priority level to fail the build on. Failures at or above this level - * will stop the build. Anything below will be warnings and will be - * displayed in the build output if verbose=true. Note: Minimum Priority = 5 - * Maximum Priority = 0 + * What priority level to fail the build on. Failures at or above this level will stop the build. Anything below + * will be warnings and will be displayed in the build output if verbose=true. Note: Minimum Priority = 5 Maximum + * Priority = 0 */ @Parameter( property = "pmd.failurePriority", defaultValue = "5", required = true ) private int failurePriority; /** - * Skip the PMD checks. Most useful on the command line - * via "-Dpmd.skip=true". + * Skip the PMD checks. Most useful on the command line via "-Dpmd.skip=true". */ @Parameter( property = "pmd.skip", defaultValue = "false" ) private boolean skip; @@ -134,7 +132,7 @@ public class PmdViolationCheckMojo private String extractClassName( final Violation errorDetail ) { - //for some reason, some violations don't contain the package name, so we have to guess the full class name + // for some reason, some violations don't contain the package name, so we have to guess the full class name if ( errorDetail.getViolationPackage() != null && errorDetail.getViolationClass() != null ) { return errorDetail.getViolationPackage() + "." + errorDetail.getViolationClass(); Modified: maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/rules/DummyRule.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/rules/DummyRule.java?rev=1653350&r1=1653349&r2=1653350&view=diff ============================================================================== --- maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/rules/DummyRule.java (original) +++ maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/rules/DummyRule.java Tue Jan 20 19:54:03 2015 @@ -26,10 +26,10 @@ import net.sourceforge.pmd.lang.ast.Node import net.sourceforge.pmd.lang.rule.AbstractRule; /** - * A dummy rule that does nothing. Referenced from the Dummy ruleset - * to work around pmd bug #1155. + * A dummy rule that does nothing. Referenced from the Dummy ruleset to work around pmd bug #1155. */ -public class DummyRule extends AbstractRule +public class DummyRule + extends AbstractRule { public void apply( List<? extends Node> nodes, RuleContext ctx ) { Modified: maven/plugins/trunk/maven-pmd-plugin/src/main/resources/rulesets/maven.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/main/resources/rulesets/maven.xml?rev=1653350&r1=1653349&r2=1653350&view=diff ============================================================================== --- maven/plugins/trunk/maven-pmd-plugin/src/main/resources/rulesets/maven.xml (original) +++ maven/plugins/trunk/maven-pmd-plugin/src/main/resources/rulesets/maven.xml Tue Jan 20 19:54:03 2015 @@ -22,16 +22,16 @@ under the License. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd" xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd"> - - <!-- - Customized PMD ruleset for Maven, see [0] for more information + + <!-- + Customized PMD ruleset for Maven, see [0] for more information [0] http://pmd.sourceforge.net/howtomakearuleset.html --> - + <description> This ruleset checks the code for discouraged programming constructs. </description> - + <rule ref="rulesets/java/basic.xml"> <exclude name="EmptyCatchBlock"/> </rule> Modified: maven/plugins/trunk/maven-pmd-plugin/src/test/java/org/apache/maven/plugin/pmd/AbstractPmdReportTest.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/test/java/org/apache/maven/plugin/pmd/AbstractPmdReportTest.java?rev=1653350&r1=1653349&r2=1653350&view=diff ============================================================================== --- maven/plugins/trunk/maven-pmd-plugin/src/test/java/org/apache/maven/plugin/pmd/AbstractPmdReportTest.java (original) +++ maven/plugins/trunk/maven-pmd-plugin/src/test/java/org/apache/maven/plugin/pmd/AbstractPmdReportTest.java Tue Jan 20 19:54:03 2015 @@ -62,8 +62,7 @@ public abstract class AbstractPmdReportT outputHtml.getParentFile().mkdirs(); writer = WriterFactory.newXmlWriter( outputHtml ); - mojo.getSiteRenderer().generateDocument( writer, (SiteRendererSink) mojo.getSink(), - context ); + mojo.getSiteRenderer().generateDocument( writer, (SiteRendererSink) mojo.getSink(), context ); } finally { 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=1653350&r1=1653349&r2=1653350&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 Tue Jan 20 19:54:03 2015 @@ -19,16 +19,6 @@ package org.apache.maven.plugin.pmd; * under the License. */ -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; @@ -37,6 +27,18 @@ 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; + /** * @author <a href="mailto:och...@apache.org">Maria Odea Ching</a> * @version $Id$ @@ -63,8 +65,9 @@ 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(); @@ -77,18 +80,17 @@ public class CpdReportTest assertTrue( FileUtils.fileExists( generatedFile.getAbsolutePath() ) ); // check the contents of cpd.html - String str = - readFile( new File( getBasedir(), "target/test/unit/default-configuration/target/site/cpd.html" ) ); - assertTrue(str.toLowerCase().contains("AppSample.java".toLowerCase())); + String str = readFile( new File( getBasedir(), "target/test/unit/default-configuration/target/site/cpd.html" ) ); + assertTrue( str.toLowerCase().contains( "AppSample.java".toLowerCase() ) ); str = readFile( new File( getBasedir(), "target/test/unit/default-configuration/target/site/cpd.html" ) ); - assertTrue(str.toLowerCase().contains("App.java".toLowerCase())); + assertTrue( str.toLowerCase().contains( "App.java".toLowerCase() ) ); str = readFile( new File( getBasedir(), "target/test/unit/default-configuration/target/site/cpd.html" ) ); - assertTrue(str.toLowerCase().contains("public String dup( String str )".toLowerCase())); + assertTrue( str.toLowerCase().contains( "public String dup( String str )".toLowerCase() ) ); str = readFile( new File( getBasedir(), "target/test/unit/default-configuration/target/site/cpd.html" ) ); - assertTrue(str.toLowerCase().contains("tmp = tmp + str.substring( i, i + 1);".toLowerCase())); + assertTrue( str.toLowerCase().contains( "tmp = tmp + str.substring( i, i + 1);".toLowerCase() ) ); } @@ -100,8 +102,9 @@ 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,20 +118,20 @@ public class CpdReportTest // Contents that should NOT be in the report String str = readFile( new File( getBasedir(), "target/test/unit/custom-configuration/target/site/cpd.html" ) ); - assertTrue(!str.toLowerCase().contains("/Sample.java".toLowerCase())); + assertTrue( !str.toLowerCase().contains( "/Sample.java".toLowerCase() ) ); str = readFile( new File( getBasedir(), "target/test/unit/custom-configuration/target/site/cpd.html" ) ); - assertTrue(!str.toLowerCase().contains("public void duplicateMethod( int i )".toLowerCase())); + assertTrue( !str.toLowerCase().contains( "public void duplicateMethod( int i )".toLowerCase() ) ); // Contents that should be in the report str = readFile( new File( getBasedir(), "target/test/unit/custom-configuration/target/site/cpd.html" ) ); - assertTrue(str.toLowerCase().contains("AnotherSample.java".toLowerCase())); + assertTrue( str.toLowerCase().contains( "AnotherSample.java".toLowerCase() ) ); str = readFile( new File( getBasedir(), "target/test/unit/custom-configuration/target/site/cpd.html" ) ); - assertTrue(str.toLowerCase().contains("public static void main( String[] args )".toLowerCase())); + assertTrue( str.toLowerCase().contains( "public static void main( String[] args )".toLowerCase() ) ); str = readFile( new File( getBasedir(), "target/test/unit/custom-configuration/target/site/cpd.html" ) ); - assertTrue(str.toLowerCase().contains("private String unusedMethod(".toLowerCase())); + assertTrue( str.toLowerCase().contains( "private String unusedMethod(".toLowerCase() ) ); } @@ -184,8 +187,9 @@ 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 ); @@ -214,9 +218,10 @@ public class CpdReportTest } public void testSkipEmptyReportConfiguration() - throws Exception + throws Exception { - File testPom = new File( getBasedir(), "src/test/resources/unit/empty-report/cpd-skip-empty-report-plugin-config.xml" ); + File testPom = + new File( getBasedir(), "src/test/resources/unit/empty-report/cpd-skip-empty-report-plugin-config.xml" ); CpdReport mojo = (CpdReport) lookupMojo( "cpd", testPom ); mojo.execute(); @@ -226,9 +231,10 @@ public class CpdReportTest } public void testEmptyReportConfiguration() - throws Exception + throws Exception { - File testPom = new File( getBasedir(), "src/test/resources/unit/empty-report/cpd-empty-report-plugin-config.xml" ); + File testPom = + new File( getBasedir(), "src/test/resources/unit/empty-report/cpd-empty-report-plugin-config.xml" ); CpdReport mojo = (CpdReport) lookupMojo( "cpd", testPom ); mojo.execute(); @@ -236,19 +242,20 @@ public class CpdReportTest File generatedFile = new File( getBasedir(), "target/test/unit/empty-report/target/site/cpd.html" ); assertTrue( FileUtils.fileExists( generatedFile.getAbsolutePath() ) ); String str = readFile( new File( getBasedir(), "target/test/unit/empty-report/target/site/cpd.html" ) ); - assertTrue(!str.toLowerCase().contains("Hello.java".toLowerCase())); + assertTrue( !str.toLowerCase().contains( "Hello.java".toLowerCase() ) ); } public void testCpdEncodingConfiguration() - throws Exception + throws Exception { String originalEncoding = System.getProperty( "file.encoding" ); try { System.setProperty( "file.encoding", "UTF-16" ); - 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(); @@ -256,7 +263,7 @@ public class CpdReportTest File generatedFile = new File( getBasedir(), "target/test/unit/default-configuration/target/cpd.xml" ); assertTrue( FileUtils.fileExists( generatedFile.getAbsolutePath() ) ); String str = readFile( generatedFile ); - assertTrue(str.toLowerCase().contains("AppSample.java".toLowerCase())); + assertTrue( str.toLowerCase().contains( "AppSample.java".toLowerCase() ) ); } finally { Modified: maven/plugins/trunk/maven-pmd-plugin/src/test/java/org/apache/maven/plugin/pmd/CpdViolationCheckMojoTest.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/test/java/org/apache/maven/plugin/pmd/CpdViolationCheckMojoTest.java?rev=1653350&r1=1653349&r2=1653350&view=diff ============================================================================== --- maven/plugins/trunk/maven-pmd-plugin/src/test/java/org/apache/maven/plugin/pmd/CpdViolationCheckMojoTest.java (original) +++ maven/plugins/trunk/maven-pmd-plugin/src/test/java/org/apache/maven/plugin/pmd/CpdViolationCheckMojoTest.java Tue Jan 20 19:54:03 2015 @@ -19,10 +19,9 @@ package org.apache.maven.plugin.pmd; * under the License. */ -import org.apache.maven.plugin.testing.AbstractMojoTestCase; - import java.io.File; +import org.apache.maven.plugin.testing.AbstractMojoTestCase; /** * @author <a href="mailto:och...@apache.org">Maria Odea Ching</a> @@ -44,8 +43,9 @@ public class CpdViolationCheckMojoTest { try { - final File testPom = new File( getBasedir(), - "src/test/resources/unit/default-configuration/pmd-check-default-configuration-plugin-config.xml" ); + final File testPom = + new File( getBasedir(), + "src/test/resources/unit/default-configuration/pmd-check-default-configuration-plugin-config.xml" ); final CpdViolationCheckMojo mojo = (CpdViolationCheckMojo) lookupMojo( "cpd-check", testPom ); mojo.execute(); @@ -61,13 +61,15 @@ public class CpdViolationCheckMojoTest 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" ); final CpdReport mojo = (CpdReport) lookupMojo( "cpd", testPom ); mojo.execute(); - testPom = new File( getBasedir(), - "src/test/resources/unit/default-configuration/pmd-check-notfailonviolation-plugin-config.xml" ); + testPom = + new File( getBasedir(), + "src/test/resources/unit/default-configuration/pmd-check-notfailonviolation-plugin-config.xml" ); final CpdViolationCheckMojo cpdViolationMojo = (CpdViolationCheckMojo) lookupMojo( "cpd-check", testPom ); cpdViolationMojo.execute(); @@ -79,8 +81,9 @@ public class CpdViolationCheckMojoTest { try { - final File testPom = new File( getBasedir(), - "src/test/resources/unit/custom-configuration/pmd-check-exception-test-plugin-config.xml" ); + final File testPom = + new File( getBasedir(), + "src/test/resources/unit/custom-configuration/pmd-check-exception-test-plugin-config.xml" ); final CpdViolationCheckMojo mojo = (CpdViolationCheckMojo) lookupMojo( "cpd-check", testPom ); mojo.execute(); @@ -95,16 +98,18 @@ public class CpdViolationCheckMojoTest public void testExclusionsConfiguration() 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" ); final CpdReport mojo = (CpdReport) lookupMojo( "cpd", testPom ); mojo.execute(); - testPom = new File( getBasedir(), - "src/test/resources/unit/default-configuration/pmd-check-cpd-exclusions-configuration-plugin-config.xml" ); + testPom = + new File( getBasedir(), + "src/test/resources/unit/default-configuration/pmd-check-cpd-exclusions-configuration-plugin-config.xml" ); final CpdViolationCheckMojo cpdViolationMojo = (CpdViolationCheckMojo) lookupMojo( "cpd-check", testPom ); cpdViolationMojo.execute(); assertTrue( true ); - } + } } 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=1653350&r1=1653349&r2=1653350&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 Tue Jan 20 19:54:03 2015 @@ -54,16 +54,17 @@ public class PmdReportTest public void testDefaultConfiguration() throws Exception { - FileUtils.copyDirectoryStructure( - new File( getBasedir(), "src/test/resources/unit/default-configuration/jxr-files" ), - new File( getBasedir(), "target/test/unit/default-configuration/target/site" ) ); - - File testPom = new File( getBasedir(), - "src/test/resources/unit/default-configuration/default-configuration-plugin-config.xml" ); + FileUtils.copyDirectoryStructure( new File( getBasedir(), + "src/test/resources/unit/default-configuration/jxr-files" ), + new File( getBasedir(), "target/test/unit/default-configuration/target/site" ) ); + + File testPom = + new File( getBasedir(), + "src/test/resources/unit/default-configuration/default-configuration-plugin-config.xml" ); PmdReport mojo = (PmdReport) lookupMojo( "pmd", testPom ); mojo.execute(); - //check if the PMD files were generated + // check if the PMD files were generated File generatedFile = new File( getBasedir(), "target/test/unit/default-configuration/target/pmd.xml" ); assertTrue( FileUtils.fileExists( generatedFile.getAbsolutePath() ) ); @@ -81,21 +82,20 @@ public class PmdReportTest renderer( mojo, generatedFile ); assertTrue( FileUtils.fileExists( generatedFile.getAbsolutePath() ) ); - //check if there's a link to the JXR files - String str = - readFile( new File( getBasedir(), "target/test/unit/default-configuration/target/site/pmd.html" ) ); + // check if there's a link to the JXR files + String str = readFile( new File( getBasedir(), "target/test/unit/default-configuration/target/site/pmd.html" ) ); - assertTrue(str.contains("/xref/def/configuration/App.html#L31")); + assertTrue( str.contains( "/xref/def/configuration/App.html#L31" ) ); - assertTrue(str.contains("/xref/def/configuration/AppSample.html#L45")); + assertTrue( str.contains( "/xref/def/configuration/AppSample.html#L45" ) ); } - public void testJavascriptConfiguration() throws Exception { - File testPom = new File( getBasedir(), - "src/test/resources/unit/default-configuration/javascript-configuration-plugin-config.xml" ); + File testPom = + new File( getBasedir(), + "src/test/resources/unit/default-configuration/javascript-configuration-plugin-config.xml" ); PmdReport mojo = (PmdReport) lookupMojo( "pmd", testPom ); mojo.execute(); @@ -119,56 +119,49 @@ public class PmdReportTest assertTrue( FileUtils.fileExists( generatedFile.getAbsolutePath() ) ); String str = readFile( generatedFile ); - assertTrue(str.contains("Avoid using global variables")); + assertTrue( str.contains( "Avoid using global variables" ) ); } public void testFileURL() throws Exception { - FileUtils.copyDirectoryStructure( - new File( getBasedir(), "src/test/resources/unit/default-configuration/jxr-files" ), - new File( getBasedir(), "target/test/unit/default-configuration/target/site" ) ); - - File testPom = new File( getBasedir(), - "src/test/resources/unit/default-configuration/default-configuration-plugin-config.xml" ); + FileUtils.copyDirectoryStructure( new File( getBasedir(), + "src/test/resources/unit/default-configuration/jxr-files" ), + new File( getBasedir(), "target/test/unit/default-configuration/target/site" ) ); + + File testPom = + new File( getBasedir(), + "src/test/resources/unit/default-configuration/default-configuration-plugin-config.xml" ); PmdReport mojo = (PmdReport) lookupMojo( "pmd", testPom ); // Additional test case for MPMD-174 (http://jira.codehaus.org/browse/MPMD-174). WireMockServer mockServer = new WireMockServer( 3456 ); mockServer.start(); - String sonarRuleset = IOUtils.toString( - getClass().getClassLoader().getResourceAsStream( - "unit/default-configuration/rulesets/sonar-way-ruleset.xml" ) ); - - String sonarMainPageHtml = IOUtils.toString( - getClass().getClassLoader().getResourceAsStream( - "unit/default-configuration/rulesets/sonar-main-page.html" ) ); + String sonarRuleset = + IOUtils.toString( getClass().getClassLoader().getResourceAsStream( "unit/default-configuration/rulesets/sonar-way-ruleset.xml" ) ); + + String sonarMainPageHtml = + IOUtils.toString( getClass().getClassLoader().getResourceAsStream( "unit/default-configuration/rulesets/sonar-main-page.html" ) ); final String sonarBaseUrl = "/profiles"; final String sonarProfileUrl = sonarBaseUrl + "/export?format=pmd&language=java&name=Sonar%2520way"; final String sonarExportRulesetUrl = "http://localhost:" + mockServer.port() + sonarProfileUrl; - mockServer.stubFor(WireMock.get( WireMock.urlEqualTo( sonarBaseUrl ) ) - .willReturn( WireMock.aResponse() - .withStatus( 200 ) - .withHeader( "Content-Type", "text/html" ) - .withBody( sonarMainPageHtml ) ) ); - - mockServer.stubFor( WireMock.get( WireMock.urlEqualTo( sonarProfileUrl ) ) - .willReturn( WireMock.aResponse() - .withStatus( 200 ) - .withHeader( "Content-Type", "text/xml" ) - .withBody( sonarRuleset ) ) ); + mockServer.stubFor( WireMock.get( WireMock.urlEqualTo( sonarBaseUrl ) ).willReturn( WireMock.aResponse().withStatus( 200 ).withHeader( "Content-Type", + "text/html" ).withBody( sonarMainPageHtml ) ) ); + + mockServer.stubFor( WireMock.get( WireMock.urlEqualTo( sonarProfileUrl ) ).willReturn( WireMock.aResponse().withStatus( 200 ).withHeader( "Content-Type", + "text/xml" ).withBody( sonarRuleset ) ) ); URL url = getClass().getClassLoader().getResource( "rulesets/java/basic.xml" ); URL url2 = getClass().getClassLoader().getResource( "rulesets/java/unusedcode.xml" ); URL url3 = getClass().getClassLoader().getResource( "rulesets/java/imports.xml" ); - mojo.setRulesets( new String[]{ url.toString(), url2.toString(), url3.toString(), sonarExportRulesetUrl } ); + mojo.setRulesets( new String[] { url.toString(), url2.toString(), url3.toString(), sonarExportRulesetUrl } ); mojo.execute(); - //check if the PMD files were generated + // check if the PMD files were generated File generatedFile = new File( getBasedir(), "target/test/unit/default-configuration/target/pmd.xml" ); assertTrue( FileUtils.fileExists( generatedFile.getAbsolutePath() ) ); @@ -181,21 +174,21 @@ public class PmdReportTest generatedFile = new File( getBasedir(), "target/test/unit/default-configuration/target/unusedcode.xml" ); assertTrue( FileUtils.fileExists( generatedFile.getAbsolutePath() ) ); - generatedFile = new File( getBasedir(), - "target/test/unit/default-configuration/target/export_format_pmd_language_java_name_Sonar_2520way.xml" ); + generatedFile = + new File( getBasedir(), + "target/test/unit/default-configuration/target/export_format_pmd_language_java_name_Sonar_2520way.xml" ); assertTrue( FileUtils.fileExists( generatedFile.getAbsolutePath() ) ); generatedFile = new File( getBasedir(), "target/test/unit/default-configuration/target/site/pmd.html" ); renderer( mojo, generatedFile ); assertTrue( FileUtils.fileExists( generatedFile.getAbsolutePath() ) ); - //check if there's a link to the JXR files - String str = - readFile( new File( getBasedir(), "target/test/unit/default-configuration/target/site/pmd.html" ) ); + // check if there's a link to the JXR files + String str = readFile( new File( getBasedir(), "target/test/unit/default-configuration/target/site/pmd.html" ) ); - assertTrue(str.contains("/xref/def/configuration/App.html#L31")); + assertTrue( str.contains( "/xref/def/configuration/App.html#L31" ) ); - assertTrue(str.contains("/xref/def/configuration/AppSample.html#L45")); + assertTrue( str.contains( "/xref/def/configuration/AppSample.html#L45" ) ); mockServer.stop(); } @@ -208,13 +201,14 @@ public class PmdReportTest public void testCustomConfiguration() throws Exception { - File testPom = new File( getBasedir(), - "src/test/resources/unit/custom-configuration/custom-configuration-plugin-config.xml" ); + File testPom = + new File( getBasedir(), + "src/test/resources/unit/custom-configuration/custom-configuration-plugin-config.xml" ); PmdReport mojo = (PmdReport) lookupMojo( "pmd", testPom ); mojo.execute(); - //check the generated files + // check the generated files File generatedFile = new File( getBasedir(), "target/test/unit/custom-configuration/target/pmd.csv" ); assertTrue( FileUtils.fileExists( generatedFile.getAbsolutePath() ) ); @@ -226,16 +220,15 @@ public class PmdReportTest renderer( mojo, generatedFile ); assertTrue( FileUtils.fileExists( generatedFile.getAbsolutePath() ) ); - //check if custom ruleset was applied + // check if custom ruleset was applied String str = readFile( new File( getBasedir(), "target/test/unit/custom-configuration/target/site/pmd.html" ) ); - assertTrue(str.toLowerCase().contains("Avoid using if statements without curly braces".toLowerCase())); + assertTrue( str.toLowerCase().contains( "Avoid using if statements without curly braces".toLowerCase() ) ); // Must be false as IfElseStmtsMustUseBraces is excluded! - assertFalse( - str.toLowerCase().contains("Avoid using if...else statements without curly braces".toLowerCase())); + assertFalse( str.toLowerCase().contains( "Avoid using if...else statements without curly braces".toLowerCase() ) ); assertTrue( "unnecessary constructor should not be triggered because of low priority", - !str.toLowerCase().contains("Avoid unnecessary constructors - the compiler will generate these for you".toLowerCase())); + !str.toLowerCase().contains( "Avoid unnecessary constructors - the compiler will generate these for you".toLowerCase() ) ); // veryLongVariableNameWithViolation is really too long assertTrue( str.toLowerCase().contains( "veryLongVariableNameWithViolation".toLowerCase() ) ); @@ -269,7 +262,8 @@ public class PmdReportTest public void testSkipEmptyReportConfiguration() throws Exception { - File testPom = new File( getBasedir(), "src/test/resources/unit/empty-report/skip-empty-report-plugin-config.xml" ); + File testPom = + new File( getBasedir(), "src/test/resources/unit/empty-report/skip-empty-report-plugin-config.xml" ); PmdReport mojo = (PmdReport) lookupMojo( "pmd", testPom ); mojo.execute(); @@ -279,7 +273,7 @@ public class PmdReportTest } public void testEmptyReportConfiguration() - throws Exception + throws Exception { File testPom = new File( getBasedir(), "src/test/resources/unit/empty-report/empty-report-plugin-config.xml" ); PmdReport mojo = (PmdReport) lookupMojo( "pmd", testPom ); @@ -289,7 +283,7 @@ public class PmdReportTest File generatedFile = new File( getBasedir(), "target/test/unit/empty-report/target/site/pmd.html" ); assertTrue( FileUtils.fileExists( generatedFile.getAbsolutePath() ) ); String str = readFile( new File( getBasedir(), "target/test/unit/empty-report/target/site/pmd.html" ) ); - assertTrue(!str.toLowerCase().contains("Hello.java".toLowerCase())); + assertTrue( !str.toLowerCase().contains( "Hello.java".toLowerCase() ) ); } public void testInvalidFormat() @@ -329,7 +323,6 @@ public class PmdReportTest } } - /** * Read the contents of the specified file object into a string * @@ -374,13 +367,14 @@ public class PmdReportTest throws Exception { - File testPom = new File( getBasedir(), - "src/test/resources/unit/default-configuration/default-configuration-plugin-config.xml" ); + 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.xml", mojo.getLocationTemp( - "http://nemo.sonarsource.org/sonar/profiles/export?format=pmd&language=java&name=some%2520name" ) ); + "export_format_pmd_language_java_name_some_2520name.xml", + mojo.getLocationTemp( "http://nemo.sonarsource.org/sonar/profiles/export?format=pmd&language=java&name=some%2520name" ) ); } @@ -390,22 +384,22 @@ public class PmdReportTest * @throws Exception */ public void testSuppressMarkerConfiguration() - throws Exception - { - File testPom = new File( getBasedir(), - "src/test/resources/unit/default-configuration/pmd-with-suppressMarker-plugin-config.xml" ); - PmdReport mojo = (PmdReport) lookupMojo( "pmd", testPom ); - mojo.execute(); + throws Exception + { + File testPom = + new File( getBasedir(), + "src/test/resources/unit/default-configuration/pmd-with-suppressMarker-plugin-config.xml" ); + PmdReport mojo = (PmdReport) lookupMojo( "pmd", testPom ); + mojo.execute(); - //check if the PMD files were generated - File generatedFile = new File( getBasedir(), "target/test/unit/default-configuration/target/pmd.xml" ); - assertTrue( FileUtils.fileExists( generatedFile.getAbsolutePath() ) ); + // check if the PMD files were generated + File generatedFile = new File( getBasedir(), "target/test/unit/default-configuration/target/pmd.xml" ); + assertTrue( FileUtils.fileExists( generatedFile.getAbsolutePath() ) ); - String str = - readFile( new File( getBasedir(), "target/test/unit/default-configuration/target/pmd.xml" ) ); + String str = readFile( new File( getBasedir(), "target/test/unit/default-configuration/target/pmd.xml" ) ); - //check that there is no violation reported for "unusedVar2" - as it is suppressed - assertFalse(str.contains("Avoid unused private fields such as 'unusedVar2'.")); - } + // check that there is no violation reported for "unusedVar2" - as it is suppressed + assertFalse( str.contains( "Avoid unused private fields such as 'unusedVar2'." ) ); + } }