From 8d91726f7872f4462d9fa085ef5b6f32bfd0a2e1 Mon Sep 17 00:00:00 2001 From: Alex Henrie Date: Tue, 19 Jan 2016 20:04:59 +0100 Subject: [PATCH] [MNG-5934] String handling issues identified by PMD --- .../maven/artifact/DefaultArtifact.java | 12 +++++----- .../repository/ArtifactRepositoryPolicy.java | 2 +- .../AbstractArtifactResolutionException.java | 10 ++++----- .../MultipleArtifactsNotFoundException.java | 3 ++- .../versioning/DefaultArtifactVersion.java | 2 +- .../artifact/versioning/Restriction.java | 6 ++--- .../artifact/versioning/VersionRange.java | 6 ++--- .../apache/maven/building/DefaultProblem.java | 2 +- .../repository/DefaultArtifactRepository.java | 8 +++---- .../versioning/ManagedVersionMap.java | 4 ++-- .../validation/ModelValidationResult.java | 2 +- .../repository/MetadataResolutionResult.java | 22 +++++++++---------- .../repository/metadata/MetadataGraph.java | 6 ++--- .../metadata/MetadataGraphVertex.java | 8 +++---- .../project/LegacyLocalRepositoryManager.java | 2 +- .../AbstractProjectInheritanceTestCase.java | 2 +- .../repository/MavenArtifactRepository.java | 14 ++++++------ .../metadata/AbstractRepositoryMetadata.java | 2 +- .../resolver/ArtifactResolutionResult.java | 8 +++---- .../lifecycle/mapping/LifecyclePhase.java | 2 +- .../apache/maven/plugin/MojoExecution.java | 2 +- .../plugin/PluginParameterException.java | 6 ++--- .../PluginParameterExpressionEvaluator.java | 16 +++++++------- .../DefaultProjectDependenciesResolver.java | 4 ++-- .../apache/maven/project/MavenProject.java | 4 ++-- .../repository/ArtifactTransferEvent.java | 10 ++++----- .../metadata/AbstractArtifactMetadata.java | 2 +- .../project/LegacyLocalRepositoryManager.java | 2 +- .../apache/maven/cli/CLIReportingUtils.java | 2 +- .../java/org/apache/maven/cli/MavenCli.java | 2 +- .../maven/cli/event/ExecutionEventLogger.java | 4 ++-- .../UnsupportedSlf4jBindingConfiguration.java | 2 +- .../cli/CLIManagerDocumentationTest.java | 2 +- .../model/building/DefaultModelBuilder.java | 8 +++---- .../model/building/DefaultModelProblem.java | 2 +- .../model/building/ModelProblemUtils.java | 2 +- .../maven/plugin/MojoNotFoundException.java | 2 +- .../building/DefaultSettingsProblem.java | 2 +- 38 files changed, 98 insertions(+), 99 deletions(-) diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/DefaultArtifact.java b/maven-artifact/src/main/java/org/apache/maven/artifact/DefaultArtifact.java index 147e88e4ae..bd2e8ed1ac 100644 --- a/maven-artifact/src/main/java/org/apache/maven/artifact/DefaultArtifact.java +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/DefaultArtifact.java @@ -230,7 +230,7 @@ public class DefaultArtifact { StringBuilder sb = new StringBuilder( 128 ); sb.append( getGroupId() ); - sb.append( ":" ); + sb.append( ':' ); appendArtifactTypeClassifierString( sb ); return sb.toString(); } @@ -238,11 +238,11 @@ public class DefaultArtifact private void appendArtifactTypeClassifierString( StringBuilder sb ) { sb.append( getArtifactId() ); - sb.append( ":" ); + sb.append( ':' ); sb.append( getType() ); if ( hasClassifier() ) { - sb.append( ":" ); + sb.append( ':' ); sb.append( getClassifier() ); } } @@ -285,10 +285,10 @@ public class DefaultArtifact if ( getGroupId() != null ) { sb.append( getGroupId() ); - sb.append( ":" ); + sb.append( ':' ); } appendArtifactTypeClassifierString( sb ); - sb.append( ":" ); + sb.append( ':' ); if ( getBaseVersionInternal() != null ) { sb.append( getBaseVersionInternal() ); @@ -299,7 +299,7 @@ public class DefaultArtifact } if ( scope != null ) { - sb.append( ":" ); + sb.append( ':' ); sb.append( scope ); } return sb.toString(); diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/repository/ArtifactRepositoryPolicy.java b/maven-artifact/src/main/java/org/apache/maven/artifact/repository/ArtifactRepositoryPolicy.java index b6cd8f39cb..c5d24732ee 100644 --- a/maven-artifact/src/main/java/org/apache/maven/artifact/repository/ArtifactRepositoryPolicy.java +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/repository/ArtifactRepositoryPolicy.java @@ -160,7 +160,7 @@ public class ArtifactRepositoryPolicy buffer.append( checksumPolicy ); buffer.append( ", updates=" ); buffer.append( updatePolicy ); - buffer.append( "}" ); + buffer.append( '}' ); return buffer.toString(); } 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 66e147c238..b63428e713 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 @@ -175,7 +175,7 @@ public class AbstractArtifactResolutionException for ( Iterator i = path.iterator(); i.hasNext(); num++ ) { sb.append( indentation ); - sb.append( "\t" ); + sb.append( '\t' ); sb.append( num ); sb.append( ") " ); sb.append( i.next() ); @@ -201,8 +201,8 @@ public class AbstractArtifactResolutionException if ( message == null || !message.contains( "from the specified remote repositories:" ) ) { sb.append( LS ); - sb.append( " " ).append( groupId ).append( ":" ).append( artifactId ).append( ":" ).append( type ).append( - ":" ).append( version ); + sb.append( " " ).append( groupId ).append( ':' ).append( artifactId ).append( ':' ).append( type ).append( + ':' ).append( version ); sb.append( LS ); if ( remoteRepositories != null ) { @@ -235,10 +235,10 @@ public class AbstractArtifactResolutionException sb.append( ", snapshots=" ).append( snapshots.isEnabled() ); } - sb.append( ")" ); + sb.append( ')' ); if ( i.hasNext() ) { - sb.append( "," ).append( LS ).append( " " ); + sb.append( ',' ).append( LS ).append( " " ); } } } diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/MultipleArtifactsNotFoundException.java b/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/MultipleArtifactsNotFoundException.java index 0f13db1571..896710f575 100644 --- a/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/MultipleArtifactsNotFoundException.java +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/MultipleArtifactsNotFoundException.java @@ -84,8 +84,9 @@ public class MultipleArtifactsNotFoundException private static String constructMessage( List artifacts ) { - StringBuilder buffer = new StringBuilder( "Missing:\n" ); + StringBuilder buffer = new StringBuilder( 256 ); + buffer.append( "Missing:\n" ); buffer.append( "----------\n" ); int counter = 0; diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/DefaultArtifactVersion.java b/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/DefaultArtifactVersion.java index b5e43d4209..81a52b8ae8 100644 --- a/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/DefaultArtifactVersion.java +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/DefaultArtifactVersion.java @@ -111,7 +111,7 @@ public class DefaultArtifactVersion { comparable = new ComparableVersion( version ); - int index = version.indexOf( "-" ); + int index = version.indexOf( '-' ); String part1; String part2 = null; diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/Restriction.java b/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/Restriction.java index d73d7ea5b0..c728e9f03e 100644 --- a/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/Restriction.java +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/Restriction.java @@ -178,17 +178,17 @@ public class Restriction { StringBuilder buf = new StringBuilder(); - buf.append( isLowerBoundInclusive() ? "[" : "(" ); + buf.append( isLowerBoundInclusive() ? '[' : '(' ); if ( getLowerBound() != null ) { buf.append( getLowerBound().toString() ); } - buf.append( "," ); + buf.append( ',' ); if ( getUpperBound() != null ) { buf.append( getUpperBound().toString() ); } - buf.append( isUpperBoundInclusive() ? "]" : ")" ); + buf.append( isUpperBoundInclusive() ? ']' : ')' ); return buf.toString(); } diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/VersionRange.java b/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/VersionRange.java index 0d094ef8a4..7181db0286 100644 --- a/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/VersionRange.java +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/VersionRange.java @@ -104,8 +104,8 @@ public class VersionRange while ( process.startsWith( "[" ) || process.startsWith( "(" ) ) { - int index1 = process.indexOf( ")" ); - int index2 = process.indexOf( "]" ); + int index1 = process.indexOf( ')' ); + int index2 = process.indexOf( ']' ); int index = index2; if ( index2 < 0 || index1 < index2 ) @@ -171,7 +171,7 @@ public class VersionRange Restriction restriction; - int index = process.indexOf( "," ); + int index = process.indexOf( ',' ); if ( index < 0 ) { diff --git a/maven-builder-support/src/main/java/org/apache/maven/building/DefaultProblem.java b/maven-builder-support/src/main/java/org/apache/maven/building/DefaultProblem.java index ad1fc40fb9..427eb2c6e4 100644 --- a/maven-builder-support/src/main/java/org/apache/maven/building/DefaultProblem.java +++ b/maven-builder-support/src/main/java/org/apache/maven/building/DefaultProblem.java @@ -151,7 +151,7 @@ class DefaultProblem { StringBuilder buffer = new StringBuilder( 128 ); - buffer.append( "[" ).append( getSeverity() ).append( "] " ); + buffer.append( '[' ).append( getSeverity() ).append( "] " ); buffer.append( getMessage() ); buffer.append( " @ " ).append( getLocation() ); diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/repository/DefaultArtifactRepository.java b/maven-compat/src/main/java/org/apache/maven/artifact/repository/DefaultArtifactRepository.java index e0a55879ea..f5db5ef634 100644 --- a/maven-compat/src/main/java/org/apache/maven/artifact/repository/DefaultArtifactRepository.java +++ b/maven-compat/src/main/java/org/apache/maven/artifact/repository/DefaultArtifactRepository.java @@ -175,11 +175,11 @@ public class DefaultArtifactRepository public String toString() { - StringBuilder sb = new StringBuilder(); + StringBuilder sb = new StringBuilder( 256 ); - sb.append( " id: " ).append( getId() ).append( "\n" ); - sb.append( " url: " ).append( getUrl() ).append( "\n" ); - sb.append( " layout: " ).append( layout != null ? layout : "none" ).append( "\n" ); + sb.append( " id: " ).append( getId() ).append( '\n' ); + sb.append( " url: " ).append( getUrl() ).append( '\n' ); + sb.append( " layout: " ).append( layout != null ? layout : "none" ).append( '\n' ); if ( snapshots != null ) { diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/versioning/ManagedVersionMap.java b/maven-compat/src/main/java/org/apache/maven/artifact/versioning/ManagedVersionMap.java index 86b49499ad..02ac24cbe5 100644 --- a/maven-compat/src/main/java/org/apache/maven/artifact/versioning/ManagedVersionMap.java +++ b/maven-compat/src/main/java/org/apache/maven/artifact/versioning/ManagedVersionMap.java @@ -45,10 +45,10 @@ public class ManagedVersionMap while ( iter.hasNext() ) { String key = iter.next(); - buffer.append( key ).append( "=" ).append( get( key ) ); + buffer.append( key ).append( '=' ).append( get( key ) ); if ( iter.hasNext() ) { - buffer.append( "\n" ); + buffer.append( '\n' ); } } return buffer.toString(); 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 ad94fe00d1..5033b990d8 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,7 @@ public class ModelValidationResult // for ( int i = 0; i < messages.size(); i++ ) { - message.append( indentation ).append( "[" ).append( i ).append( "] " ).append( messages.get( i ) ).append( + message.append( indentation ).append( '[' ).append( i ).append( "] " ).append( messages.get( i ) ).append( NEWLINE ); } diff --git a/maven-compat/src/main/java/org/apache/maven/repository/MetadataResolutionResult.java b/maven-compat/src/main/java/org/apache/maven/repository/MetadataResolutionResult.java index bd5436c3b1..906d0f69e1 100644 --- a/maven-compat/src/main/java/org/apache/maven/repository/MetadataResolutionResult.java +++ b/maven-compat/src/main/java/org/apache/maven/repository/MetadataResolutionResult.java @@ -322,21 +322,19 @@ public class MetadataResolutionResult public String toString() { - StringBuilder sb = new StringBuilder(); + if ( artifacts == null ) + return ""; - if ( artifacts != null ) + StringBuilder sb = new StringBuilder( 256 ); + int i = 1; + sb.append( "---------\n" ); + sb.append( artifacts.size() ).append( '\n' ); + for ( Artifact a : artifacts ) { - int i = 1; - sb.append( "---------" ).append( "\n" ); - sb.append( artifacts.size() ).append( "\n" ); - for ( Artifact a : artifacts ) - { - sb.append( i ).append( " " ).append( a ).append( "\n" ); - i++; - } - sb.append( "---------" ).append( "\n" ); + sb.append( i ).append( ' ' ).append( a ).append( '\n' ); + i++; } - + sb.append( "---------\n" ); return sb.toString(); } 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 4bcca4c939..532cd3c8fc 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 @@ -486,13 +486,13 @@ public class MetadataGraph } for ( MetadataGraphVertex v : vertices ) { - sb.append( "Vertex: " ).append( v.getMd().toString() ).append( "\n" ); + sb.append( "Vertex: " ).append( v.getMd().toString() ).append( '\n' ); List ins = getIncidentEdges( v ); if ( ins != null ) { for ( MetadataGraphEdge e : ins ) { - sb.append( " from : " ).append( e.toString() ).append( "\n" ); + sb.append( " from : " ).append( e.toString() ).append( '\n' ); } } else @@ -505,7 +505,7 @@ public class MetadataGraph { for ( MetadataGraphEdge e : outs ) { - sb.append( " to : " ).append( e.toString() ).append( "\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 eb871216d1..495d061ca6 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 ).append( "|" ); - hashString.append( md.artifactId ).append( "|" ); + hashString.append( md.groupId ).append( '|' ); + hashString.append( md.artifactId ).append( '|' ); if ( compareVersion ) { - hashString.append( md.version ).append( "|" ); + hashString.append( md.version ).append( '|' ); } if ( compareScope ) { - hashString.append( md.getArtifactScope() ).append( "|" ); + hashString.append( md.getArtifactScope() ).append( '|' ); } return hashString.toString().hashCode(); diff --git a/maven-compat/src/test/java/org/apache/maven/project/LegacyLocalRepositoryManager.java b/maven-compat/src/test/java/org/apache/maven/project/LegacyLocalRepositoryManager.java index 52fdd80478..c919cdf776 100644 --- a/maven-compat/src/test/java/org/apache/maven/project/LegacyLocalRepositoryManager.java +++ b/maven-compat/src/test/java/org/apache/maven/project/LegacyLocalRepositoryManager.java @@ -59,7 +59,7 @@ public class LegacyLocalRepositoryManager path.append( artifact.getGroupId() ).append( '/' ); - path.append( artifact.getExtension() ).append( 's' ).append( '/' ); + path.append( artifact.getExtension() ).append( "s/" ); path.append( artifact.getArtifactId() ).append( '-' ).append( artifact.getVersion() ); diff --git a/maven-compat/src/test/java/org/apache/maven/project/inheritance/AbstractProjectInheritanceTestCase.java b/maven-compat/src/test/java/org/apache/maven/project/inheritance/AbstractProjectInheritanceTestCase.java index 413d6fea06..93358ecc1f 100644 --- a/maven-compat/src/test/java/org/apache/maven/project/inheritance/AbstractProjectInheritanceTestCase.java +++ b/maven-compat/src/test/java/org/apache/maven/project/inheritance/AbstractProjectInheritanceTestCase.java @@ -33,7 +33,7 @@ public abstract class AbstractProjectInheritanceTestCase { String className = getClass().getPackage().getName(); - return className.substring( className.lastIndexOf( "." ) + 1 ); + return className.substring( className.lastIndexOf( '.' ) + 1 ); } protected File projectFile( String name ) diff --git a/maven-core/src/main/java/org/apache/maven/artifact/repository/MavenArtifactRepository.java b/maven-core/src/main/java/org/apache/maven/artifact/repository/MavenArtifactRepository.java index 450d139c63..38ae6bb76b 100644 --- a/maven-core/src/main/java/org/apache/maven/artifact/repository/MavenArtifactRepository.java +++ b/maven-core/src/main/java/org/apache/maven/artifact/repository/MavenArtifactRepository.java @@ -132,15 +132,15 @@ public class MavenArtifactRepository public String toString() { - StringBuilder sb = new StringBuilder(); + StringBuilder sb = new StringBuilder( 256 ); - sb.append( " id: " ).append( getId() ).append( "\n" ); - sb.append( " url: " ).append( getUrl() ).append( "\n" ); - sb.append( " layout: " ).append( layout != null ? layout : "none" ).append( "\n" ); + sb.append( " id: " ).append( getId() ).append( '\n' ); + sb.append( " url: " ).append( getUrl() ).append( '\n' ); + sb.append( " layout: " ).append( layout != null ? layout : "none" ).append( '\n' ); if ( proxy != null ) { - sb.append( " proxy: " ).append( proxy.getHost() ).append( ":" ).append( proxy.getPort() ).append( "\n" ); + sb.append( " proxy: " ).append( proxy.getHost() ).append( ':' ).append( proxy.getPort() ).append( '\n' ); } if ( snapshots != null ) @@ -220,7 +220,7 @@ public class MavenArtifactRepository */ private static String protocol( final String url ) { - final int pos = url.indexOf( ":" ); + final int pos = url.indexOf( ':' ); if ( pos == -1 ) { @@ -257,7 +257,7 @@ public class MavenArtifactRepository else { // Now we expect the host - int index = retValue.indexOf( "/" ); + int index = retValue.indexOf( '/' ); if ( index >= 0 ) { retValue = retValue.substring( index + 1 ); diff --git a/maven-core/src/main/java/org/apache/maven/artifact/repository/metadata/AbstractRepositoryMetadata.java b/maven-core/src/main/java/org/apache/maven/artifact/repository/metadata/AbstractRepositoryMetadata.java index 05284174a0..37e69e5bea 100644 --- a/maven-core/src/main/java/org/apache/maven/artifact/repository/metadata/AbstractRepositoryMetadata.java +++ b/maven-core/src/main/java/org/apache/maven/artifact/repository/metadata/AbstractRepositoryMetadata.java @@ -197,7 +197,7 @@ public abstract class AbstractRepositoryMetadata public String extendedToString() { - StringBuilder buffer = new StringBuilder(); + StringBuilder buffer = new StringBuilder( 256 ); buffer.append( "\nRepository Metadata\n--------------------------" ); buffer.append( "\nGroupId: " ).append( getGroupId() ); diff --git a/maven-core/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolutionResult.java b/maven-core/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolutionResult.java index 07331f2994..2bad1a74af 100644 --- a/maven-core/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolutionResult.java +++ b/maven-core/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolutionResult.java @@ -343,14 +343,14 @@ public class ArtifactResolutionResult if ( artifacts != null ) { int i = 1; - sb.append( "---------" ).append( "\n" ); - sb.append( artifacts.size() ).append( "\n" ); + sb.append( "---------\n" ); + sb.append( artifacts.size() ).append( '\n' ); for ( Artifact a : artifacts ) { - sb.append( i ).append( " " ).append( a ).append( "\n" ); + sb.append( i ).append( ' ' ).append( a ).append( '\n' ); i++; } - sb.append( "---------" ).append( "\n" ); + sb.append( "---------\n" ); } return sb.toString(); diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/mapping/LifecyclePhase.java b/maven-core/src/main/java/org/apache/maven/lifecycle/mapping/LifecyclePhase.java index 059f234688..295e6421d4 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/mapping/LifecyclePhase.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/mapping/LifecyclePhase.java @@ -84,7 +84,7 @@ public class LifecyclePhase } else { - sb.append( "," ); + sb.append( ',' ); } sb.append( mojo.getGoal() ); } diff --git a/maven-core/src/main/java/org/apache/maven/plugin/MojoExecution.java b/maven-core/src/main/java/org/apache/maven/plugin/MojoExecution.java index bf053cc5f4..71ece87ed0 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/MojoExecution.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/MojoExecution.java @@ -175,7 +175,7 @@ public class MojoExecution { buffer.append( mojoDescriptor.getId() ); } - buffer.append( " {execution: " ).append( executionId ).append( "}" ); + buffer.append( " {execution: " ).append( executionId ).append( '}' ); return buffer.toString(); } 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 dcf459e7ba..5f431e0aec 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 @@ -151,7 +151,7 @@ public class PluginParameterException if ( StringUtils.isEmpty( expression ) ) { - messageBuffer.append( "." ); + messageBuffer.append( '.' ); } else { @@ -172,7 +172,7 @@ public class PluginParameterException MojoDescriptor mojo = getMojoDescriptor(); messageBuffer.append( "One or more required plugin parameters are invalid/missing for \'" ) - .append( mojo.getPluginDescriptor().getGoalPrefix() ).append( ":" ).append( mojo.getGoal() ) + .append( mojo.getPluginDescriptor().getGoalPrefix() ).append( ':' ).append( mojo.getGoal() ) .append( "\'\n" ); int idx = 0; @@ -184,7 +184,7 @@ public class PluginParameterException decomposeParameterIntoUserInstructions( mojo, param, messageBuffer ); - messageBuffer.append( "\n" ); + messageBuffer.append( '\n' ); } return messageBuffer.toString(); diff --git a/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java b/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java index 9199ba5a94..a7eeb4e307 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java @@ -160,7 +160,7 @@ public class PluginParameterExpressionEvaluator int index = expr.indexOf( "${" ); if ( index >= 0 ) { - int lastIndex = expr.indexOf( "}", index ); + int lastIndex = expr.indexOf( '}', index ); if ( lastIndex >= 0 ) { String retVal = expr.substring( 0, index ); @@ -213,7 +213,7 @@ public class PluginParameterExpressionEvaluator { try { - int pathSeparator = expression.indexOf( "/" ); + int pathSeparator = expression.indexOf( '/' ); if ( pathSeparator > 0 ) { @@ -253,7 +253,7 @@ public class PluginParameterExpressionEvaluator { try { - int pathSeparator = expression.indexOf( "/" ); + int pathSeparator = expression.indexOf( '/' ); if ( pathSeparator > 0 ) { @@ -285,7 +285,7 @@ public class PluginParameterExpressionEvaluator { try { - int pathSeparator = expression.indexOf( "/" ); + int pathSeparator = expression.indexOf( '/' ); if ( pathSeparator > 0 ) { @@ -313,7 +313,7 @@ public class PluginParameterExpressionEvaluator { try { - int pathSeparator = expression.indexOf( "/" ); + int pathSeparator = expression.indexOf( '/' ); PluginDescriptor pluginDescriptor = mojoDescriptor.getPluginDescriptor(); @@ -342,7 +342,7 @@ public class PluginParameterExpressionEvaluator { try { - int pathSeparator = expression.indexOf( "/" ); + int pathSeparator = expression.indexOf( '/' ); if ( pathSeparator > 0 ) { @@ -368,7 +368,7 @@ public class PluginParameterExpressionEvaluator } else if ( expression.startsWith( "basedir" ) ) { - int pathSeparator = expression.indexOf( "/" ); + int pathSeparator = expression.indexOf( '/' ); if ( pathSeparator > 0 ) { @@ -447,7 +447,7 @@ public class PluginParameterExpressionEvaluator private String stripTokens( String expr ) { - if ( expr.startsWith( "${" ) && ( expr.indexOf( "}" ) == expr.length() - 1 ) ) + if ( expr.startsWith( "${" ) && ( expr.indexOf( '}' ) == expr.length() - 1 ) ) { expr = expr.substring( 2, expr.length() - 1 ); } diff --git a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectDependenciesResolver.java b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectDependenciesResolver.java index 24860578e5..16b60c2004 100644 --- a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectDependenciesResolver.java +++ b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectDependenciesResolver.java @@ -263,7 +263,7 @@ public class DefaultProjectDependenciesResolver { buffer.append( " (scope managed from " ).append( premanagedScope ); appendManagementSource( buffer, art, "scope" ); - buffer.append( ")" ); + buffer.append( ')' ); } String premanagedVersion = DependencyManagerUtils.getPremanagedVersion( node ); @@ -271,7 +271,7 @@ public class DefaultProjectDependenciesResolver { buffer.append( " (version managed from " ).append( premanagedVersion ); appendManagementSource( buffer, art, "version" ); - buffer.append( ")" ); + buffer.append( ')' ); } } else diff --git a/maven-core/src/main/java/org/apache/maven/project/MavenProject.java b/maven-core/src/main/java/org/apache/maven/project/MavenProject.java index 952622ffa2..77206bd5fc 100644 --- a/maven-core/src/main/java/org/apache/maven/project/MavenProject.java +++ b/maven-core/src/main/java/org/apache/maven/project/MavenProject.java @@ -1133,9 +1133,9 @@ public class MavenProject StringBuilder sb = new StringBuilder( 128 ); sb.append( "MavenProject: " ); sb.append( getGroupId() ); - sb.append( ":" ); + sb.append( ':' ); sb.append( getArtifactId() ); - sb.append( ":" ); + sb.append( ':' ); sb.append( getVersion() ); sb.append( " @ " ); diff --git a/maven-core/src/main/java/org/apache/maven/repository/ArtifactTransferEvent.java b/maven-core/src/main/java/org/apache/maven/repository/ArtifactTransferEvent.java index 09729ddd2c..0d31eb2d06 100644 --- a/maven-core/src/main/java/org/apache/maven/repository/ArtifactTransferEvent.java +++ b/maven-core/src/main/java/org/apache/maven/repository/ArtifactTransferEvent.java @@ -242,7 +242,7 @@ public class ArtifactTransferEvent public String toString() { - StringBuilder sb = new StringBuilder(); + StringBuilder sb = new StringBuilder( 64 ); sb.append( "TransferEvent[" ); @@ -259,7 +259,7 @@ public class ArtifactTransferEvent break; } - sb.append( "|" ); + sb.append( '|' ); switch ( this.getEventType() ) { case TRANSFER_COMPLETED: @@ -282,9 +282,9 @@ public class ArtifactTransferEvent break; } - sb.append( "|" ); - sb.append( this.getLocalFile() ).append( "|" ); - sb.append( "]" ); + sb.append( '|' ); + sb.append( this.getLocalFile() ).append( '|' ); + sb.append( ']' ); return sb.toString(); } diff --git a/maven-core/src/main/java/org/apache/maven/repository/legacy/metadata/AbstractArtifactMetadata.java b/maven-core/src/main/java/org/apache/maven/repository/legacy/metadata/AbstractArtifactMetadata.java index 352e5bbb1c..def20e4726 100644 --- a/maven-core/src/main/java/org/apache/maven/repository/legacy/metadata/AbstractArtifactMetadata.java +++ b/maven-core/src/main/java/org/apache/maven/repository/legacy/metadata/AbstractArtifactMetadata.java @@ -53,7 +53,7 @@ public abstract class AbstractArtifactMetadata public String extendedToString() { - StringBuilder buffer = new StringBuilder(); + StringBuilder buffer = new StringBuilder( 256 ); buffer.append( "\nArtifact Metadata\n--------------------------" ); buffer.append( "\nGroupId: " ).append( getGroupId() ); diff --git a/maven-core/src/test/java/org/apache/maven/project/LegacyLocalRepositoryManager.java b/maven-core/src/test/java/org/apache/maven/project/LegacyLocalRepositoryManager.java index 52fdd80478..c919cdf776 100644 --- a/maven-core/src/test/java/org/apache/maven/project/LegacyLocalRepositoryManager.java +++ b/maven-core/src/test/java/org/apache/maven/project/LegacyLocalRepositoryManager.java @@ -59,7 +59,7 @@ public class LegacyLocalRepositoryManager path.append( artifact.getGroupId() ).append( '/' ); - path.append( artifact.getExtension() ).append( 's' ).append( '/' ); + path.append( artifact.getExtension() ).append( "s/" ); path.append( artifact.getArtifactId() ).append( '-' ).append( artifact.getVersion() ); 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 f1648520fc..c5faef5b47 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 @@ -71,7 +71,7 @@ public final class CLIReportingUtils 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( "\"" ); + "\", arch: \"" ).append( Os.OS_ARCH ).append( "\", family: \"" ).append( Os.OS_FAMILY ).append( '\"' ); return version.toString(); } diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java b/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java index d239884d34..1cdbd23a04 100644 --- a/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java +++ b/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java @@ -1621,7 +1621,7 @@ public class MavenCli String value; - int i = property.indexOf( "=" ); + int i = property.indexOf( '=' ); if ( i <= 0 ) { diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/event/ExecutionEventLogger.java b/maven-embedder/src/main/java/org/apache/maven/cli/event/ExecutionEventLogger.java index 25ec38d349..76327eae85 100644 --- a/maven-embedder/src/main/java/org/apache/maven/cli/event/ExecutionEventLogger.java +++ b/maven-embedder/src/main/java/org/apache/maven/cli/event/ExecutionEventLogger.java @@ -174,7 +174,7 @@ public class ExecutionEventLogger buffer.append( chars( ' ', padSize ) ); } buffer.append( buildTimeDuration ); - buffer.append( "]" ); + buffer.append( ']' ); } else if ( buildSummary instanceof BuildFailure ) { @@ -187,7 +187,7 @@ public class ExecutionEventLogger buffer.append( chars( ' ', padSize ) ); } buffer.append( buildTimeDuration ); - buffer.append( "]" ); + buffer.append( ']' ); } logger.info( buffer.toString() ); diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/logging/impl/UnsupportedSlf4jBindingConfiguration.java b/maven-embedder/src/main/java/org/apache/maven/cli/logging/impl/UnsupportedSlf4jBindingConfiguration.java index 2e91b251f1..d269770852 100644 --- a/maven-embedder/src/main/java/org/apache/maven/cli/logging/impl/UnsupportedSlf4jBindingConfiguration.java +++ b/maven-embedder/src/main/java/org/apache/maven/cli/logging/impl/UnsupportedSlf4jBindingConfiguration.java @@ -59,7 +59,7 @@ public class UnsupportedSlf4jBindingConfiguration for ( Map.Entry> entry : supported.entrySet() ) { StringBuilder sb = new StringBuilder(); - sb.append( "(from " ).append( entry.getKey().toExternalForm() ).append( ")" ); + sb.append( "(from " ).append( entry.getKey().toExternalForm() ).append( ')' ); for ( Object binding : entry.getValue() ) { diff --git a/maven-embedder/src/test/java/org/apache/maven/cli/CLIManagerDocumentationTest.java b/maven-embedder/src/test/java/org/apache/maven/cli/CLIManagerDocumentationTest.java index a06f0a1c58..f58d75b3ff 100644 --- a/maven-embedder/src/test/java/org/apache/maven/cli/CLIManagerDocumentationTest.java +++ b/maven-embedder/src/test/java/org/apache/maven/cli/CLIManagerDocumentationTest.java @@ -62,7 +62,7 @@ public class CLIManagerDocumentationTest public String getOptionsAsHtml() { - StringBuilder sb = new StringBuilder(); + StringBuilder sb = new StringBuilder( 512 ); boolean a = true; sb.append( "" ); for ( Option option : new CLIManagerExtension().getOptions() ) diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java b/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java index ac54737389..189651b3af 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java @@ -914,8 +914,8 @@ public class DefaultModelBuilder { buffer.append( " of POM " ).append( ModelProblemUtils.toSourceHint( childModel ) ); } - buffer.append( " points at " ).append( groupId ).append( ":" ).append( artifactId ); - buffer.append( " instead of " ).append( parent.getGroupId() ).append( ":" ); + buffer.append( " points at " ).append( groupId ).append( ':' ).append( artifactId ); + buffer.append( " instead of " ).append( parent.getGroupId() ).append( ':' ); buffer.append( parent.getArtifactId() ).append( ", please verify your project structure" ); problems.setSource( childModel ); @@ -1028,7 +1028,7 @@ public class DefaultModelBuilder buffer.append( "Non-resolvable parent POM" ); if ( !containsCoordinates( e.getMessage(), groupId, artifactId, version ) ) { - buffer.append( " " ).append( ModelProblemUtils.toId( groupId, artifactId, version ) ); + buffer.append( ' ' ).append( ModelProblemUtils.toId( groupId, artifactId, version ) ); } if ( childModel != problems.getRootModel() ) { @@ -1221,7 +1221,7 @@ public class DefaultModelBuilder buffer.append( "Non-resolvable import POM" ); if ( !containsCoordinates( e.getMessage(), groupId, artifactId, version ) ) { - buffer.append( " " ).append( ModelProblemUtils.toId( groupId, artifactId, version ) ); + buffer.append( ' ' ).append( ModelProblemUtils.toId( groupId, artifactId, version ) ); } buffer.append( ": " ).append( e.getMessage() ); diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelProblem.java b/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelProblem.java index 0892f0a580..78e81e380c 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelProblem.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelProblem.java @@ -165,7 +165,7 @@ public class DefaultModelProblem { StringBuilder buffer = new StringBuilder( 128 ); - buffer.append( "[" ).append( getSeverity() ).append( "] " ); + buffer.append( '[' ).append( getSeverity() ).append( "] " ); buffer.append( getMessage() ); buffer.append( " @ " ).append( ModelProblemUtils.formatLocation( this, null ) ); diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelProblemUtils.java b/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelProblemUtils.java index 806c28d474..76c23e1fde 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelProblemUtils.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelProblemUtils.java @@ -51,7 +51,7 @@ public class ModelProblemUtils File pomFile = model.getPomFile(); if ( pomFile != null ) { - buffer.append( " (" ).append( pomFile ).append( ")" ); + buffer.append( " (" ).append( pomFile ).append( ')' ); } return buffer.toString(); diff --git a/maven-plugin-api/src/main/java/org/apache/maven/plugin/MojoNotFoundException.java b/maven-plugin-api/src/main/java/org/apache/maven/plugin/MojoNotFoundException.java index 4d99546ae2..cdb9a23ca8 100644 --- a/maven-plugin-api/src/main/java/org/apache/maven/plugin/MojoNotFoundException.java +++ b/maven-plugin-api/src/main/java/org/apache/maven/plugin/MojoNotFoundException.java @@ -54,7 +54,7 @@ public class MojoNotFoundException { StringBuilder buffer = new StringBuilder( 256 ); - buffer.append( "Could not find goal '" ).append( goal ).append( "'" ); + buffer.append( "Could not find goal '" ).append( goal ).append( '\'' ); if ( pluginDescriptor != null ) { diff --git a/maven-settings-builder/src/main/java/org/apache/maven/settings/building/DefaultSettingsProblem.java b/maven-settings-builder/src/main/java/org/apache/maven/settings/building/DefaultSettingsProblem.java index b261fa1d64..a8eb909b45 100644 --- a/maven-settings-builder/src/main/java/org/apache/maven/settings/building/DefaultSettingsProblem.java +++ b/maven-settings-builder/src/main/java/org/apache/maven/settings/building/DefaultSettingsProblem.java @@ -156,7 +156,7 @@ public class DefaultSettingsProblem { StringBuilder buffer = new StringBuilder( 128 ); - buffer.append( "[" ).append( getSeverity() ).append( "] " ); + buffer.append( '[' ).append( getSeverity() ).append( "] " ); buffer.append( getMessage() ); buffer.append( " @ " ).append( getLocation() );
OptionsDescription