Add missing trailing comma on array declarations

Enable the CheckStyle warning and fix occurences of it.

Note that the check allows leaving out the comma at the end if both
the left and right curly brackets are on the same line [1].

Also re-wrap some declarations for better readability, and remove
redundant "//" comments.

[1] http://checkstyle.sourceforge.net/config_coding.html#ArrayTrailingComma

Change-Id: Ieeb837724ac699aa5a71861c3887bcfda1941939
This commit is contained in:
David Pursehouse 2016-04-12 16:23:58 +09:00
parent 92ba0dd270
commit f785d862d3
12 changed files with 29 additions and 24 deletions

View File

@ -151,7 +151,7 @@ public class GerritServer {
public Void call() throws Exception {
int rc = daemon.main(new String[] {
"-d", site.getPath(),
"--headless", "--console-log", "--show-stack-trace"});
"--headless", "--console-log", "--show-stack-trace",});
if (rc != 0) {
System.err.println("Failed to start Gerrit daemon");
serverStarted.reset();
@ -172,7 +172,7 @@ public class GerritServer {
Init init = new Init();
int rc = init.main(new String[] {
"-d", tmp.getPath(), "--batch", "--no-auto-start",
"--skip-plugins"});
"--skip-plugins",});
if (rc != 0) {
throw new RuntimeException("Couldn't initialize site");
}

View File

@ -37,7 +37,7 @@ import java.util.TreeSet;
class Actions extends Composite {
private static final String[] CORE = {
"abandon", "cherrypick", "followup", "hashtags", "publish",
"rebase", "restore", "revert", "submit", "topic", "/"};
"rebase", "restore", "revert", "submit", "topic", "/",};
interface Binder extends UiBinder<FlowPanel, Actions> {}
private static final Binder uiBinder = GWT.create(Binder.class);

View File

@ -32,7 +32,7 @@ public class Vim extends JavaScriptObject {
}
for (String key : new String[] {
"Ctrl-C", "Ctrl-O", "Ctrl-P", "Ctrl-S",
"Ctrl-F", "Ctrl-B", "Ctrl-R"}) {
"Ctrl-F", "Ctrl-B", "Ctrl-R",}) {
km.propagate(key);
}
for (int i = 0; i <= 9; i++) {

View File

@ -212,7 +212,7 @@ class ProjectDigestFilter implements Filter {
private static final char[] LHEX =
{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', //
'a', 'b', 'c', 'd', 'e', 'f'};
'a', 'b', 'c', 'd', 'e', 'f',};
private static String LHEX(byte[] bin) {
StringBuilder r = new StringBuilder(bin.length * 2);

View File

@ -134,7 +134,7 @@ public class JythonShell {
new Class[] { String.class, pyObject },
new Object[] { getDefaultBanner() +
" running for Gerrit " + com.google.gerrit.common.Version.getVersion(),
null });
null, });
}
public void set(String key, Object content) {

View File

@ -105,22 +105,22 @@ class InitSshd implements InitStep {
System.err.print(" rsa...");
System.err.flush();
Runtime.getRuntime().exec(new String[] {"ssh-keygen", //
"-q" /* quiet */, //
"-t", "rsa", //
"-P", "", //
"-C", comment, //
"-f", site.ssh_rsa.toAbsolutePath().toString() //
Runtime.getRuntime().exec(new String[] {"ssh-keygen",
"-q" /* quiet */,
"-t", "rsa",
"-P", "",
"-C", comment,
"-f", site.ssh_rsa.toAbsolutePath().toString(),
}).waitFor();
System.err.print(" dsa...");
System.err.flush();
Runtime.getRuntime().exec(new String[] {"ssh-keygen", //
"-q" /* quiet */, //
"-t", "dsa", //
"-P", "", //
"-C", comment, //
"-f", site.ssh_dsa.toAbsolutePath().toString() //
Runtime.getRuntime().exec(new String[] {"ssh-keygen",
"-q" /* quiet */,
"-t", "dsa",
"-P", "",
"-C", comment,
"-f", site.ssh_dsa.toAbsolutePath().toString(),
}).waitFor();
} else {

View File

@ -26,7 +26,7 @@ public class StringUtil {
{ "\\x00", "\\x01", "\\x02", "\\x03", "\\x04", "\\x05", "\\x06", "\\a",
"\\b", "\\t", "\\n", "\\v", "\\f", "\\r", "\\x0e", "\\x0f",
"\\x10", "\\x11", "\\x12", "\\x13", "\\x14", "\\x15", "\\x16", "\\x17",
"\\x18", "\\x19", "\\x1a", "\\x1b", "\\x1c", "\\x1d", "\\x1e", "\\x1f" };
"\\x18", "\\x19", "\\x1a", "\\x1b", "\\x1c", "\\x1d", "\\x1e", "\\x1f", };
/**
* Escapes the input string so that all non-printable characters

View File

@ -53,8 +53,12 @@ public class GitwebCgiConfig {
String cfgCgi = cfg.getString("gitweb", null, "cgi");
Path pkgCgi = Paths.get("/usr/lib/cgi-bin/gitweb.cgi");
String[] resourcePaths = {"/usr/share/gitweb/static", "/usr/share/gitweb",
"/var/www/static", "/var/www"};
String[] resourcePaths = {
"/usr/share/gitweb/static",
"/usr/share/gitweb",
"/var/www/static",
"/var/www",
};
Path cgi;
if (cfgCgi != null) {

View File

@ -60,7 +60,7 @@ public class IdentifiedUserTest {
private static final String[] TEST_CASES = {
"",
"FirstName.LastName@Corporation.com",
"!#$%&'+-/=.?^`{|}~@[IPv6:0123:4567:89AB:CDEF:0123:4567:89AB:CDEF]"
"!#$%&'+-/=.?^`{|}~@[IPv6:0123:4567:89AB:CDEF:0123:4567:89AB:CDEF]",
};
@Before

View File

@ -51,7 +51,7 @@ public class StringUtilTest {
"string with 'quotes'", "string with 'quotes'",
"C:\\Program Files\\MyProgram", "C:\\\\Program Files\\\\MyProgram",
"string\nwith\nnewlines", "string\\nwith\\nnewlines",
"string\twith\ttabs", "string\\twith\\ttabs" };
"string\twith\ttabs", "string\\twith\\ttabs", };
for (int i = 0; i < testPairs.length; i += 2) {
assertEquals(StringUtil.escapeString(testPairs[i]), testPairs[i + 1]);
}

View File

@ -156,6 +156,6 @@ public class BasicSerializationTest {
private static byte[] b(int a, int b, int c, int d, int e, int f, int g, int h) {
return new byte[] {(byte) a, (byte) b, (byte) c, (byte) d, //
(byte) e, (byte) f, (byte) g, (byte) h};
(byte) e, (byte) f, (byte) g, (byte) h,};
}
}

View File

@ -96,6 +96,7 @@ edited to remove noisy warnings.
<module name="RedundantImport"/>
<module name="RedundantModifier"/>
<module name="ExplicitInitialization"/>
<module name="ArrayTrailingComma"/>
</module>
<module name="FileTabCharacter">
<property name="severity" value="ignore"/>