Allow threshold of too long lines to be configured

Currently the plugin will only reject the commit if 33% or more of the
commit message's lines are longer than the limit.

Add a configuration parameter to allow the administrator to set this
threshold.  If not specified, it defaults to 33, the same as it is now.

Change-Id: Ic1f07ba1f27a7837a59d215ca943663cb85a12ff
diff --git a/src/main/java/com/googlesource/gerrit/plugins/validators/CommitMessageLengthValidation.java b/src/main/java/com/googlesource/gerrit/plugins/validators/CommitMessageLengthValidation.java
index 5bba706..270c5a4 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/validators/CommitMessageLengthValidation.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/validators/CommitMessageLengthValidation.java
@@ -36,15 +36,18 @@
 public class CommitMessageLengthValidation implements CommitValidationListener {
   private final static int DEFAULT_MAX_SUBJECT_LENGTH = 65;
   private final static int DEFAULT_MAX_LINE_LENGTH = 70;
+  private final static int DEFAULT_LONG_LINES_THRESHOLD = 33;
   private final static boolean DEFAULT_REJECT_TOO_LONG = false;
   private final static String COMMIT_MESSAGE_SECTION = "commitmessage";
   private final static String MAX_SUBJECT_LENGTH_KEY = "maxSubjectLength";
   private final static String MAX_LINE_LENGTH_KEY = "maxLineLength";
   private final static String REJECT_TOO_LONG_KEY = "rejectTooLong";
+  private final static String LONG_LINES_THRESHOLD_KEY = "longLinesThreshold";
 
   private final Config config;
   private final int maxSubjectLength;
   private final int maxLineLength;
+  private final int longLinesThreshold;
   private boolean rejectTooLong;
 
   @Inject
@@ -60,6 +63,9 @@
     this.rejectTooLong = config.getBoolean(
         COMMIT_MESSAGE_SECTION, REJECT_TOO_LONG_KEY,
         DEFAULT_REJECT_TOO_LONG);
+    this.longLinesThreshold = config.getInt(
+        COMMIT_MESSAGE_SECTION, null,
+        LONG_LINES_THRESHOLD_KEY, DEFAULT_LONG_LINES_THRESHOLD);
   }
 
   private void onLineTooLong(final AbbreviatedObjectId id,
@@ -97,9 +103,10 @@
       }
     }
 
-    if (0 < longLineCnt && 33 < longLineCnt * 100 / nonEmptyCnt) {
+    if (longLineCnt > (longLinesThreshold * nonEmptyCnt) / 100) {
       onLineTooLong(id, messages,
-          new String("commit message lines >" + this.maxLineLength
+          new String("too many commit message lines longer than "
+              + this.maxLineLength
               + " characters; manually wrap lines"));
     }
 
diff --git a/src/main/resources/Documentation/config.md b/src/main/resources/Documentation/config.md
index 92440e7..0bf0c9b 100644
--- a/src/main/resources/Documentation/config.md
+++ b/src/main/resources/Documentation/config.md
@@ -12,6 +12,11 @@
 :	Maximum length of a line in the commit message's body.  If
 	not specified, defaults to 70.
 
+commitmessage.longLinesThreshold
+:	Percentage of commit message lines allowed to exceed the
+	maximum length before a warning or error is generated.  If
+	not specified, defaults to 33.
+
 commitmessage.rejectTooLong
 :	If set to `true`, reject commits whose subject or line
 	length exceeds the maximum allowed length.  If not