public List onCommitReceived()

in src/main/java/com/googlesource/gerrit/plugins/validators/CommitMessageLengthValidation.java [75:106]


  public List<CommitValidationMessage> onCommitReceived(CommitReceivedEvent receiveEvent)
      throws CommitValidationException {
    final RevCommit commit = receiveEvent.commit;
    List<CommitValidationMessage> messages = new ArrayList<>();

    if (this.maxSubjectLength < commit.getShortMessage().length()) {
      onLineTooLong(
          messages,
          "subject >" + this.maxSubjectLength + " characters; use shorter first paragraph");
    }

    int longLineCnt = 0;
    int nonEmptyCnt = 0;
    for (String line : Splitter.on('\n').split(commit.getFullMessage())) {
      if (!line.trim().isEmpty()) {
        nonEmptyCnt++;
      }
      if (this.maxLineLength < line.length()) {
        longLineCnt++;
      }
    }

    if (longLineCnt > (longLinesThreshold * nonEmptyCnt) / 100) {
      onLineTooLong(
          messages,
          "too many message lines longer than "
              + this.maxLineLength
              + " characters; manually wrap lines");
    }

    return messages;
  }