Remove unnecessary nesting of statements in 'else' blocks

Change-Id: I8ed79a19d933d2866efd38be630fd61ca7786da7
diff --git a/github-oauth/src/main/java/com/googlesource/gerrit/plugins/github/oauth/AuthenticatedHttpRequest.java b/github-oauth/src/main/java/com/googlesource/gerrit/plugins/github/oauth/AuthenticatedHttpRequest.java
index 3cfa11f..5475fcf 100644
--- a/github-oauth/src/main/java/com/googlesource/gerrit/plugins/github/oauth/AuthenticatedHttpRequest.java
+++ b/github-oauth/src/main/java/com/googlesource/gerrit/plugins/github/oauth/AuthenticatedHttpRequest.java
@@ -53,8 +53,7 @@
     String headerValue = headers.get(name);
     if (headerValue != null) {
       return headerValue;
-    } else {
-      return super.getHeader(name);
     }
+    return super.getHeader(name);
   }
 }
diff --git a/github-oauth/src/main/java/com/googlesource/gerrit/plugins/github/oauth/GitHubLogin.java b/github-oauth/src/main/java/com/googlesource/gerrit/plugins/github/oauth/GitHubLogin.java
index 6e050b4..1844251 100644
--- a/github-oauth/src/main/java/com/googlesource/gerrit/plugins/github/oauth/GitHubLogin.java
+++ b/github-oauth/src/main/java/com/googlesource/gerrit/plugins/github/oauth/GitHubLogin.java
@@ -71,17 +71,15 @@
   public GHMyself getMyself() throws IOException {
     if (isLoggedIn()) {
       return getHub().getMyself();
-    } else {
-      return null;
     }
+    return null;
   }
 
   public Set<String> getMyOrganisationsLogins() throws IOException {
     if (isLoggedIn()) {
       return getHub().getMyOrganizations().keySet();
-    } else {
-      return Collections.emptySet();
     }
+    return Collections.emptySet();
   }
 
   @Inject
@@ -141,9 +139,8 @@
   public GitHub getHub() throws IOException {
     if (token == null) {
       return null;
-    } else {
-      return GitHub.connectUsingOAuth(config.gitHubApiUrl, token.accessToken);
     }
+    return GitHub.connectUsingOAuth(config.gitHubApiUrl, token.accessToken);
   }
 
   private String getScopesKey(HttpServletRequest request,
diff --git a/github-oauth/src/main/java/com/googlesource/gerrit/plugins/github/oauth/GitHubOAuthConfig.java b/github-oauth/src/main/java/com/googlesource/gerrit/plugins/github/oauth/GitHubOAuthConfig.java
index 28a27af..d44480a 100644
--- a/github-oauth/src/main/java/com/googlesource/gerrit/plugins/github/oauth/GitHubOAuthConfig.java
+++ b/github-oauth/src/main/java/com/googlesource/gerrit/plugins/github/oauth/GitHubOAuthConfig.java
@@ -151,8 +151,7 @@
   public Scope[] getDefaultScopes() {
     if (scopes == null || scopes.get("scopes") == null) {
       return new Scope[0];
-    } else {
-      return scopes.get("scopes").toArray(new Scope[0]);
     }
+    return scopes.get("scopes").toArray(new Scope[0]);
   }
 }
diff --git a/github-oauth/src/main/java/com/googlesource/gerrit/plugins/github/oauth/IdentifiedUserGitHubLoginProvider.java b/github-oauth/src/main/java/com/googlesource/gerrit/plugins/github/oauth/IdentifiedUserGitHubLoginProvider.java
index 646b602..b03a61d 100644
--- a/github-oauth/src/main/java/com/googlesource/gerrit/plugins/github/oauth/IdentifiedUserGitHubLoginProvider.java
+++ b/github-oauth/src/main/java/com/googlesource/gerrit/plugins/github/oauth/IdentifiedUserGitHubLoginProvider.java
@@ -66,9 +66,8 @@
         GitHubLogin login = new GitHubLogin(config);
         login.login(accessToken);
         return login;
