Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,7 @@ public boolean checkOutOfDate(Date lastModified) {

@Override
public String toString() {
StringBuilder buffer = new StringBuilder(64);
buffer.append("{enabled=");
buffer.append(enabled);
buffer.append(", checksums=");
buffer.append(checksumPolicy);
buffer.append(", updates=");
buffer.append(updatePolicy);
buffer.append('}');
return buffer.toString();
return "{enabled=" + enabled + ", checksums=" + checksumPolicy + ", updates=" + updatePolicy + '}';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't do this; it's actively bad

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

before it was optimized, right?

}

public void merge(ArtifactRepositoryPolicy policy) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,11 @@ public String pathOf(Artifact artifact) {
}

public String pathOfLocalRepositoryMetadata(ArtifactMetadata metadata, ArtifactRepository repository) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return pathOfRepositoryMetadata(metadata.getLocalFilename(repository));
}

private String pathOfRepositoryMetadata(String filename) {
StringBuilder path = new StringBuilder(128);

path.append(filename);

return path.toString();
return metadata.getLocalFilename(repository);
}

public String pathOfRemoteRepositoryMetadata(ArtifactMetadata metadata) {
return pathOfRepositoryMetadata(metadata.getRemoteFilename());
return metadata.getRemoteFilename();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,11 @@ public void merge(ArtifactMetadata metadata) {
}

public String extendedToString() {
StringBuilder buffer = new StringBuilder(256);

buffer.append(LS).append("Repository Metadata").append(LS).append("--------------------------");
buffer.append(LS).append("GroupId: ").append(getGroupId());
buffer.append(LS).append("ArtifactId: ").append(getArtifactId());
buffer.append(LS).append("Metadata Type: ").append(getClass().getName());

return buffer.toString();
return LS + "Repository Metadata" + LS + "--------------------------" + LS
+ "GroupId: " + getGroupId() + LS
+ "ArtifactId: " + getArtifactId() + LS
+ "Metadata Type: " + getClass().getName();
}

public int getNature() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,21 +207,18 @@ public boolean isResolveTransitively() {
}

public String toString() {
StringBuilder sb = new StringBuilder()
.append("REQUEST: ")
.append(LS)
.append("artifact: ")
.append(artifact)
.append(LS)
.append(artifactDependencies)
.append(LS)
.append("localRepository: ")
.append(localRepository)
.append(LS)
.append("remoteRepositories: ")
.append(remoteRepositories);

return sb.toString();

return "REQUEST: " + LS
+ "artifact: "
+ artifact
+ LS
+ artifactDependencies
+ LS
+ "localRepository: "
+ localRepository
+ LS
+ "remoteRepositories: "
+ remoteRepositories;
}

public boolean isOffline() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,22 +134,19 @@ public MetadataResolutionRequest setManagedVersionMap(Map managedVersionMap) {
}

public String toString() {
StringBuilder sb = new StringBuilder()
.append("REQUEST: ")
.append("\n")
.append("artifact: ")
.append(mad)
.append("\n")
.append(artifactDependencies)
.append("\n")
.append("localRepository: ")
.append(localRepository)
.append("\n")
.append("remoteRepositories: ")
.append(remoteRepositories)
.append("\n");

return sb.toString();

return "REQUEST: " + "\n"
+ "artifact: "
+ mad
+ "\n"
+ artifactDependencies
+ "\n"
+ "localRepository: "
+ localRepository
+ "\n"
+ "remoteRepositories: "
+ remoteRepositories
+ "\n";
}

public boolean isAsList() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,10 @@ public String getArtifactId() {
}

public String extendedToString() {
StringBuilder buffer = new StringBuilder(256);

buffer.append(LS).append("Artifact Metadata").append(LS).append("--------------------------");
buffer.append(LS).append("GroupId: ").append(getGroupId());
buffer.append(LS).append("ArtifactId: ").append(getArtifactId());
buffer.append(LS).append("Metadata Type: ").append(getClass().getName());

return buffer.toString();
return LS + "Artifact Metadata" + LS + "--------------------------" + LS
+ "GroupId: " + getGroupId() + LS
+ "ArtifactId: " + getArtifactId() + LS
+ "Metadata Type: " + getClass().getName();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,8 @@ protected Artifact createArtifact(String artifactId, String version, String type
}

protected Artifact createArtifact(String groupId, String artifactId, String version, String type) throws Exception {
Artifact a = artifactFactory.createBuildArtifact(groupId, artifactId, version, type);

return a;
return artifactFactory.createBuildArtifact(groupId, artifactId, version, type);
}

protected void deleteLocalArtifact(Artifact artifact) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,8 @@ protected static File getFileForClasspathResource(String resource)
protected ArtifactRepository getLocalRepository() throws Exception {
ArtifactRepositoryLayout repoLayout = getContainer().lookup(ArtifactRepositoryLayout.class);

ArtifactRepository r = repositorySystem.createArtifactRepository(
return repositorySystem.createArtifactRepository(
"local", "file://" + getLocalRepositoryPath().getAbsolutePath(), repoLayout, null, null);

return r;
}

// ----------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,10 @@ public void transferInitiated(TransferEvent event) {
String direction = event.getRequestType() == TransferEvent.RequestType.PUT ? "to" : "from";

TransferResource resource = event.getResource();
StringBuilder message = new StringBuilder();
message.append(darkOn).append(action).append(' ').append(direction).append(' ');
message.append(darkOff).append(resource.getRepositoryId());
message.append(darkOn).append(": ").append(resource.getRepositoryUrl());
message.append(darkOff).append(resource.getResourceName());
String message = darkOn + action + ' ' + direction + ' ' + darkOff
+ resource.getRepositoryId() + darkOn
+ ": " + resource.getRepositoryUrl() + darkOff
+ resource.getResourceName();

out.println(message);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,11 @@ public void transferInitiated(TransferEvent event) {
String direction = event.getRequestType() == TransferEvent.RequestType.PUT ? "to" : "from";

TransferResource resource = event.getResource();
StringBuilder message = new StringBuilder();
message.append(action).append(' ').append(direction).append(' ').append(resource.getRepositoryId());
message.append(": ");
message.append(resource.getRepositoryUrl()).append(resource.getResourceName());
String message = action + ' ' + direction + ' ' + resource.getRepositoryId() + ": "
+ resource.getRepositoryUrl()
+ resource.getResourceName();

out.info(message.toString());
out.info(message);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -984,9 +984,7 @@ private ModelData readParentLocally(
* if ( version == null || !version.equals( parent.getVersion() ) ) { return null; }
*/

ModelData parentData = new ModelData(candidateSource, candidateModel, groupId, artifactId, version);

return parentData;
return new ModelData(candidateSource, candidateModel, groupId, artifactId, version);
}

private boolean rawChildVersionReferencesParent(String rawChildModelVersion) {
Expand Down Expand Up @@ -1094,10 +1092,8 @@ public int getValidationLevel() {
// MNG-2199: What else to check here ?
}

ModelData parentData = new ModelData(
return new ModelData(
modelSource, parentModel, parent.getGroupId(), parent.getArtifactId(), parent.getVersion());

return parentData;
}

private Model getSuperModel() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,7 @@ public Version getVersion() {

@Override
public String toString() {
StringBuilder buffer = new StringBuilder(128);

buffer.append('[').append(getSeverity()).append("] ");
buffer.append(getMessage());
buffer.append(" @ ").append(ModelProblemUtils.formatLocation(this, null));

return buffer.toString();
return "[" + getSeverity() + "] " + getMessage() + " @ " + ModelProblemUtils.formatLocation(this, null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -189,15 +189,8 @@ public void setVersion(String version) {
* @return The effective identifier of the model, never {@code null}.
*/
public String getId() {
StringBuilder buffer = new StringBuilder(128);

buffer.append(getGroupId())
.append(':')
.append(getArtifactId())
.append(':')
.append(getVersion());

return buffer.toString();
return getGroupId() + ':' + getArtifactId() + ':' + getVersion();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,12 @@ static String toId(Model model) {
* @return The user-friendly artifact id, never {@code null}.
*/
static String toId(String groupId, String artifactId, String version) {
StringBuilder buffer = new StringBuilder(128);

buffer.append((groupId != null && groupId.length() > 0) ? groupId : "[unknown-group-id]");
buffer.append(':');
buffer.append((artifactId != null && artifactId.length() > 0) ? artifactId : "[unknown-artifact-id]");
buffer.append(':');
buffer.append((version != null && version.length() > 0) ? version : "[unknown-version]");

return buffer.toString();
return ((groupId != null && groupId.length() > 0) ? groupId : "[unknown-group-id]")
+ ':'
+ ((artifactId != null && artifactId.length() > 0) ? artifactId : "[unknown-artifact-id]")
+ ':'
+ ((version != null && version.length() > 0) ? version : "[unknown-version]");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ void setUp() throws Exception {
private Profile newProfile(String jdkVersion) {
Activation a = Activation.newBuilder().jdk(jdkVersion).build();

Profile p = Profile.newBuilder().activation(a).build();

return p;
return Profile.newBuilder().activation(a).build();
}

private Properties newProperties(String javaVersion) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ void setUp() throws Exception {
private Profile newProfile(ActivationOS.Builder activationBuilder) {
Activation a = Activation.newBuilder().os(activationBuilder.build()).build();

Profile p = Profile.newBuilder().activation(a).build();

return p;
return Profile.newBuilder().activation(a).build();
}

private Properties newProperties(String osName, String osVersion, String osArch) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ private Profile newProfile(String key, String value) {

Activation a = Activation.newBuilder().property(ap).build();

Profile p = Profile.newBuilder().activation(a).build();

return p;
return Profile.newBuilder().activation(a).build();
}

private Properties newProperties(String key, String value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,11 @@ public void transferInitiated(TransferEvent event) {
String direction = event.getRequestType() == TransferEvent.RequestType.PUT ? "to" : "from";

TransferResource resource = event.getResource();
StringBuilder message = new StringBuilder();
message.append(action).append(' ').append(direction).append(' ').append(resource.getRepositoryId());
message.append(": ");
message.append(resource.getRepositoryUrl()).append(resource.getResourceName());
String message = action + ' ' + direction + ' ' + resource.getRepositoryId() + ": "
+ resource.getRepositoryUrl()
+ resource.getResourceName();

out.info(message.toString());
out.info(message);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,7 @@ public List<String> computePhases(Lifecycle lifecycle) {
addPhases(graph, null, null, lifecycle.v3phases());
List<String> allPhases = graph.visitAll();
Collections.reverse(allPhases);
List<String> computed =
allPhases.stream().filter(s -> !s.startsWith("$")).collect(Collectors.toList());
return computed;
return allPhases.stream().filter(s -> !s.startsWith("$")).collect(Collectors.toList());
}

private static void addPhase(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,7 @@ private ModelBuilderResult buildModel(RepositorySystemSession session, Path src)
request.lifecycleBindingsInjector(lifecycleBindingsInjector::injectLifecycleBindings);
ModelBuilder.ModelBuilderSession mbSession =
iSession.getData().get(SessionData.key(ModelBuilder.ModelBuilderSession.class));
ModelBuilderResult result = mbSession.build(request.build());
return result;
return mbSession.build(request.build());
}

static Model transformNonPom(Model model, MavenProject project) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,8 @@ public void setConfiguration(XmlNode configuration) {
}

public String identify() {
StringBuilder sb = new StringBuilder(256);

sb.append(executionId);
sb.append(configuration.toString());

return sb.toString();
return executionId + configuration.toString();
}

public String getLifecyclePhase() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1403,9 +1403,7 @@ private void deepCopy(MavenProject project) {
}

private static String getProjectReferenceId(String groupId, String artifactId, String version) {
StringBuilder buffer = new StringBuilder(128);
buffer.append(groupId).append(':').append(artifactId).append(':').append(version);
return buffer.toString();
return groupId + ':' + artifactId + ':' + version;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,7 @@ public int hashCode() {

@Override
public String toString() {
StringBuilder buffer = new StringBuilder(128);
buffer.append(groupId).append(':').append(artifactId).append(':').append(version);
return buffer.toString();
return groupId + ':' + artifactId + ':' + version;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -421,9 +421,8 @@ private MojoExecution newMojoExecution(Session session) {
}

private DefaultSession newSession() throws Exception {
DefaultSession session = new DefaultSession(
return new DefaultSession(
newMavenSession(), mock(RepositorySystem.class), null, null, new DefaultLookup(container), null);
return session;
}

private MavenSession newMavenSession() throws Exception {
Expand Down
Loading