From 9bec8d7386156bd7b56b8261ecd51e903d55673e Mon Sep 17 00:00:00 2001 From: Stephen Connolly Date: Mon, 6 Jan 2014 10:42:20 +0000 Subject: [PATCH] Use chained .append calls rather than concatenate strings in arguments to .append --- .../AbstractArtifactResolutionException.java | 5 +++-- .../project/validation/ModelValidationResult.java | 3 ++- .../repository/metadata/ClasspathContainer.java | 4 ++-- .../maven/repository/metadata/MetadataGraph.java | 6 +++--- .../repository/metadata/MetadataGraphVertex.java | 8 ++++---- .../maven/plugin/PluginParameterException.java | 4 ++-- .../org/apache/maven/cli/CLIReportingUtils.java | 15 ++++++++------- .../java/org/apache/maven/cli/CLIManagerTest.java | 2 +- 8 files changed, 25 insertions(+), 22 deletions(-) diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/AbstractArtifactResolutionException.java b/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/AbstractArtifactResolutionException.java index 9cfc36b287..393e02833b 100644 --- a/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/AbstractArtifactResolutionException.java +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/AbstractArtifactResolutionException.java @@ -199,13 +199,14 @@ public class AbstractArtifactResolutionException if ( message == null || !message.contains( "from the specified remote repositories:" ) ) { sb.append( LS ); - sb.append( " " + groupId + ":" + artifactId + ":" + type + ":" + version ); + sb.append( " " ).append( groupId ).append( ":" ).append( artifactId ).append( ":" ).append( type ).append( + ":" ).append( version ); sb.append( LS ); if ( remoteRepositories != null ) { sb.append( LS ); sb.append( "from the specified remote repositories:" ); - sb.append( LS + " " ); + sb.append( LS ).append( " " ); if ( remoteRepositories.isEmpty() ) { diff --git a/maven-compat/src/main/java/org/apache/maven/project/validation/ModelValidationResult.java b/maven-compat/src/main/java/org/apache/maven/project/validation/ModelValidationResult.java index 12ead7eae9..cb8c6012d6 100644 --- a/maven-compat/src/main/java/org/apache/maven/project/validation/ModelValidationResult.java +++ b/maven-compat/src/main/java/org/apache/maven/project/validation/ModelValidationResult.java @@ -85,7 +85,8 @@ public class ModelValidationResult // for ( int i = 0; i < messages.size(); i++ ) { - message.append( indentation + "[" + i + "] " + messages.get( i ) + NEWLINE ); + message.append( indentation ).append( "[" ).append( i ).append( "] " ).append( messages.get( i ) ).append( + NEWLINE ); } return message.toString(); diff --git a/maven-compat/src/main/java/org/apache/maven/repository/metadata/ClasspathContainer.java b/maven-compat/src/main/java/org/apache/maven/repository/metadata/ClasspathContainer.java index 593daac9c7..cdf28f675d 100644 --- a/maven-compat/src/main/java/org/apache/maven/repository/metadata/ClasspathContainer.java +++ b/maven-compat/src/main/java/org/apache/maven/repository/metadata/ClasspathContainer.java @@ -129,12 +129,12 @@ implements Iterable public String toString() { StringBuilder sb = new StringBuilder( 256 ); - sb.append( "[scope=" + scope.getScope() ); + sb.append( "[scope=" ).append( scope.getScope() ); if ( classpath != null ) { for ( ArtifactMetadata md : classpath ) { - sb.append( ": " + md.toString() + '{' + md.getArtifactUri() + '}' ); + sb.append( ": " ).append( md.toString() ).append( '{' ).append( md.getArtifactUri() ).append( '}' ); } } sb.append( ']' ); diff --git a/maven-compat/src/main/java/org/apache/maven/repository/metadata/MetadataGraph.java b/maven-compat/src/main/java/org/apache/maven/repository/metadata/MetadataGraph.java index b116c69f06..55b025048c 100644 --- a/maven-compat/src/main/java/org/apache/maven/repository/metadata/MetadataGraph.java +++ b/maven-compat/src/main/java/org/apache/maven/repository/metadata/MetadataGraph.java @@ -485,13 +485,13 @@ public class MetadataGraph } for ( MetadataGraphVertex v : vertices ) { - sb.append( "Vertex: " + v.getMd().toString() + "\n" ); + sb.append( "Vertex: " ).append( v.getMd().toString() ).append( "\n" ); List ins = getIncidentEdges( v ); if ( ins != null ) { for ( MetadataGraphEdge e : ins ) { - sb.append( " from : " + e.toString() + "\n" ); + sb.append( " from : " ).append( e.toString() ).append( "\n" ); } } else @@ -504,7 +504,7 @@ public class MetadataGraph { for ( MetadataGraphEdge e : outs ) { - sb.append( " to : " + e.toString() + "\n" ); + sb.append( " to : " ).append( e.toString() ).append( "\n" ); } } else diff --git a/maven-compat/src/main/java/org/apache/maven/repository/metadata/MetadataGraphVertex.java b/maven-compat/src/main/java/org/apache/maven/repository/metadata/MetadataGraphVertex.java index 87ff70bcd7..202a01f16d 100644 --- a/maven-compat/src/main/java/org/apache/maven/repository/metadata/MetadataGraphVertex.java +++ b/maven-compat/src/main/java/org/apache/maven/repository/metadata/MetadataGraphVertex.java @@ -192,17 +192,17 @@ public class MetadataGraphVertex return super.hashCode(); } StringBuilder hashString = new StringBuilder( 128 ); - hashString.append( md.groupId + "|" ); - hashString.append( md.artifactId + "|" ); + hashString.append( md.groupId ).append( "|" ); + hashString.append( md.artifactId ).append( "|" ); if ( compareVersion ) { - hashString.append( md.version + "|" ); + hashString.append( md.version ).append( "|" ); } if ( compareScope ) { - hashString.append( md.getArtifactScope() + "|" ); + hashString.append( md.getArtifactScope() ).append( "|" ); } return hashString.toString().hashCode(); diff --git a/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterException.java b/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterException.java index f14bfc0a37..dfdd4327f0 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterException.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterException.java @@ -144,8 +144,8 @@ public class PluginParameterException String alias = param.getAlias(); if ( StringUtils.isNotEmpty( alias ) && !alias.equals( param.getName() ) ) { - messageBuffer.append( - "\n\n-OR-\n\n\n ...\n <" + alias + ">VALUE\n\n" ); + messageBuffer.append( "\n\n-OR-\n\n\n ...\n <" ).append( alias ).append( + ">VALUE\n\n" ); } } diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/CLIReportingUtils.java b/maven-embedder/src/main/java/org/apache/maven/cli/CLIReportingUtils.java index 3b11aa09d9..3ce2c48b2f 100644 --- a/maven-embedder/src/main/java/org/apache/maven/cli/CLIReportingUtils.java +++ b/maven-embedder/src/main/java/org/apache/maven/cli/CLIReportingUtils.java @@ -55,13 +55,14 @@ public final class CLIReportingUtils version.append( createMavenVersionString( properties ) ).append( LS ); version.append( reduce( properties.getProperty( "distributionShortName" ) + " home: " + System.getProperty( "maven.home", "" ) ) ).append( LS ); - version.append( "Java version: " + System.getProperty( "java.version", "" ) - + ", vendor: " + System.getProperty( "java.vendor", "" ) ).append( LS ); - version.append( "Java home: " + System.getProperty( "java.home", "" ) ).append( LS ); - version.append( "Default locale: " + Locale.getDefault() + ", platform encoding: " - + System.getProperty( "file.encoding", "" ) ).append( LS ); - version.append( "OS name: \"" + Os.OS_NAME + "\", version: \"" + Os.OS_VERSION + "\", arch: \"" + Os.OS_ARCH - + "\", family: \"" + Os.OS_FAMILY + "\"" ); + version.append( "Java version: " ).append( + System.getProperty( "java.version", "" ) ).append( ", vendor: " ).append( + System.getProperty( "java.vendor", "" ) ).append( LS ); + version.append( "Java home: " ).append( System.getProperty( "java.home", "" ) ).append( LS ); + version.append( "Default locale: " ).append( Locale.getDefault() ).append( ", platform encoding: " ).append( + System.getProperty( "file.encoding", "" ) ).append( LS ); + version.append( "OS name: \"" ).append( Os.OS_NAME ).append( "\", version: \"" ).append( Os.OS_VERSION ).append( + "\", arch: \"" ).append( Os.OS_ARCH ).append( "\", family: \"" ).append( Os.OS_FAMILY ).append( "\"" ); return version.toString(); } diff --git a/maven-embedder/src/test/java/org/apache/maven/cli/CLIManagerTest.java b/maven-embedder/src/test/java/org/apache/maven/cli/CLIManagerTest.java index 716127b312..9df1768a11 100644 --- a/maven-embedder/src/test/java/org/apache/maven/cli/CLIManagerTest.java +++ b/maven-embedder/src/test/java/org/apache/maven/cli/CLIManagerTest.java @@ -70,7 +70,7 @@ public class CLIManagerTest for ( Option option : new CLIManagerExtension().getOptions() ) { a = !a; - sb.append( "--" ); sb.append( option.getOpt() );