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

View File

@@ -226,9 +226,9 @@ public abstract class ChangeEmail extends NotificationEmail {
StringBuilder detail = new StringBuilder(); StringBuilder detail = new StringBuilder();
if (patchSetInfo != null) { if (patchSetInfo != null) {
detail.append(patchSetInfo.getMessage().trim() + "\n"); detail.append(patchSetInfo.getMessage().trim()).append("\n");
} else { } else {
detail.append(change.getSubject().trim() + "\n"); detail.append(change.getSubject().trim()).append("\n");
} }
if (patchSet != null) { if (patchSet != null) {
@@ -238,7 +238,8 @@ public abstract class ChangeEmail extends NotificationEmail {
if (Patch.COMMIT_MSG.equals(p.getNewName())) { if (Patch.COMMIT_MSG.equals(p.getNewName())) {
continue; continue;
} }
detail.append(p.getChangeType().getCode() + " " + p.getNewName() + "\n"); detail.append(p.getChangeType().getCode())
.append(" ").append(p.getNewName()).append("\n");
} }
detail.append(MessageFormat.format("" // detail.append(MessageFormat.format("" //
+ "{0,choice,0#0 files|1#1 file|1<{0} files} changed, " // + "{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) { for (Address addr : rcpt) {
if (!client.addRecipient(addr.email)) { if (!client.addRecipient(addr.email)) {
String error = client.getReplyString(); String error = client.getReplyString();
rejected.append("Server " + smtpHost + " rejected recipient " rejected.append("Server ").append(smtpHost)
+ addr + ": " + error); .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"); hdr.append("diff --git");
if (aCommit != null) { if (aCommit != null) {
hdr.append(" a/" + Patch.COMMIT_MSG); hdr.append(" a/").append(Patch.COMMIT_MSG);
} else { } 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"); hdr.append("\n");
if (aCommit != null) { if (aCommit != null) {
hdr.append("--- a/" + Patch.COMMIT_MSG + "\n"); hdr.append("--- a/").append(Patch.COMMIT_MSG).append("\n");
} else { } 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 = Text aText =
aCommit != null ? Text.forCommit(db, reader, aCommit) : Text.EMPTY; 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, private static void appendPersonIdent(StringBuilder b, String field,
PersonIdent person) { PersonIdent person) {
if (person != null) { if (person != null) {
b.append(field + ": "); b.append(field).append(": ");
if (person.getName() != null) { if (person.getName() != null) {
b.append(" "); b.append(" ");
b.append(person.getName()); b.append(person.getName());
@@ -103,7 +103,7 @@ public class Text extends RawText {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss ZZZ"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss ZZZ");
sdf.setTimeZone(person.getTimeZone()); sdf.setTimeZone(person.getTimeZone());
b.append(field + "Date: "); b.append(field).append("Date: ");
b.append(sdf.format(person.getWhen())); b.append(sdf.format(person.getWhen()));
b.append("\n"); b.append("\n");
} }

View File

@@ -405,7 +405,7 @@ public abstract class BaseCommand implements Command {
m.append(context.getCommandLine()); m.append(context.getCommandLine());
if (userProvider.get().isIdentifiedUser()) { if (userProvider.get().isIdentifiedUser()) {
IdentifiedUser u = (IdentifiedUser) userProvider.get(); IdentifiedUser u = (IdentifiedUser) userProvider.get();
m.append(" (" + u.getAccount().getUserName() + ")"); m.append(" (").append(u.getAccount().getUserName()).append(")");
} }
this.taskName = m.toString(); 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); final NamedFactory<T> n = find(name, avail);
if (n == null) { if (n == null) {
final StringBuilder msg = new StringBuilder(); 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++) { for (int i = 0; i < avail.length; i++) {
if (avail[i] == null) { if (avail[i] == null) {
continue; continue;

View File

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

View File

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

View File

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

View File

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