Format all Java files with google-java-format
Having a standard tool for formatting saves reviewers' valuable time. google-java-format is Google's standard formatter and is somewhat inspired by gofmt[1]. This commit formats everything using google-java-format version 1.2. The downside of this one-off formatting is breaking blame. This can be somewhat hacked around with a tool like git-hyper-blame[2], but it's definitely not optimal until/unless this kind of feature makes its way to git core. Not in this change: * Tool support, e.g. Eclipse. The command must be run manually [3]. * Documentation of best practice, e.g. new 100-column default. [1] https://talks.golang.org/2015/gofmt-en.slide#3 [2] https://commondatastorage.googleapis.com/chrome-infra-docs/flat/depot_tools/docs/html/git-hyper-blame.html [3] git ls-files | grep java$ | xargs google-java-format -i Change-Id: Id5f3c6de95ce0b68b41f0a478b5c99a93675aaa3 Signed-off-by: David Pursehouse <dpursehouse@collab.net>
This commit is contained in:
committed by
David Pursehouse
parent
6723b6d0fa
commit
292fa154c1
@@ -17,9 +17,8 @@ package com.google.gerrit.server.util;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.HashSet;
|
||||
import org.junit.Test;
|
||||
|
||||
public class IdGeneratorTest {
|
||||
@Test
|
||||
|
||||
@@ -79,15 +79,10 @@ public class LabelVoteTest {
|
||||
|
||||
@Test
|
||||
public void formatWithEquals() {
|
||||
assertEquals("Code-Review=-2",
|
||||
LabelVote.parseWithEquals("Code-Review=-2").formatWithEquals());
|
||||
assertEquals("Code-Review=-1",
|
||||
LabelVote.parseWithEquals("Code-Review=-1").formatWithEquals());
|
||||
assertEquals("Code-Review=0",
|
||||
LabelVote.parseWithEquals("Code-Review=0").formatWithEquals());
|
||||
assertEquals("Code-Review=+1",
|
||||
LabelVote.parseWithEquals("Code-Review=+1").formatWithEquals());
|
||||
assertEquals("Code-Review=+2",
|
||||
LabelVote.parseWithEquals("Code-Review=+2").formatWithEquals());
|
||||
assertEquals("Code-Review=-2", LabelVote.parseWithEquals("Code-Review=-2").formatWithEquals());
|
||||
assertEquals("Code-Review=-1", LabelVote.parseWithEquals("Code-Review=-1").formatWithEquals());
|
||||
assertEquals("Code-Review=0", LabelVote.parseWithEquals("Code-Review=0").formatWithEquals());
|
||||
assertEquals("Code-Review=+1", LabelVote.parseWithEquals("Code-Review=+1").formatWithEquals());
|
||||
assertEquals("Code-Review=+2", LabelVote.parseWithEquals("Code-Review=+2").formatWithEquals());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,9 +33,8 @@ public class MostSpecificComparatorTest {
|
||||
}
|
||||
|
||||
/**
|
||||
* Assuming two patterns have the same Levenshtein distance,
|
||||
* the pattern which represents a finite language wins over a pattern
|
||||
* which represents an infinite language.
|
||||
* Assuming two patterns have the same Levenshtein distance, the pattern which represents a finite
|
||||
* language wins over a pattern which represents an infinite language.
|
||||
*/
|
||||
@Test
|
||||
public void finiteWinsOverInfinite() {
|
||||
@@ -45,9 +44,8 @@ public class MostSpecificComparatorTest {
|
||||
}
|
||||
|
||||
/**
|
||||
* Assuming two patterns have the same Levenshtein distance
|
||||
* and are both either finite or infinite the one with the higher
|
||||
* number of state transitions (in an equivalent automaton) wins
|
||||
* Assuming two patterns have the same Levenshtein distance and are both either finite or infinite
|
||||
* the one with the higher number of state transitions (in an equivalent automaton) wins
|
||||
*/
|
||||
@Test
|
||||
public void higherNumberOfTransitionsWins() {
|
||||
@@ -65,8 +63,8 @@ public class MostSpecificComparatorTest {
|
||||
}
|
||||
|
||||
/**
|
||||
* Assuming the same Levenshtein distance, (in)finity and the number
|
||||
* of transitions, the longer pattern wins
|
||||
* Assuming the same Levenshtein distance, (in)finity and the number of transitions, the longer
|
||||
* pattern wins
|
||||
*/
|
||||
@Test
|
||||
public void longerPatternWins() {
|
||||
|
||||
@@ -29,14 +29,14 @@ import org.parboiled.support.ParsingResult;
|
||||
public class ParboiledTest {
|
||||
|
||||
private static final String EXPECTED =
|
||||
"[Expression] '42'\n" +
|
||||
" [Term] '42'\n" +
|
||||
" [Factor] '42'\n" +
|
||||
" [Number] '42'\n" +
|
||||
" [0..9] '4'\n" +
|
||||
" [0..9] '2'\n" +
|
||||
" [zeroOrMore]\n" +
|
||||
" [zeroOrMore]\n";
|
||||
"[Expression] '42'\n"
|
||||
+ " [Term] '42'\n"
|
||||
+ " [Factor] '42'\n"
|
||||
+ " [Number] '42'\n"
|
||||
+ " [0..9] '4'\n"
|
||||
+ " [0..9] '2'\n"
|
||||
+ " [zeroOrMore]\n"
|
||||
+ " [zeroOrMore]\n";
|
||||
|
||||
private CalculatorParser parser;
|
||||
|
||||
@@ -47,8 +47,7 @@ public class ParboiledTest {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
ParsingResult<String> result =
|
||||
new ReportingParseRunner<String>(parser.Expression()).run("42");
|
||||
ParsingResult<String> result = new ReportingParseRunner<String>(parser.Expression()).run("42");
|
||||
assertThat(result.isSuccess()).isTrue();
|
||||
// next test is optional; we could stop here.
|
||||
assertThat(ParseTreeUtils.printNodeTree(result)).isEqualTo(EXPECTED);
|
||||
|
||||
@@ -20,10 +20,8 @@ import static org.junit.Assert.assertTrue;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Ordering;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
import org.junit.Test;
|
||||
|
||||
public class RegexListSearcherTest {
|
||||
private static final List<String> EMPTY = ImmutableList.of();
|
||||
@@ -55,30 +53,20 @@ public class RegexListSearcherTest {
|
||||
List<String> list = ImmutableList.of("bar", "foo", "quux");
|
||||
assertSearchReturns(ImmutableList.of("foo"), "f.*", list);
|
||||
assertSearchReturns(ImmutableList.of("foo"), ".*o.*", list);
|
||||
assertSearchReturns(ImmutableList.of("bar", "foo", "quux"), ".*[aou].*",
|
||||
list);
|
||||
assertSearchReturns(ImmutableList.of("bar", "foo", "quux"), ".*[aou].*", list);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void commonPrefix() {
|
||||
List<String> list = ImmutableList.of(
|
||||
"bar",
|
||||
"baz",
|
||||
"foo1",
|
||||
"foo2",
|
||||
"foo3",
|
||||
"quux");
|
||||
List<String> list = ImmutableList.of("bar", "baz", "foo1", "foo2", "foo3", "quux");
|
||||
assertSearchReturns(ImmutableList.of("bar", "baz"), "b.*", list);
|
||||
assertSearchReturns(ImmutableList.of("foo1", "foo2"), "foo[12]", list);
|
||||
assertSearchReturns(ImmutableList.of("foo1", "foo2", "foo3"), "foo.*",
|
||||
list);
|
||||
assertSearchReturns(ImmutableList.of("foo1", "foo2", "foo3"), "foo.*", list);
|
||||
assertSearchReturns(ImmutableList.of("quux"), "q.*", list);
|
||||
}
|
||||
|
||||
private void assertSearchReturns(List<?> expected, String re,
|
||||
List<String> inputs) {
|
||||
private void assertSearchReturns(List<?> expected, String re, List<String> inputs) {
|
||||
assertTrue(Ordering.natural().isOrdered(inputs));
|
||||
assertEquals(expected,
|
||||
ImmutableList.copyOf(RegexListSearcher.ofStrings(re).search(inputs)));
|
||||
assertEquals(expected, ImmutableList.copyOf(RegexListSearcher.ofStrings(re).search(inputs)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,14 +25,12 @@ import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import com.google.gerrit.testutil.GerritBaseTests;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.net.Inet4Address;
|
||||
import java.net.Inet6Address;
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import org.junit.Test;
|
||||
|
||||
public class SocketUtilTest extends GerritBaseTests {
|
||||
@Test
|
||||
@@ -61,15 +59,19 @@ public class SocketUtilTest extends GerritBaseTests {
|
||||
assertEquals("foo:1234", SocketUtil.format(createUnresolved("foo", 1234), 80));
|
||||
assertEquals("foo", SocketUtil.format(createUnresolved("foo", 80), 80));
|
||||
|
||||
assertEquals("[1:2:3:4:5:6:7:8]:1234",//
|
||||
assertEquals(
|
||||
"[1:2:3:4:5:6:7:8]:1234", //
|
||||
SocketUtil.format(new InetSocketAddress(getByName("1:2:3:4:5:6:7:8"), 1234), 80));
|
||||
assertEquals("[1:2:3:4:5:6:7:8]",//
|
||||
assertEquals(
|
||||
"[1:2:3:4:5:6:7:8]", //
|
||||
SocketUtil.format(new InetSocketAddress(getByName("1:2:3:4:5:6:7:8"), 80), 80));
|
||||
|
||||
assertEquals("localhost:1234",//
|
||||
assertEquals(
|
||||
"localhost:1234", //
|
||||
SocketUtil.format(new InetSocketAddress("localhost", 1234), 80));
|
||||
assertEquals("localhost",//
|
||||
SocketUtil. format(new InetSocketAddress("localhost", 80), 80));
|
||||
assertEquals(
|
||||
"localhost", //
|
||||
SocketUtil.format(new InetSocketAddress("localhost", 80), 80));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -79,19 +81,25 @@ public class SocketUtilTest extends GerritBaseTests {
|
||||
assertEquals(new InetSocketAddress(1234), parse(":1234", 80));
|
||||
assertEquals(new InetSocketAddress(80), parse("", 80));
|
||||
|
||||
assertEquals(createUnresolved("1:2:3:4:5:6:7:8", 1234), //
|
||||
assertEquals(
|
||||
createUnresolved("1:2:3:4:5:6:7:8", 1234), //
|
||||
parse("[1:2:3:4:5:6:7:8]:1234", 80));
|
||||
assertEquals(createUnresolved("1:2:3:4:5:6:7:8", 80), //
|
||||
assertEquals(
|
||||
createUnresolved("1:2:3:4:5:6:7:8", 80), //
|
||||
parse("[1:2:3:4:5:6:7:8]", 80));
|
||||
|
||||
assertEquals(createUnresolved("localhost", 1234), //
|
||||
assertEquals(
|
||||
createUnresolved("localhost", 1234), //
|
||||
parse("[localhost]:1234", 80));
|
||||
assertEquals(createUnresolved("localhost", 80), //
|
||||
assertEquals(
|
||||
createUnresolved("localhost", 80), //
|
||||
parse("[localhost]", 80));
|
||||
|
||||
assertEquals(createUnresolved("foo.bar.example.com", 1234), //
|
||||
assertEquals(
|
||||
createUnresolved("foo.bar.example.com", 1234), //
|
||||
parse("[foo.bar.example.com]:1234", 80));
|
||||
assertEquals(createUnresolved("foo.bar.example.com", 80), //
|
||||
assertEquals(
|
||||
createUnresolved("foo.bar.example.com", 80), //
|
||||
parse("[foo.bar.example.com]", 80));
|
||||
}
|
||||
|
||||
@@ -116,14 +124,18 @@ public class SocketUtilTest extends GerritBaseTests {
|
||||
assertEquals(new InetSocketAddress(1234), resolve(":1234", 80));
|
||||
assertEquals(new InetSocketAddress(80), resolve("", 80));
|
||||
|
||||
assertEquals(new InetSocketAddress(getByName("1:2:3:4:5:6:7:8"), 1234), //
|
||||
assertEquals(
|
||||
new InetSocketAddress(getByName("1:2:3:4:5:6:7:8"), 1234), //
|
||||
resolve("[1:2:3:4:5:6:7:8]:1234", 80));
|
||||
assertEquals(new InetSocketAddress(getByName("1:2:3:4:5:6:7:8"), 80), //
|
||||
assertEquals(
|
||||
new InetSocketAddress(getByName("1:2:3:4:5:6:7:8"), 80), //
|
||||
resolve("[1:2:3:4:5:6:7:8]", 80));
|
||||
|
||||
assertEquals(new InetSocketAddress(getByName("localhost"), 1234), //
|
||||
assertEquals(
|
||||
new InetSocketAddress(getByName("localhost"), 1234), //
|
||||
resolve("[localhost]:1234", 80));
|
||||
assertEquals(new InetSocketAddress(getByName("localhost"), 80), //
|
||||
assertEquals(
|
||||
new InetSocketAddress(getByName("localhost"), 80), //
|
||||
resolve("[localhost]", 80));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user