From adcbdc204f4a577262709bfaf6cb038ddc90e301 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Sun, 10 Mar 2013 09:48:11 +0100 Subject: [PATCH] pmd: fix #1073 Hard coded violation messages CommentSize --- pmd/etc/changelog.txt | 1 + .../rule/comments/CommentContentRule.java | 22 +++++++++---------- .../java/rule/comments/CommentSizeRule.java | 8 +++++-- .../main/resources/rulesets/java/comments.xml | 2 +- 4 files changed, 19 insertions(+), 14 deletions(-) diff --git a/pmd/etc/changelog.txt b/pmd/etc/changelog.txt index a4a55eedd6..9c52440f97 100644 --- a/pmd/etc/changelog.txt +++ b/pmd/etc/changelog.txt @@ -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 diff --git a/pmd/src/main/java/net/sourceforge/pmd/lang/java/rule/comments/CommentContentRule.java b/pmd/src/main/java/net/sourceforge/pmd/lang/java/rule/comments/CommentContentRule.java index e8383eff9f..220326b270 100644 --- a/pmd/src/main/java/net/sourceforge/pmd/lang/java/rule/comments/CommentContentRule.java +++ b/pmd/src/main/java/net/sourceforge/pmd/lang/java/rule/comments/CommentContentRule.java @@ -108,19 +108,19 @@ public class CommentContentRule extends AbstractCommentRule { return foundWords; } - private static String errorMsgFor(List 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 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 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); } } diff --git a/pmd/src/main/resources/rulesets/java/comments.xml b/pmd/src/main/resources/rulesets/java/comments.xml index cd8912c4cc..5fe724cd3e 100755 --- a/pmd/src/main/resources/rulesets/java/comments.xml +++ b/pmd/src/main/resources/rulesets/java/comments.xml @@ -62,7 +62,7 @@ Determines whether the dimensions of non-header comments found are within the sp