use of org.sonar.plugins.html.visitor.HtmlSourceCode in project sonar-web by SonarSource.
the class PageCountLinesTest method testCountLinesJspFile.
@Test
public void testCountLinesJspFile() {
List<Node> nodeList = lexer.parse(readFile("checks/AvoidHtmlCommentCheck/document.jsp"));
HtmlSourceCode htmlSourceCode = new HtmlSourceCode(new TestInputFileBuilder("key", "testdocument.jsp").setModuleBaseDir(new File(".").toPath()).build());
scanner.scan(nodeList, htmlSourceCode);
assertThat(htmlSourceCode.getMeasure(CoreMetrics.NCLOC)).isEqualTo(2);
assertThat(htmlSourceCode.getDetailedLinesOfCode()).containsOnly(1, 3);
assertThat(htmlSourceCode.getMeasure(CoreMetrics.COMMENT_LINES)).isEqualTo(6);
}
use of org.sonar.plugins.html.visitor.HtmlSourceCode in project sonar-web by SonarSource.
the class RequiredAttributeCheckTest method checkRepetition.
@Test
public void checkRepetition() {
RequiredAttributeCheck check = new RequiredAttributeCheck();
check.attributes = "img.alt,script.type";
HtmlSourceCode sourceCode = TestHelper.scan(new File("src/test/resources/checks/RequiredAttributeCheck.html"), check);
checkMessagesVerifier.verify(sourceCode.getIssues()).next().atLine(2).withMessage("Add the missing \"alt\" to element \"img\".").next().atLine(7).withMessage("Add the missing \"type\" to element \"script\".");
sourceCode = TestHelper.scan(new File("src/test/resources/checks/RequiredAttributeCheck.html"), check);
checkMessagesVerifier.verify(sourceCode.getIssues()).next().atLine(2).withMessage("Add the missing \"alt\" to element \"img\".").next().atLine(7).withMessage("Add the missing \"type\" to element \"script\".");
}
use of org.sonar.plugins.html.visitor.HtmlSourceCode in project sonar-web by SonarSource.
the class InternationalizationCheckTest method regexIgnore2.
@Test
public void regexIgnore2() {
InternationalizationCheck check = new InternationalizationCheck();
check.attributes = "";
check.ignoredContentRegex = ".*cDe.*";
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.");
}
use of org.sonar.plugins.html.visitor.HtmlSourceCode in project sonar-web by SonarSource.
the class InternationalizationCheckTest method custom2.
@Test
public void custom2() {
InternationalizationCheck check = new InternationalizationCheck();
check.attributes = "";
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(9).withMessage("Define this label in the resource bundle.").next().atLine(11).withMessage("Define this label in the resource bundle.");
}
use of org.sonar.plugins.html.visitor.HtmlSourceCode in project sonar-web by SonarSource.
the class InternationalizationCheckTest method regexIgnore1.
@Test
public void regexIgnore1() {
InternationalizationCheck check = new InternationalizationCheck();
check.attributes = "outputLabel.value";
check.ignoredContentRegex = ".*cDe.*";
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.");
}
Aggregations