-      } else {
-        return null;
       }
+      return null;
     } catch (IOException e) {
       log.error("Cannot login to GitHub as '" + username + "'", e);
       return null;
diff --git a/github-oauth/src/main/java/com/googlesource/gerrit/plugins/github/oauth/OAuthGitFilter.java b/github-oauth/src/main/java/com/googlesource/gerrit/plugins/github/oauth/OAuthGitFilter.java
index 4cc8f4f..02d6020 100644
--- a/github-oauth/src/main/java/com/googlesource/gerrit/plugins/github/oauth/OAuthGitFilter.java
+++ b/github-oauth/src/main/java/com/googlesource/gerrit/plugins/github/oauth/OAuthGitFilter.java
@@ -108,9 +108,8 @@
       String headerValue = headers.get(name);
       if (headerValue != null) {
         return headerValue;
-      } else {
-        return super.getHeader(name);
       }
+      return super.getHeader(name);
     }
   }
 
@@ -216,9 +215,8 @@
     int port = originalUrl.getPort();
     if (port == -1) {
       return protocol.equals("https") ? 443 : 80;
-    } else {
-      return port;
     }
+    return port;
   }
 
   private Cookie getGerritLoginCookie(String username,
@@ -290,10 +288,9 @@
     String hdr = req.getHeader(GIT_AUTHORIZATION_HEADER);
     if (hdr == null || !hdr.startsWith(GIT_AUTHENTICATION_BASIC)) {
       return null;
-    } else {
-      return new String(Base64.decodeBase64(hdr
-          .substring(GIT_AUTHENTICATION_BASIC.length())), encoding(req));
     }
+    return new String(Base64.decodeBase64(hdr
+        .substring(GIT_AUTHENTICATION_BASIC.length())), encoding(req));
   }
 
   @Override
diff --git a/github-oauth/src/main/java/com/googlesource/gerrit/plugins/github/oauth/OAuthProtocol.java b/github-oauth/src/main/java/com/googlesource/gerrit/plugins/github/oauth/OAuthProtocol.java
index 7b12c61..088b70e 100644
--- a/github-oauth/src/main/java/com/googlesource/gerrit/plugins/github/oauth/OAuthProtocol.java
+++ b/github-oauth/src/main/java/com/googlesource/gerrit/plugins/github/oauth/OAuthProtocol.java
@@ -225,10 +225,9 @@
       if (isError()) {
         return "Error AccessToken [error=" + error + ", error_description="
             + errorDescription + ", error_uri=" + errorUri + "]";
-      } else {
-        return "AccessToken [access_token=" + accessToken + ", token_type="
-            + tokenType + "]";
       }
+      return "AccessToken [access_token=" + accessToken + ", token_type="
+          + tokenType + "]";
     }
 
     @Override
@@ -407,9 +406,8 @@
     String finalUrlSuffix = "?" + FINAL_URL_PARAM + "=true";
     if (meEnd > 0) {
       return state(request).substring(meEnd + 1) + finalUrlSuffix;
-    } else {
-      return finalUrlSuffix;
     }
