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.pgm/src/org | |
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.pgm/src/org')
5 files changed, 22 insertions, 31 deletions
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/console/ConsoleCredentialsProvider.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/console/ConsoleCredentialsProvider.java index f8442facb7..039d0946b2 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/console/ConsoleCredentialsProvider.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/console/ConsoleCredentialsProvider.java @@ -136,18 +136,15 @@ public class ConsoleCredentialsProvider extends CredentialsProvider { if (v != null) { item.setValue(new String(v)); return true; - } else { - return false; - } - } else { - String v = cons.readLine("%s: ", item.getPromptText()); //$NON-NLS-1$ - if (v != null) { - item.setValue(v); - return true; - } else { - return false; } + return false; + } + String v = cons.readLine("%s: ", item.getPromptText()); //$NON-NLS-1$ + if (v != null) { + item.setValue(v); + return true; } + return false; } private boolean get(CredentialItem.CharArrayType item) { @@ -156,18 +153,15 @@ public class ConsoleCredentialsProvider extends CredentialsProvider { if (v != null) { item.setValueNoCopy(v); return true; - } else { - return false; - } - } else { - String v = cons.readLine("%s: ", item.getPromptText()); //$NON-NLS-1$ - if (v != null) { - item.setValueNoCopy(v.toCharArray()); - return true; - } else { - return false; } + return false; + } + String v = cons.readLine("%s: ", item.getPromptText()); //$NON-NLS-1$ + if (v != null) { + item.setValueNoCopy(v.toCharArray()); + return true; } + return false; } private boolean get(CredentialItem.InformationalMessage item) { @@ -182,8 +176,7 @@ public class ConsoleCredentialsProvider extends CredentialsProvider { if (r != null) { item.setValue(CLIText.get().answerYes.equalsIgnoreCase(r)); return true; - } else { - return false; } + return false; } } diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Status.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Status.java index c3887fe9c3..23ee9337b6 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Status.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Status.java @@ -306,8 +306,8 @@ class Status extends TextBuiltin { } outw.flush(); return list.size(); - } else - return 0; + } + return 0; } /** diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildCommitGraph.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildCommitGraph.java index 8948c27537..0d30f3661c 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildCommitGraph.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildCommitGraph.java @@ -189,9 +189,8 @@ class RebuildCommitGraph extends TextBuiltin { // rewritten. queue.add(t); continue REWRITE; - } else { - newParents[k] = p.newId; } + newParents[k] = p.newId; } else { // We have the old parent object. Use it. // diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/TextHashFunctions.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/TextHashFunctions.java index a2ea8c20b4..1242bb754b 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/TextHashFunctions.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/TextHashFunctions.java @@ -138,9 +138,8 @@ class TextHashFunctions extends TextBuiltin { Arrays.fill(buf16, (byte) 0); System.arraycopy(raw, ptr, buf16, 0, end - ptr); return rabin(buf16, 0); - } else { - return rabin(raw, ptr); } + return rabin(raw, ptr); } private int rabin(byte[] raw, int ptr) { diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/CmdLineParser.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/CmdLineParser.java index b97aa5b7af..d3aa38cf23 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/CmdLineParser.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/CmdLineParser.java @@ -299,10 +299,10 @@ public class CmdLineParser extends org.kohsuke.args4j.CmdLineParser { /** {@inheritDoc} */ @Override protected OptionHandler createOptionHandler(OptionDef o, Setter setter) { - if (o instanceof NamedOptionDef) + if (o instanceof NamedOptionDef) { return super.createOptionHandler(o, setter); - else - return super.createOptionHandler(new MyOptionDef(o), setter); + } + return super.createOptionHandler(new MyOptionDef(o), setter); } |