Enable and fix 'Statement unnecessarily nested within else clause' warnings
Change-Id: Ida6df4593fc2ab3c11581309b2b4a638229ea093
This commit is contained in:
@@ -356,17 +356,17 @@ public abstract class BaseCommand implements Command {
|
||||
}
|
||||
return f.exitCode;
|
||||
|
||||
} else {
|
||||
try {
|
||||
err.write("fatal: internal server error\n".getBytes(ENC));
|
||||
err.flush();
|
||||
} catch (IOException e2) {
|
||||
// Ignored
|
||||
} catch (Throwable e2) {
|
||||
log.warn("Cannot send internal server error message to client", e2);
|
||||
}
|
||||
return 128;
|
||||
}
|
||||
|
||||
try {
|
||||
err.write("fatal: internal server error\n".getBytes(ENC));
|
||||
err.flush();
|
||||
} catch (IOException e2) {
|
||||
// Ignored
|
||||
} catch (Throwable e2) {
|
||||
log.warn("Cannot send internal server error message to client", e2);
|
||||
}
|
||||
return 128;
|
||||
}
|
||||
|
||||
protected UnloggedFailure die(String msg) {
|
||||
|
||||
@@ -77,9 +77,9 @@ public class ChangeArgumentParser {
|
||||
private boolean inProject(ProjectControl projectControl, Project project) {
|
||||
if (projectControl != null) {
|
||||
return projectControl.getProject().getNameKey().equals(project.getNameKey());
|
||||
} else {
|
||||
// No --project option, so they want every project.
|
||||
return true;
|
||||
}
|
||||
|
||||
// No --project option, so they want every project.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -106,10 +106,9 @@ class DatabasePubKeyAuth implements PublickeyAuthenticator {
|
||||
PeerDaemonUser user = peerFactory.create(sd.getRemoteAddress());
|
||||
return SshUtil.success(username, session, sshScope, sshLog, sd, user);
|
||||
|
||||
} else {
|
||||
sd.authenticationError(username, "no-matching-key");
|
||||
return false;
|
||||
}
|
||||
sd.authenticationError(username, "no-matching-key");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (config.getBoolean("auth", "userNameToLowerCase", false)) {
|
||||
|
||||
@@ -73,8 +73,7 @@ class GerritGSSAuthenticator extends GSSAuthenticator {
|
||||
if (active) {
|
||||
return SshUtil.success(username, session, sshScope, sshLog, sd,
|
||||
SshUtil.createUser(sd, userFactory, account.getId()));
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,25 +58,23 @@ class HostKeyProvider implements Provider<KeyPairProvider> {
|
||||
p.setPath(objKey.toAbsolutePath());
|
||||
return p;
|
||||
|
||||
} else {
|
||||
// Both formats of host key exist, we don't know which format
|
||||
// should be authoritative. Complain and abort.
|
||||
//
|
||||
stdKeys.add(objKey.toAbsolutePath().toFile());
|
||||
throw new ProvisionException("Multiple host keys exist: " + stdKeys);
|
||||
}
|
||||
// Both formats of host key exist, we don't know which format
|
||||
// should be authoritative. Complain and abort.
|
||||
//
|
||||
stdKeys.add(objKey.toAbsolutePath().toFile());
|
||||
throw new ProvisionException("Multiple host keys exist: " + stdKeys);
|
||||
|
||||
} else {
|
||||
if (stdKeys.isEmpty()) {
|
||||
throw new ProvisionException("No SSH keys under " + site.etc_dir);
|
||||
}
|
||||
if (!SecurityUtils.isBouncyCastleRegistered()) {
|
||||
throw new ProvisionException("Bouncy Castle Crypto not installed;"
|
||||
+ " needed to read server host keys: " + stdKeys + "");
|
||||
}
|
||||
AbstractFileKeyPairProvider kp = SecurityUtils.createFileKeyPairProvider();
|
||||
kp.setFiles(stdKeys);
|
||||
return kp;
|
||||
}
|
||||
if (stdKeys.isEmpty()) {
|
||||
throw new ProvisionException("No SSH keys under " + site.etc_dir);
|
||||
}
|
||||
if (!SecurityUtils.isBouncyCastleRegistered()) {
|
||||
throw new ProvisionException("Bouncy Castle Crypto not installed;"
|
||||
+ " needed to read server host keys: " + stdKeys + "");
|
||||
}
|
||||
AbstractFileKeyPairProvider kp = SecurityUtils.createFileKeyPairProvider();
|
||||
kp.setFiles(stdKeys);
|
||||
return kp;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,14 +137,13 @@ public class PatchSetParser {
|
||||
if (projectControl != null) {
|
||||
return notesFactory.create(db.get(), projectControl.getProject().getNameKey(),
|
||||
changeId);
|
||||
} else {
|
||||
try {
|
||||
ChangeControl ctl = changeFinder.findOne(changeId, self.get());
|
||||
return notesFactory.create(db.get(), ctl.getProject().getNameKey(),
|
||||
changeId);
|
||||
} catch (NoSuchChangeException e) {
|
||||
throw error("\"" + changeId + "\" no such change");
|
||||
}
|
||||
}
|
||||
try {
|
||||
ChangeControl ctl = changeFinder.findOne(changeId, self.get());
|
||||
return notesFactory.create(db.get(), ctl.getProject().getNameKey(),
|
||||
changeId);
|
||||
} catch (NoSuchChangeException e) {
|
||||
throw error("\"" + changeId + "\" no such change");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -192,9 +192,8 @@ final class ShowConnections extends SshCommand {
|
||||
|
||||
return "a/" + u.getAccountId().toString();
|
||||
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private String hostname(final SocketAddress remoteAddress) {
|
||||
|
||||
Reference in New Issue
Block a user