+    return finalUrlSuffix;
   }
 
   private static String state(ServletRequest request) {
diff --git a/github-plugin/src/main/java/com/google/gerrit/server/account/AccountImporter.java b/github-plugin/src/main/java/com/google/gerrit/server/account/AccountImporter.java
index 00d4420..0f1b596 100644
--- a/github-plugin/src/main/java/com/google/gerrit/server/account/AccountImporter.java
+++ b/github-plugin/src/main/java/com/google/gerrit/server/account/AccountImporter.java
@@ -56,19 +56,18 @@
       accountInput.name = MoreObjects.firstNonNull(name, login);
       Response<AccountInfo> accountResponse =
           createAccount.apply(TopLevelResource.INSTANCE, accountInput);
-      if (accountResponse.statusCode() == HttpStatus.SC_CREATED) {
-        Id accountId = new Account.Id(
-            accountResponse.value()._accountId.intValue());
-        db.accountExternalIds().insert(
-            Arrays
-                .asList(new AccountExternalId(accountId,
-                    new AccountExternalId.Key(AccountExternalId.SCHEME_GERRIT,
-                        login))));
-        return accountId;
-      } else {
+      if (accountResponse.statusCode() != HttpStatus.SC_CREATED) {
         throw new IOException("Cannot import GitHub account " + login
             + ": HTTP Status " + accountResponse.statusCode());
       }
+      Id accountId = new Account.Id(
+          accountResponse.value()._accountId.intValue());
+      db.accountExternalIds().insert(
+          Arrays
+              .asList(new AccountExternalId(accountId,
+                  new AccountExternalId.Key(AccountExternalId.SCHEME_GERRIT,
+                      login))));
+      return accountId;
     }
   }
 }
diff --git a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/GitHubTopMenu.java b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/GitHubTopMenu.java
index 61431e0..12a9b30 100644
--- a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/GitHubTopMenu.java
+++ b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/GitHubTopMenu.java
@@ -61,8 +61,7 @@
         // Only with HTTP authentication we can transparently trigger OAuth if needed
         authConfig.getAuthType().equals(AuthType.HTTP)) {
       return menuEntries;
-    } else {
-      return Collections.emptyList();
     }
+    return Collections.emptyList();
   }
 }
diff --git a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/AbstractCloneJob.java b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/AbstractCloneJob.java
index 16fefc9..7308b28 100644
--- a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/AbstractCloneJob.java
+++ b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/AbstractCloneJob.java
@@ -31,11 +31,10 @@
       return ((GitException) exception).getErrorDescription();
     } else if(ProvisionException.class.isAssignableFrom(exception.getClass())){
       Throwable cause = exception.getCause();
-      if(cause != null) {
-      return getErrorDescription(cause);
-      } else {
-        return "Import startup failed";
+      if (cause != null) {
+        return getErrorDescription(cause);
       }
+      return "Import startup failed";
     } else {
       return "Internal error";
     }
diff --git a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/GitImportJob.java b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/GitImportJob.java
index 005d54c..b633b67 100644
--- a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/GitImportJob.java
+++ b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/GitImportJob.java
@@ -77,16 +77,16 @@
   public String getStatusDescription() {
     if (exception != null) {
       return getErrorDescription(exception);
-    } else {
-      switch (status.getStatus()) {
-        case COMPLETE:
-          return "Cloned (100%)";
-        case CANCELLED:
-          return "Cancelled";
-        default:
-          return "Phase-" + currTask + " / " + task + " (" + lastPercentage
-              + "%)";
-      }
+    }
+
+    switch (status.getStatus()) {
+      case COMPLETE:
+        return "Cloned (100%)";
+      case CANCELLED:
+        return "Cancelled";
+      default:
+        return "Phase-" + currTask + " / " + task + " (" + lastPercentage
+            + "%)";
     }
   }
 
diff --git a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/PullRequestCreateChange.java b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/PullRequestCreateChange.java
index de1c9a8..00a659e 100644
--- a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/PullRequestCreateChange.java
+++ b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/PullRequestCreateChange.java
@@ -177,14 +177,13 @@
       insertPatchSet(bu, repo, destChange, pullRequestCommit,
           refControl, pullRequestMesage);
       return destChange.getId();
-    } else {
-
-      // Change key not found on destination branch. We can create a new
-      // change.
-      return createNewChange(db, bu, changeKey, project.getNameKey(), destRef,
-          pullRequestOwner, pullRequestCommit, refControl, pullRequestMesage,
-          topic);
     }
