Merge "Remove the use of + when using StringBuilder (2 of 2)"

This commit is contained in:
Shawn Pearce
2013-12-09 05:03:32 +00:00
committed by Gerrit Code Review
11 changed files with 48 additions and 43 deletions

View File

@@ -519,9 +519,9 @@ public class CommitValidators {
PersonIdent who, IdentifiedUser currentUser, String canonicalWebUrl) {
StringBuilder sb = new StringBuilder();
sb.append("\n");
sb.append("ERROR: In commit " + c.name() + "\n");
sb.append("ERROR: " + type + " email address " + who.getEmailAddress()
+ "\n");
sb.append("ERROR: In commit ").append(c.name()).append("\n");
sb.append("ERROR: ").append(type).append(" email address ")
.append(who.getEmailAddress()).append("\n");
sb.append("ERROR: does not match your user account.\n");
sb.append("ERROR:\n");
if (currentUser.getEmailAddresses().isEmpty()) {
@@ -529,14 +529,14 @@ public class CommitValidators {
} else {
sb.append("ERROR: The following addresses are currently registered:\n");
for (String address : currentUser.getEmailAddresses()) {
sb.append("ERROR: " + address + "\n");
sb.append("ERROR: ").append(address).append("\n");
}
}
sb.append("ERROR:\n");
if (canonicalWebUrl != null) {
sb.append("ERROR: To register an email address, please visit:\n");
sb.append("ERROR: " + canonicalWebUrl + "#" + PageLinks.SETTINGS_CONTACT
+ "\n");
sb.append("ERROR: ").append(canonicalWebUrl).append("#")
.append(PageLinks.SETTINGS_CONTACT).append("\n");
}
sb.append("\n");
return new CommitValidationMessage(sb.toString(), false);

View File

@@ -226,9 +226,9 @@ public abstract class ChangeEmail extends NotificationEmail {
StringBuilder detail = new StringBuilder();
if (patchSetInfo != null) {
detail.append(patchSetInfo.getMessage().trim() + "\n");
detail.append(patchSetInfo.getMessage().trim()).append("\n");
} else {
detail.append(change.getSubject().trim() + "\n");
detail.append(change.getSubject().trim()).append("\n");
}
if (patchSet != null) {
@@ -238,7 +238,8 @@ public abstract class ChangeEmail extends NotificationEmail {
if (Patch.COMMIT_MSG.equals(p.getNewName())) {
continue;
}
detail.append(p.getChangeType().getCode() + " " + p.getNewName() + "\n");
detail.append(p.getChangeType().getCode())
.append(" ").append(p.getNewName()).append("\n");
}
detail.append(MessageFormat.format("" //
+ "{0,choice,0#0 files|1#1 file|1<{0} files} changed, " //

View File

@@ -177,8 +177,9 @@ public class SmtpEmailSender implements EmailSender {
for (Address addr : rcpt) {
if (!client.addRecipient(addr.email)) {
String error = client.getReplyString();
rejected.append("Server " + smtpHost + " rejected recipient "
+ addr + ": " + error);
rejected.append("Server ").append(smtpHost)
.append(" rejected recipient ").append(addr)
.append(": ").append(error);
}
}

View File

@@ -170,19 +170,19 @@ public class PatchListLoader extends CacheLoader<PatchListKey, PatchList> {
hdr.append("diff --git");
if (aCommit != null) {
hdr.append(" a/" + Patch.COMMIT_MSG);
hdr.append(" a/").append(Patch.COMMIT_MSG);
} else {
hdr.append(" " + FileHeader.DEV_NULL);
hdr.append(" ").append(FileHeader.DEV_NULL);
}
hdr.append(" b/" + Patch.COMMIT_MSG);
hdr.append(" b/").append(Patch.COMMIT_MSG);
hdr.append("\n");
if (aCommit != null) {
hdr.append("--- a/" + Patch.COMMIT_MSG + "\n");
hdr.append("--- a/").append(Patch.COMMIT_MSG).append("\n");
} else {
hdr.append("--- " + FileHeader.DEV_NULL + "\n");
hdr.append("--- ").append(FileHeader.DEV_NULL).append("\n");
}
hdr.append("+++ b/" + Patch.COMMIT_MSG + "\n");
hdr.append("+++ b/").append(Patch.COMMIT_MSG).append("\n");
Text aText =
aCommit != null ? Text.forCommit(db, reader, aCommit) : Text.EMPTY;

View File

@@ -89,7 +89,7 @@ public class Text extends RawText {
private static void appendPersonIdent(StringBuilder b, String field,
PersonIdent person) {
if (person != null) {
b.append(field + ": ");
b.append(field).append(": ");
if (person.getName() != null) {
b.append(" ");
b.append(person.getName());
@@ -103,7 +103,7 @@ public class Text extends RawText {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss ZZZ");
sdf.setTimeZone(person.getTimeZone());
b.append(field + "Date: ");
b.append(field).append("Date: ");
b.append(sdf.format(person.getWhen()));
b.append("\n");
}

View File

@@ -405,7 +405,7 @@ public abstract class BaseCommand implements Command {
m.append(context.getCommandLine());
if (userProvider.get().isIdentifiedUser()) {
IdentifiedUser u = (IdentifiedUser) userProvider.get();
m.append(" (" + u.getAccount().getUserName() + ")");
m.append(" (").append(u.getAccount().getUserName()).append(")");
}
this.taskName = m.toString();
}

View File

@@ -436,7 +436,8 @@ public class SshDaemon extends SshServer implements SshInfo, LifecycleListener {
final NamedFactory<T> n = find(name, avail);
if (n == null) {
final StringBuilder msg = new StringBuilder();
msg.append("sshd." + key + " = " + name + " unsupported; only ");
msg.append("sshd.").append(key).append(" = ").append(name)
.append(" unsupported; only ");
for (int i = 0; i < avail.length; i++) {
if (avail[i] == null) {
continue;

View File

@@ -130,16 +130,18 @@ final class AdminSetParent extends SshCommand {
if (allProjectsName.equals(nameKey)) {
// Don't allow the wild card project to have a parent.
//
err.append("error: Cannot set parent of '" + name + "'\n");
err.append("error: Cannot set parent of '").append(name).append("'\n");
continue;
}
if (grandParents.contains(nameKey) || nameKey.equals(newParentKey)) {
// Try to avoid creating a cycle in the parent pointers.
//
err.append("error: Cycle exists between '" + name + "' and '"
+ (newParentKey != null ? newParentKey.get() : allProjectsName.get())
+ "'\n");
err.append("error: Cycle exists between '")
.append(name)
.append("' and '")
.append(newParentKey != null ? newParentKey.get() : allProjectsName.get())
.append("'\n");
continue;
}
@@ -155,15 +157,15 @@ final class AdminSetParent extends SshCommand {
md.close();
}
} catch (RepositoryNotFoundException notFound) {
err.append("error: Project " + name + " not found\n");
err.append("error: Project ").append(name).append(" not found\n");
} catch (IOException e) {
final String msg = "Cannot update project " + name;
log.error(msg, e);
err.append("error: " + msg + "\n");
err.append("error: ").append(msg).append("\n");
} catch (ConfigInvalidException e) {
final String msg = "Cannot update project " + name;
log.error(msg, e);
err.append("error: " + msg + "\n");
err.append("error: ").append(msg).append("\n");
}
projectCache.evict(nameKey);

View File

@@ -105,8 +105,8 @@ final class Receive extends AbstractGitCommand {
// we want to present this error to the user
if (badStream.getCause() instanceof TooLargeObjectInPackException) {
StringBuilder msg = new StringBuilder();
msg.append("Receive error on project \""
+ projectControl.getProject().getName() + "\"");
msg.append("Receive error on project \"")
.append(projectControl.getProject().getName()).append("\"");
msg.append(" (user ");
msg.append(currentUser.getAccount().getUserName());
msg.append(" account ");
@@ -121,10 +121,10 @@ final class Receive extends AbstractGitCommand {
// Log what the heck is going on, as detailed as we can.
//
StringBuilder msg = new StringBuilder();
msg.append("Unpack error on project \""
+ projectControl.getProject().getName() + "\":\n");
msg.append("Unpack error on project \"")
.append(projectControl.getProject().getName()).append("\":\n");
msg.append(" AdvertiseRefsHook: " + rp.getAdvertiseRefsHook());
msg.append(" AdvertiseRefsHook: ").append(rp.getAdvertiseRefsHook());
if (rp.getAdvertiseRefsHook() == AdvertiseRefsHook.DEFAULT) {
msg.append("DEFAULT");
} else if (rp.getAdvertiseRefsHook() instanceof VisibleRefFilter) {
@@ -136,10 +136,10 @@ final class Receive extends AbstractGitCommand {
if (rp.getAdvertiseRefsHook() instanceof VisibleRefFilter) {
Map<String, Ref> adv = rp.getAdvertisedRefs();
msg.append(" Visible references (" + adv.size() + "):\n");
msg.append(" Visible references (").append(adv.size()).append("):\n");
for (Ref ref : adv.values()) {
msg.append(" - " + ref.getObjectId().abbreviate(8).name() + " "
+ ref.getName() + "\n");
msg.append(" - ").append(ref.getObjectId().abbreviate(8).name())
.append(" ").append(ref.getName()).append("\n");
}
Map<String, Ref> allRefs =
@@ -151,10 +151,10 @@ final class Receive extends AbstractGitCommand {
}
}
msg.append(" Hidden references (" + hidden.size() + "):\n");
msg.append(" Hidden references (").append(hidden.size()).append("):\n");
for (Ref ref : hidden) {
msg.append(" - " + ref.getObjectId().abbreviate(8).name() + " "
+ ref.getName() + "\n");
msg.append(" - ").append(ref.getObjectId().abbreviate(8).name())
.append(" ").append(ref.getName()).append("\n");
}
}

View File

@@ -203,7 +203,7 @@ final class ScpCommand extends BaseCommand {
buf.append(TYPE_FILE);
break;
}
buf.append("0" + Integer.toOctalString(dir.getMode())); // perms
buf.append("0").append(Integer.toOctalString(dir.getMode())); // perms
buf.append(" ");
buf.append(len); // length
buf.append(" ");

View File

@@ -160,15 +160,15 @@ final class SetProjectCommand extends SshCommand {
md.close();
}
} catch (RepositoryNotFoundException notFound) {
err.append("error: Project " + name + " not found\n");
err.append("error: Project ").append(name).append(" not found\n");
} catch (IOException e) {
final String msg = "Cannot update project " + name;
log.error(msg, e);
err.append("error: " + msg + "\n");
err.append("error: ").append(msg).append("\n");
} catch (ConfigInvalidException e) {
final String msg = "Cannot update project " + name;
log.error(msg, e);
err.append("error: " + msg + "\n");
err.append("error: ").append(msg).append("\n");
}
projectCache.evict(ctlProject);