Skip to content

Commit

Permalink
SONARHTML-148 InternationalizationCheck should raise an issue on the …
Browse files Browse the repository at this point in the history
…label rather than the entire line (#189)

* SONARHTML-148 InternationalizationCheck should raise an issue on the label rather than the entire line

* Update sonar-html-plugin/src/test/java/org/sonar/plugins/html/checks/coding/InternationalizationCheckTest.java

Co-authored-by: Christophe Zürn <[email protected]>

Co-authored-by: Christophe Zürn <[email protected]>
  • Loading branch information
1 parent 637022c commit de95a1e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void startDocument(List<Node> nodes) {
public void characters(TextNode textNode) {
String textNodeCode = textNode.getCode();
if (isValidText(textNodeCode)) {
createViolation(textNode.getStartLinePosition(), "Define this label in the resource bundle.");
createViolation(textNode, "Define this label in the resource bundle.");
}
}

Expand All @@ -76,7 +76,7 @@ private boolean notValid(TagNode element, QualifiedAttribute attribute) {
if (value != null) {
value = value.trim();
if (value.length() > 0 && isValidText(value)) {
createViolation(element.getStartLinePosition(), "Define this label in the resource bundle.");
createViolation(element, "Define this label in the resource bundle.");
return true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ public void custom() {
HtmlSourceCode sourceCode = TestHelper.scan(new File("src/test/resources/checks/InternationalizationCheck.html"), check);

checkMessagesVerifier.verify(sourceCode.getIssues())
.next().atLine(1).withMessage("Define this label in the resource bundle.")
.next().atLine(2).withMessage("Define this label in the resource bundle.")
.next().atLocation(1, 13, 1, 16).withMessage("Define this label in the resource bundle.")
.next().atLocation(2, 0, 2, 25).withMessage("Define this label in the resource bundle.")
.next().atLine(9).withMessage("Define this label in the resource bundle.")
.next().atLine(10).withMessage("Define this label in the resource bundle.")
.next().atLine(11).withMessage("Define this label in the resource bundle.");
Expand Down

0 comments on commit de95a1e

Please sign in to comment.