+
+    // Change key not found on destination branch. We can create a new
+    // change.
+    return createNewChange(db, bu, changeKey, project.getNameKey(), destRef,
+        pullRequestOwner, pullRequestCommit, refControl, pullRequestMesage,
+        topic);
   }
 
   private void insertPatchSet(BatchUpdate bu, Repository git, Change change,
diff --git a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/PullRequestImportJob.java b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/PullRequestImportJob.java
index 766a786..aed77e8 100644
--- a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/PullRequestImportJob.java
+++ b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/PullRequestImportJob.java
@@ -206,9 +206,8 @@
     AccountExternalId userExtId = gerritExtIds.get(userExtKey);
     if (userExtId == null) {
       return accountImporter.importAccount(login, name, email);
-    } else {
-      return userExtId.getAccountId();
     }
+    return userExtId.getAccountId();
   }
 
   private String getChangeMessage(GHPullRequest pr) {
@@ -260,10 +259,9 @@
   public GHRepository getGHRepository() throws IOException {
     if (ghLogin.getMyself().getLogin().equals(organisation)) {
       return ghLogin.getMyself().getRepository(repoName);
-    } else {
-      return ghLogin.getHub().getOrganization(organisation)
-          .getRepository(repoName);
     }
+    return ghLogin.getHub().getOrganization(organisation)
+        .getRepository(repoName);
   }
 
   @Override
diff --git a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/group/GitHubGroupBackend.java b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/group/GitHubGroupBackend.java
index 5a454d0..88045b4 100644
--- a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/group/GitHubGroupBackend.java
+++ b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/group/GitHubGroupBackend.java
@@ -127,8 +127,7 @@
     String username = user.getUserName();
     if (Strings.isNullOrEmpty(username)) {
       return GroupMembership.EMPTY;
-    } else {
-      return ghMembershipProvider.get(username);
     }
+    return ghMembershipProvider.get(username);
   }
 }
diff --git a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/notification/PullRequestHandler.java b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/notification/PullRequestHandler.java
index a0388a2..017d3d2 100644
--- a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/notification/PullRequestHandler.java
+++ b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/notification/PullRequestHandler.java
@@ -59,9 +59,8 @@
           PullRequestImportType.Commits);
       logger.info("Imported {}/{}#{}", organization, name, prNumber);
       return true;
-    } else {
-      return false;
     }
+    return false;
   }
 
   @Override
diff --git a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/notification/WebhookServlet.java b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/notification/WebhookServlet.java
index 3d7f819..5e79304 100644
--- a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/notification/WebhookServlet.java
+++ b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/notification/WebhookServlet.java
@@ -186,11 +186,10 @@
     T payload = gson.fromJson(jsonBody, handler.getPayloadType());
     if (payload != null) {
       return handler.doAction(payload);
-    } else {
-      logger.error("Cannot decode JSON payload '" + jsonBody + "' into "
-          + handler.getPayloadType().getName());
-      return false;
     }
+    logger.error("Cannot decode JSON payload '" + jsonBody + "' into "
+        + handler.getPayloadType().getName());
+    return false;
   }
 
   /**
diff --git a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/wizard/RepositoriesListController.java b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/wizard/RepositoriesListController.java
index 8e1de4c..281e3bd 100644
--- a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/wizard/RepositoriesListController.java
+++ b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/wizard/RepositoriesListController.java
@@ -94,10 +94,9 @@
       String organisation) throws IOException {
     if (organisation.equals(hubLogin.getMyself().getLogin())) {
       return hubLogin.getMyself().listRepositories(config.repositoryListPageSize, RepositoryListFilter.OWNER);
-    } else {
-      GHOrganization ghOrganisation =
-          hubLogin.getMyself().getAllOrganizations().byLogin(organisation);
-      return ghOrganisation.listRepositories(config.repositoryListPageSize);
     }
+    GHOrganization ghOrganisation =
+        hubLogin.getMyself().getAllOrganizations().byLogin(organisation);
+    return ghOrganisation.listRepositories(config.repositoryListPageSize);
   }
 }