pmd: fix #1073 Hard coded violation messages CommentSize
This commit is contained in:
parent
a1b1e3f31c
commit
adcbdc204f
@ -2,6 +2,7 @@
|
||||
|
||||
Fixed bug 1064: Exception running PrematureDeclaration
|
||||
Fixed bug 1068: CPD fails on broken symbolic links
|
||||
Fixed bug 1073: Hard coded violation messages CommentSize
|
||||
Fixed bug 1074: rule priority doesn't work on group definitions
|
||||
|
||||
|
||||
|
@ -108,19 +108,19 @@ public class CommentContentRule extends AbstractCommentRule {
|
||||
return foundWords;
|
||||
}
|
||||
|
||||
private static String errorMsgFor(List<String> badWords) {
|
||||
|
||||
if (badWords.size() == 1 ) {
|
||||
return "Invalid term: '" + badWords.get(0) + '\'';
|
||||
}
|
||||
|
||||
StringBuilder sb = new StringBuilder("Invalid terms: '");
|
||||
sb.append(badWords.get(0));
|
||||
private String errorMsgFor(List<String> badWords) {
|
||||
StringBuilder msg = new StringBuilder(this.getMessage()).append(": ");
|
||||
if (badWords.size() == 1 ) {
|
||||
msg.append("Invalid term: '").append(badWords.get(0)).append('\'');
|
||||
} else {
|
||||
msg.append("Invalid terms: '");
|
||||
msg.append(badWords.get(0));
|
||||
for (int i=1; i<badWords.size(); i++) {
|
||||
sb.append("', '").append(badWords.get(i));
|
||||
msg.append("', '").append(badWords.get(i));
|
||||
}
|
||||
sb.append('\'');
|
||||
return sb.toString();
|
||||
msg.append('\'');
|
||||
}
|
||||
return msg.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -78,14 +78,18 @@ public class CommentSizeRule extends AbstractCommentRule {
|
||||
|
||||
for (Comment comment : cUnit.getComments()) {
|
||||
if (hasTooManyLines(comment)) {
|
||||
addViolationWithMessage(data, cUnit, "Too many lines", comment.getBeginLine(), comment.getEndLine());
|
||||
addViolationWithMessage(data, cUnit,
|
||||
this.getMessage() + ": Too many lines",
|
||||
comment.getBeginLine(), comment.getEndLine());
|
||||
}
|
||||
|
||||
List<Integer> lineNumbers = overLengthLineIndicesIn(comment);
|
||||
if (lineNumbers.isEmpty()) continue;
|
||||
|
||||
for (Integer lineNum : lineNumbers) {
|
||||
addViolationWithMessage(data, cUnit, "Line too long", lineNum, lineNum);
|
||||
addViolationWithMessage(data, cUnit,
|
||||
this.getMessage() + ": Line too long",
|
||||
lineNum, lineNum);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -62,7 +62,7 @@ Determines whether the dimensions of non-header comments found are within the sp
|
||||
|
||||
<rule name="CommentContent"
|
||||
since="5.0"
|
||||
message="Invalid words or phrases found."
|
||||
message="Invalid words or phrases found"
|
||||
class="net.sourceforge.pmd.lang.java.rule.comments.CommentContentRule"
|
||||
externalInfoUrl="${pmd.website.baseurl}/rules/java/comments.html#CommentContent">
|
||||
<description>
|
||||
|
Loading…
x
Reference in New Issue
Block a user