Remove unnecessary usage of `new String(...)`
According to Findbugs:
Using the java.lang.String(String) constructor wastes memory because
the object so constructed will be functionally indistinguishable from
the String passed as a parameter.
Just use the argument String directly.
Change-Id: I85a3fd0b85afcae356181eef3e7262d9bf0fa600
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 9e3876e..ff7f1aa 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/validators/CommitMessageLengthValidation.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/validators/CommitMessageLengthValidation.java
@@ -87,8 +87,8 @@
if (this.maxSubjectLength < commit.getShortMessage().length()) {
onLineTooLong(id, messages,
- new String("commit subject >" + this.maxSubjectLength
- + " characters; use shorter first paragraph"));
+ "commit subject >" + this.maxSubjectLength
+ + " characters; use shorter first paragraph");
}
int longLineCnt = 0;
@@ -104,9 +104,9 @@
if (longLineCnt > (longLinesThreshold * nonEmptyCnt) / 100) {
onLineTooLong(id, messages,
- new String("too many commit message lines longer than "
- + this.maxLineLength
- + " characters; manually wrap lines"));
+ "too many commit message lines longer than "
+ + this.maxLineLength
+ + " characters; manually wrap lines");
}
return messages;