[MNG-7291] Avoid String concatenation in loops (#572)

This commit is contained in:
Arturo Bernal 2021-10-10 22:12:41 +02:00 committed by GitHub
parent 25796220ad
commit b31f3aeef3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 11 deletions

View File

@ -229,7 +229,7 @@ public class MojoDescriptorCreator
resolvePluginVersion( plugin, session, project );
}
return pluginManager.getMojoDescriptor( plugin, goal, project.getRemotePluginRepositories(),
return pluginManager.getMojoDescriptor( plugin, goal.toString(), project.getRemotePluginRepositories(),
session.getRepositorySession() );
}

View File

@ -40,29 +40,29 @@ public class NoPluginFoundForPrefixException
private static String format( LocalRepository localRepository, List<RemoteRepository> remoteRepositories )
{
String repos = "[";
StringBuilder repos = new StringBuilder( "[" );
if ( localRepository != null )
{
repos += localRepository.getId() + " (" + localRepository.getBasedir() + ")";
repos.append( localRepository.getId() ).append( " (" ).append( localRepository.getBasedir() ).append( ")" );
}
if ( remoteRepositories != null && !remoteRepositories.isEmpty() )
{
for ( RemoteRepository repository : remoteRepositories )
{
repos += ", ";
repos.append( ", " );
if ( repository != null )
{
repos += repository.getId() + " (" + repository.getUrl() + ")";
repos.append( repository.getId() ).append( " (" ).append( repository.getUrl() ).append( ")" );
}
}
}
repos += "]";
repos.append( "]" );
return repos;
return repos.toString();
}
}

View File

@ -1556,13 +1556,15 @@ public class DefaultModelBuilder
if ( importIds.contains( imported ) )
{
String message = "The dependencies of type=pom and with scope=import form a cycle: ";
StringBuilder message =
new StringBuilder( "The dependencies of type=pom and with scope=import form a cycle: " );
for ( String modelId : importIds )
{
message += modelId + " -> ";
message.append( modelId ).append( " -> " );
}
message += imported;
problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE ).setMessage( message ) );
message.append( imported );
problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE ).setMessage(
message.toString() ) );
return null;
}