diff options
author | David Pursehouse <david.pursehouse@gmail.com> | 2019-10-17 09:01:25 +0900 |
---|---|---|
committer | David Pursehouse <david.pursehouse@gmail.com> | 2019-10-17 10:20:14 +0900 |
commit | 98cdca9b5a830f1c2ceca52379d662a68109d43e (patch) | |
tree | d843141173394b4ea4e435553885749096d4fb79 /org.eclipse.jgit.test/tst | |
parent | 762f6212b4692b28f098ac597058bd6a489b8b49 (diff) | |
download | jgit-98cdca9b5a830f1c2ceca52379d662a68109d43e.tar.gz jgit-98cdca9b5a830f1c2ceca52379d662a68109d43e.zip |
Enable and fix "Statement unnecessarily nested within else clause" warnings
Since [1] the gerrit project includes jgit as a submodule, and has this
warning enabled, resulting in 100s of warnings in the console.
Also enable the warning here, and fix them.
At the same time, add missing braces around adjacent and nearby one-line
blocks.
[1] https://gerrit-review.googlesource.com/c/gerrit/+/227897
Change-Id: I81df3fc7ed6eedf6874ce1a3bedfa727a1897e4c
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
Diffstat (limited to 'org.eclipse.jgit.test/tst')
5 files changed, 17 insertions, 29 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/PackFileSnapshotTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/PackFileSnapshotTest.java index d5bc61a692..9016a02b0b 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/PackFileSnapshotTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/PackFileSnapshotTest.java @@ -295,9 +295,8 @@ public class PackFileSnapshotTest extends RepositoryTestCase { Files.copy(src, dstOut); return dst; } - } else { - return Files.copy(src, dst, StandardCopyOption.REPLACE_EXISTING); } + return Files.copy(src, dst, StandardCopyOption.REPLACE_EXISTING); } private Path copyPack(Path base, String srcSuffix, String dstSuffix) diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ObjectIdSerializerTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ObjectIdSerializerTest.java index d98b792d75..f0733f4782 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ObjectIdSerializerTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ObjectIdSerializerTest.java @@ -88,9 +88,8 @@ public class ObjectIdSerializerTest { try (InputStream in = new FileInputStream(file)) { if (objectId == null) { return ObjectIdSerializer.read(in); - } else { - return ObjectIdSerializer.readWithoutMarker(in); } + return ObjectIdSerializer.readWithoutMarker(in); } } } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RefDatabaseConflictingNamesTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RefDatabaseConflictingNamesTest.java index cbb47fa829..3f77ca25a3 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RefDatabaseConflictingNamesTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RefDatabaseConflictingNamesTest.java @@ -67,9 +67,8 @@ public class RefDatabaseConflictingNamesTest { existing.put("refs/heads/a/b", null /* not used */); existing.put("refs/heads/q", null /* not used */); return existing; - } else { - return Collections.emptyMap(); } + return Collections.emptyMap(); } @Override diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/HttpAuthTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/HttpAuthTest.java index ea15ebe7de..947ca97615 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/HttpAuthTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/HttpAuthTest.java @@ -133,16 +133,15 @@ public class HttpAuthTest { @Override public String getHeaderField(String name) { - if (!headerFields.containsKey(name)) + if (!headerFields.containsKey(name)) { return null; - else { - int n = headerFields.get(name).size(); + } + int n = headerFields.get(name).size(); - if (n > 0) - return headerFields.get(name).get(n - 1); - else - return null; + if (n > 0) { + return headerFields.get(name).get(n - 1); } + return null; } @Override diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/WalkEncryptionTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/WalkEncryptionTest.java index 4750d15b3d..d1d7a1d81d 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/WalkEncryptionTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/WalkEncryptionTest.java @@ -239,9 +239,8 @@ public class WalkEncryptionTest { loadEnvVar(ENV_SECRET_KEY, SECRET_KEY, props); loadEnvVar(ENV_BUCKET_NAME, TEST_BUCKET, props); return props; - } else { - return null; } + return null; } static Properties fromEnvFile() throws Exception { @@ -250,12 +249,10 @@ public class WalkEncryptionTest { props.load(new FileInputStream(ENV_CONFIG_FILE)); if (checkTestProps(props)) { return props; - } else { - throw new Error("Environment config file is incomplete."); } - } else { - return null; + throw new Error("Environment config file is incomplete."); } + return null; } static Properties fromSysProps() { @@ -266,9 +263,8 @@ public class WalkEncryptionTest { loadSysProp(SYS_SECRET_KEY, SECRET_KEY, props); loadSysProp(SYS_BUCKET_NAME, TEST_BUCKET, props); return props; - } else { - return null; } + return null; } static Properties fromSysFile() throws Exception { @@ -277,12 +273,10 @@ public class WalkEncryptionTest { props.load(new FileInputStream(SYS_CONFIG_FILE)); if (checkTestProps(props)) { return props; - } else { - throw new Error("System props config file is incomplete."); } - } else { - return null; + throw new Error("System props config file is incomplete."); } + return null; } static Properties fromConfigFile(String path) throws Exception { @@ -292,12 +286,10 @@ public class WalkEncryptionTest { props.load(new FileInputStream(file)); if (checkTestProps(props)) { return props; - } else { - throw new Error("Props config file is incomplete: " + path); } - } else { - return null; + throw new Error("Props config file is incomplete: " + path); } + return null; } /** |