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.ssh.apache | |
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.ssh.apache')
6 files changed, 14 insertions, 21 deletions
diff --git a/org.eclipse.jgit.ssh.apache/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.jgit.ssh.apache/.settings/org.eclipse.jdt.core.prefs index 13c32a6d94..15ef2aad5d 100644 --- a/org.eclipse.jgit.ssh.apache/.settings/org.eclipse.jdt.core.prefs +++ b/org.eclipse.jgit.ssh.apache/.settings/org.eclipse.jdt.core.prefs @@ -92,7 +92,7 @@ org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning -org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning diff --git a/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/JGitClientSession.java b/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/JGitClientSession.java index 1954abc75b..79bd3faa01 100644 --- a/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/JGitClientSession.java +++ b/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/JGitClientSession.java @@ -179,9 +179,8 @@ public class JGitClientSession extends ClientSessionImpl { } catch (Exception other) { throw new IOException(other.getLocalizedMessage(), other); } - } else { - return super.sendIdentification(ident); } + return super.sendIdentification(ident); } @Override @@ -205,9 +204,8 @@ public class JGitClientSession extends ClientSessionImpl { } catch (Exception other) { throw new IOException(other.getLocalizedMessage(), other); } - } else { - return super.sendKexInit(); } + return super.sendKexInit(); } /** diff --git a/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/OpenSshServerKeyDatabase.java b/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/OpenSshServerKeyDatabase.java index f4849ce4a3..9c0a793124 100644 --- a/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/OpenSshServerKeyDatabase.java +++ b/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/OpenSshServerKeyDatabase.java @@ -453,9 +453,8 @@ public class OpenSshServerKeyDatabase prompt); items.add(answer); return provider.get(uri, items) && answer.getValue(); - } else { - return provider.get(uri, items); } + return provider.get(uri, items); } private Check checkMode(SocketAddress remoteAddress, boolean changed) { diff --git a/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/proxy/HttpParser.java b/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/proxy/HttpParser.java index b9b32b1300..02771b501c 100644 --- a/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/proxy/HttpParser.java +++ b/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/proxy/HttpParser.java @@ -207,11 +207,10 @@ public final class HttpParser { next++; } return next; - } else { - // This token must be the name of the next authentication - // scheme. - return start; } + // This token must be the name of the next authentication + // scheme. + return start; } int nextStart = skipWhiteSpace(header, next + 1); if (nextStart >= length) { @@ -244,11 +243,10 @@ public final class HttpParser { // token, and the equals sign is part of the token challenge.setToken(header.substring(start, end + 1)); return nextStart + 1; - } else { - // Key without value... - challenge.addArgument(header.substring(start, end), null); - start = nextStart + 1; } + // Key without value... + challenge.addArgument(header.substring(start, end), null); + start = nextStart + 1; } else { if (header.charAt(nextStart) == '"') { int nextEnd[] = { nextStart + 1 }; diff --git a/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/proxy/Socks5ClientConnector.java b/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/proxy/Socks5ClientConnector.java index 27d6f418b8..b3681d14a5 100644 --- a/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/proxy/Socks5ClientConnector.java +++ b/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/proxy/Socks5ClientConnector.java @@ -281,11 +281,10 @@ public class Socks5ClientConnector extends AbstractClientProxyConnector { } if (i == proposals.length) { return proposals; - } else { - byte[] result = new byte[i]; - System.arraycopy(proposals, 0, result, 0, i); - return result; } + byte[] result = new byte[i]; + System.arraycopy(proposals, 0, result, 0, i); + return result; } private void sendConnectInfo(IoSession session) throws Exception { diff --git a/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/transport/sshd/SshdSession.java b/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/transport/sshd/SshdSession.java index 1e8d7d1e1e..3fc955ab25 100644 --- a/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/transport/sshd/SshdSession.java +++ b/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/transport/sshd/SshdSession.java @@ -354,9 +354,8 @@ public class SshdSession implements RemoteSession { if (path.charAt(0) != '/') { if (cwd.charAt(cwd.length() - 1) == '/') { return cwd + path; - } else { - return cwd + '/' + path; } + return cwd + '/' + path; } return path; } |