Fix some statically detected code issues

This includes: unnecessary semicolons, suppress warnings, switch statements, final/private qualifiers, Optional wrapping, conditionals, both inline and non-inline variables, ternaries, Collection putAll() calls, StringBuilders, and throws declarations.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=244182539
This commit is contained in:
mcilwain 2019-04-18 07:34:10 -07:00 committed by jianglai
parent 9f360587ff
commit 24bb78bd16
54 changed files with 107 additions and 158 deletions

View file

@ -51,9 +51,10 @@ public final class SoyTemplateUtils {
for (SoyFileInfo soyInfo : soyInfos) {
builder.add(getResource(soyInfo.getClass(), soyInfo.getFileName()));
}
Map<String, Object> globals = new HashMap<>();
Map<String, Object> globals;
try {
globals.putAll(SoyUtils.parseCompileTimeGlobals(asCharSource(SOY_GLOBALS, UTF_8)));
globals =
new HashMap<>(SoyUtils.parseCompileTimeGlobals(asCharSource(SOY_GLOBALS, UTF_8)));
} catch (IOException e) {
throw new RuntimeException("Failed to load soy globals", e);
}

View file

@ -351,22 +351,18 @@ public final class ConsoleRegistrarCreatorAction implements Runnable {
return;
}
String environment = Ascii.toLowerCase(String.valueOf(registryEnvironment));
StringBuilder builder = new StringBuilder();
builder
.append(
String.format(
String body =
String.format(
"The following registrar was created in %s by %s:\n",
environment, registrarAccessor.userIdForLogging()))
.append(toEmailLine(clientId, "clientId"))
.append(toEmailLine(name, "name"))
.append(toEmailLine(billingAccount, "billingAccount"))
.append(toEmailLine(ianaId, "ianaId"))
.append(toEmailLine(referralEmail, "referralEmail"))
.append(toEmailLine(driveId, "driveId"))
.append(
String.format("Gave user %s web access to the registrar\n", consoleUserEmail.get()));
environment, registrarAccessor.userIdForLogging())
+ toEmailLine(clientId, "clientId")
+ toEmailLine(name, "name")
+ toEmailLine(billingAccount, "billingAccount")
+ toEmailLine(ianaId, "ianaId")
+ toEmailLine(referralEmail, "referralEmail")
+ toEmailLine(driveId, "driveId")
+ String.format("Gave user %s web access to the registrar\n", consoleUserEmail.get());
sendEmailUtils.sendEmail(
String.format("Registrar %s created in %s", clientId.get(), environment),
builder.toString());
String.format("Registrar %s created in %s", clientId.get(), environment), body);
}
}

View file

@ -246,8 +246,7 @@ public class RegistrarSettingsAction implements Runnable, JsonActionRunner.JsonA
.map(RegistrarContact::toDiffableFieldMap)
.collect(toImmutableSet());
// Use LinkedHashMap here to preserve ordering; null values mean we can't use ImmutableMap.
LinkedHashMap<String, Object> result = new LinkedHashMap<>();
result.putAll(registrar.toDiffableFieldMap());
LinkedHashMap<String, Object> result = new LinkedHashMap<>(registrar.toDiffableFieldMap());
result.put("contacts", expandedContacts);
return result;
}