Fix some Error Prone warnings
@@ -30,7 +30,7 @@ public class CommandLineFlagsTest {
// TODO(eaftan): Disallow passing both -lines and -offset/-length, like clang-format.
@Test
- public void formatInPlaceRequiresAtLeastOneFile() {
+ public void formatInPlaceRequiresAtLeastOneFile() throws UsageException {
try {
Main.processArgs("-i");
fail();
@@ -45,21 +45,13 @@ public class CommandLineFlagsTest {
// expected
}
- try {
Main.processArgs("-i", "Foo.java");
Main.processArgs("-i", "Foo.java", "Bar.java");
- } catch (UsageException e) {
- fail();
- }
}
@Test
- public void formatASubsetRequiresExactlyOneFile() {
- try {
+ public void formatASubsetRequiresExactlyOneFile() throws UsageException {
Main.processArgs("-lines", "10", "Foo.java");
- } catch (UsageException e) {
- fail();
- }
try {
Main.processArgs("-lines", "10");
@@ -75,11 +67,7 @@ public class CommandLineFlagsTest {
// expected
}
- try {
Main.processArgs("-offset", "10", "-length", "10", "Foo.java");
- } catch (UsageException e) {
- fail();
- }
try {
Main.processArgs("-offset", "10", "-length", "10");
@@ -99,12 +87,8 @@ public class CommandLineFlagsTest {
// TODO(eaftan): clang-format allows a single offset with no length, which means to format
// up to the end of the file. We should match that behavior.
@Test
- public void numberOfOffsetsMustMatchNumberOfLengths() {
- try {
+ public void numberOfOffsetsMustMatchNumberOfLengths() throws UsageException {
Main.processArgs("-offset", "10", "-length", "20", "Foo.java");
- } catch (UsageException e) {
- fail();
- }
try {
Main.processArgs("-offset", "10", "-length", "20", "-offset", "50", "Foo.java");
@@ -122,18 +106,10 @@ public class CommandLineFlagsTest {
}
@Test
- public void noFilesToFormatRequiresEitherHelpOrVersion() {
- try {
+ public void noFilesToFormatRequiresEitherHelpOrVersion() throws UsageException {
Main.processArgs("-version");
- } catch (UsageException e) {
- fail();
- }
- try {
Main.processArgs("-help");
- } catch (UsageException e) {
- fail();
- }
try {
Main.processArgs();
