You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by rf...@apache.org on 2013/02/15 22:54:28 UTC
svn commit: r1446786 - in
/maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help:
AbstractEffectiveMojo.java DescribeMojo.java EvaluateMojo.java HelpUtil.java
Author: rfscholte
Date: Fri Feb 15 21:54:28 2013
New Revision: 1446786
URL: http://svn.apache.org/r1446786
Log:
Optimizations detected by Sonar
Modified:
maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/AbstractEffectiveMojo.java
maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/DescribeMojo.java
maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/EvaluateMojo.java
maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/HelpUtil.java
Modified: maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/AbstractEffectiveMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/AbstractEffectiveMojo.java?rev=1446786&r1=1446785&r2=1446786&view=diff
==============================================================================
--- maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/AbstractEffectiveMojo.java (original)
+++ maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/AbstractEffectiveMojo.java Fri Feb 15 21:54:28 2013
@@ -26,13 +26,14 @@ import java.io.StringWriter;
import java.io.Writer;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.Iterator;
import java.util.LinkedHashSet;
+import java.util.List;
import java.util.Properties;
import java.util.Set;
-import java.util.Vector;
import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.StringUtils;
@@ -50,7 +51,7 @@ import org.jdom.output.XMLOutputter;
/**
* Base class with common utilities to write effective Pom/settings.
- *
+ *
* @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
* @version $Id$
* @since 2.1
@@ -66,7 +67,7 @@ public abstract class AbstractEffectiveM
/**
* Utility method to write an XML content in a given file.
- *
+ *
* @param output is the wanted output file.
* @param content contains the XML content to be written to the file.
* @param encoding is the wanted encoding to use when writing file.
@@ -106,17 +107,18 @@ public abstract class AbstractEffectiveM
/**
* Write comments in the Effective POM/settings header.
- *
+ *
* @param writer not null
*/
protected static void writeHeader( XMLWriter writer )
{
XmlWriterUtil.writeCommentLineBreak( writer );
XmlWriterUtil.writeComment( writer, " " );
- // Use ISO8601-format for date and time
- DateFormat dateFormat = new SimpleDateFormat( "yyyy-MM-dd'T'hh:mm:ss" );
- XmlWriterUtil.writeComment( writer, "Generated by Maven Help Plugin on "
- + dateFormat.format( new Date( System.currentTimeMillis() ) ) );
+ // Use ISO8601-format for date and time
+ DateFormat dateFormat = new SimpleDateFormat( "yyyy-MM-dd'T'hh:mm:ss" );
+ XmlWriterUtil.writeComment( writer,
+ "Generated by Maven Help Plugin on "
+ + dateFormat.format( new Date( System.currentTimeMillis() ) ) );
XmlWriterUtil.writeComment( writer, "See: http://maven.apache.org/plugins/maven-help-plugin/" );
XmlWriterUtil.writeComment( writer, " " );
XmlWriterUtil.writeCommentLineBreak( writer );
@@ -126,7 +128,7 @@ public abstract class AbstractEffectiveM
/**
* Write comments in a normalize way.
- *
+ *
* @param writer not null
* @param comment not null
*/
@@ -143,11 +145,11 @@ public abstract class AbstractEffectiveM
/**
* Add a Pom/Settings namespaces to the effective XML content.
- *
+ *
* @param effectiveXml not null the effective POM or Settings
* @param isPom if <code>true</code> add the Pom xsd url, otherwise add the settings xsd url.
- * @return the content of the root element, i.e. <project/> or <settings/> with the Maven namespace
- * or the original <code>effective</code> if an error occurred.
+ * @return the content of the root element, i.e. <project/> or <settings/> with the Maven namespace or
+ * the original <code>effective</code> if an error occurred.
* @see #POM_XSD_URL
* @see #SETTINGS_XSD_URL
*/
@@ -206,10 +208,11 @@ public abstract class AbstractEffectiveM
static final long serialVersionUID = -8985316072702233744L;
/** {@inheritDoc} */
+ @SuppressWarnings( { "rawtypes", "unchecked" } )
public Set<Object> keySet()
{
- Set<Object>keynames = super.keySet();
- Vector list = new Vector( keynames );
+ Set<Object> keynames = super.keySet();
+ List list = new ArrayList( keynames );
Collections.sort( list );
return new LinkedHashSet<Object>( list );
Modified: maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/DescribeMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/DescribeMojo.java?rev=1446786&r1=1446785&r2=1446786&view=diff
==============================================================================
--- maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/DescribeMojo.java (original)
+++ maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/DescribeMojo.java Fri Feb 15 21:54:28 2013
@@ -317,7 +317,7 @@ public class DescribeMojo
if ( !detail && session.getExecutionProperties().get( "full" ) != null )
{
String full = session.getExecutionProperties().getProperty( "full" );
- detail = new Boolean( full ).booleanValue();
+ detail = Boolean.valueOf( full );
}
if ( detail || minimal )
@@ -491,7 +491,7 @@ public class DescribeMojo
{
if ( StringUtils.isNotEmpty( plugin ) )
{
- if ( plugin.indexOf( ":" ) > -1 )
+ if ( plugin.indexOf( ':' ) > -1 )
{
String[] pluginParts = plugin.split( ":" );
@@ -819,7 +819,7 @@ public class DescribeMojo
private boolean describeCommand( StringBuilder descriptionBuffer )
throws MojoFailureException, MojoExecutionException
{
- if ( cmd.indexOf( ":" ) == -1 )
+ if ( cmd.indexOf( ':' ) == -1 )
{
// phase
try
Modified: maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/EvaluateMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/EvaluateMojo.java?rev=1446786&r1=1446785&r2=1446786&view=diff
==============================================================================
--- maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/EvaluateMojo.java (original)
+++ maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/EvaluateMojo.java Fri Feb 15 21:54:28 2013
@@ -493,9 +493,9 @@ public class EvaluateMojo
else
{
// try to detect the alias from question
- if ( expression.indexOf( "." ) != -1 )
+ if ( expression.indexOf( '.' ) != -1 )
{
- String name = expression.substring( expression.indexOf( "." ) + 1, expression.indexOf( "}" ) );
+ String name = expression.substring( expression.indexOf( '.' ) + 1, expression.indexOf( '}' ) );
currentXStream.alias( name, List.class );
}
}
@@ -616,7 +616,7 @@ public class EvaluateMojo
}
catch ( ClassNotFoundException e )
{
- e.printStackTrace();
+ getLog().error( e );
}
}
}
Modified: maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/HelpUtil.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/HelpUtil.java?rev=1446786&r1=1446785&r2=1446786&view=diff
==============================================================================
--- maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/HelpUtil.java (original)
+++ maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/HelpUtil.java Fri Feb 15 21:54:28 2013
@@ -44,6 +44,12 @@ import org.codehaus.plexus.component.rep
*/
public class HelpUtil
{
+
+ private HelpUtil()
+ {
+ // Utility classes should not have a public or default constructor.
+ }
+
/**
* Invoke the following private method <code>
* DefaultLifecycleExecutor#getMojoDescriptor(String, MavenSession, MavenProject, String, boolean, boolean)</code>