title: How to handle return statement in Java code with checkstyle?
body: <p>I have 2 methods.  I am using checkstyle on my code. I have extracted the <code>buildResultWithLabel()</code> from <code>buildResult()</code>.</p>
  <p>Problematic Code:</p>
  <pre><code>    final int issueNo = commitMessage.getIssueNumber();
      if (processedIssueNumbers.contains(issueNo)) {
          return;
      }
      processedIssueNumbers.add(issueNo);
  </code></pre>
  <p>Before extracting the method, the code was in <code>buildResult()</code>. Now that I have extracted it, it is no longer running in a loop. Before it was a <code>continue;</code> instead of a <code>return;</code>.</p>
  <blockquote>
  <p>ERROR: (coding) ReturnCount: Return count is 1 (max allowed for void
  methods/constructors/lambdas is 0).</p>
  </blockquote>
  <p>My code looks like this:</p>
  <pre><code>public static Result buildResult(String localRepoPath, String authToken, String remoteRepoPath,
                                   String startRef, String endRef) throws IOException,
                                    GitAPIException {
  
      final Result result = new Result();
  
      final GHRepository remoteRepo = createRemoteRepo(authToken, remoteRepoPath);
      final Set&lt;RevCommit&gt; commitsForRelease =
          getCommitsBetweenReferences(localRepoPath, startRef, endRef);
      commitsForRelease.removeAll(getIgnoredCommits(commitsForRelease));
  
      final Set&lt;Integer&gt; processedIssueNumbers = new HashSet&lt;&gt;();
      for (RevCommit commit : commitsForRelease) {
          CommitMessage commitMessage = new CommitMessage(commit.getFullMessage());
          if (commitMessage.isRevert()) {
              System.out.println(commitMessage.getMessage());
              commitMessage = new CommitMessage(commitMessage.getRevertedCommitMessage());
          }
          buildResultWithLabel(remoteRepoPath, result, remoteRepo, commitsForRelease,
                               processedIssueNumbers,
                               commit,
                               commitMessage);
      }
      return result;
  }
  
  private static void buildResultWithLabel(String remoteRepoPath, Result result,
                                           GHRepository remoteRepo,
                                           Set&lt;RevCommit&gt; commitsForRelease,
                                           Set&lt;Integer&gt; processedIssueNumbers, RevCommit commit,
                                           CommitMessage commitMessage) throws IOException {
      if (commitMessage.isIssueOrPull()) {
          final int issueNo = commitMessage.getIssueNumber();
          if (processedIssueNumbers.contains(issueNo)) {
              return;
          }
          processedIssueNumbers.add(issueNo);
  
          final GHIssue issue = remoteRepo.getIssue(issueNo);
          if (issue.getState() != GHIssueState.CLOSED) {
              result.addWarning(String.format(MESSAGE_NOT_CLOSED, issueNo, issue.getTitle(),
                                              remoteRepoPath, issueNo));
          }
  
          final String issueLabel = getIssueLabelFrom(issue);
          if (issueLabel.isEmpty()) {
              final String error = String.format(MESSAGE_NO_LABEL,
                                                 issueNo,
                                                 Arrays.stream(Constants.ISSUE_LABELS)
                                                     .collect(Collectors.joining(SEPARATOR)),
                                                 remoteRepoPath, issueNo);
              result.addError(error);
          }
          final List&lt;GHLabel&gt; releaseLabels = getAllIssueLabels(issue);
          if (releaseLabels.size() &gt; 1) {
              final String error = String.format(MESSAGE_MORE_THAN_ONE_RELEASE_LABEL,
                                                 issueNo,
                                                 Arrays.stream(Constants.ISSUE_LABELS)
                                                     .collect(Collectors.joining(SEPARATOR)),
                                                 remoteRepoPath, issueNo);
              result.addError(error);
          }
          final Set&lt;RevCommit&gt; issueCommits = getCommitsForIssue(commitsForRelease, issueNo);
          final String authors = getAuthorsOf(issueCommits);
          final ReleaseNotesMessage releaseNotesMessage =
              new ReleaseNotesMessage(issue, authors);
          result.putReleaseNotesMessage(issueLabel, releaseNotesMessage);
      }
      else {
          // Commits that have messages which do not contain issue or pull number
          final String commitShortMessage = commit.getShortMessage();
          final String author = commit.getAuthorIdent().getName();
          final ReleaseNotesMessage releaseNotesMessage =
              new ReleaseNotesMessage(commitShortMessage, author);
          result.putReleaseNotesMessage(Constants.MISCELLANEOUS_LABEL, releaseNotesMessage);
      }
  }
  </code></pre>