use of org.sonar.plugins.web.visitor.WebSourceCode in project sonar-web by SonarSource.
the class WmodeIsWindowCheckTest method detected.
@Test
public void detected() throws Exception {
WebSourceCode sourceCode = TestHelper.scan(new File("src/test/resources/checks/WmodeIsWindowCheck.html"), new WmodeIsWindowCheck());
checkMessagesVerifier.verify(sourceCode.getIssues()).next().atLine(9).withMessage("Set the value of the 'wmode' parameter to 'window'.").next().atLine(14).next().atLine(19).next().atLine(58).next().atLine(64);
}
use of org.sonar.plugins.web.visitor.WebSourceCode in project sonar-web by SonarSource.
the class ChildElementRequiredCheckTest method custom.
@Test
public void custom() {
ChildElementRequiredCheck check = new ChildElementRequiredCheck();
check.child = "bar";
check.parent = "foo";
WebSourceCode sourceCode = TestHelper.scan(new File("src/test/resources/checks/ChildElementRequiredCheck.html"), check);
checkMessagesVerifier.verify(sourceCode.getIssues()).next().atLine(8).withMessage("Add the missing \"bar\" element to this \"foo\".").next().atLine(12);
}
use of org.sonar.plugins.web.visitor.WebSourceCode in project sonar-web by SonarSource.
the class ParentElementRequiredCheckTest method custom.
@Test
public void custom() {
ParentElementRequiredCheck check = new ParentElementRequiredCheck();
check.child = "bar";
check.parent = "foo";
WebSourceCode sourceCode = TestHelper.scan(new File("src/test/resources/checks/ParentElementRequiredCheck.html"), check);
checkMessagesVerifier.verify(sourceCode.getIssues()).next().atLine(6).withMessage("Add the missing \"foo\" parent element for \"bar\" element.").next().atLine(17);
}
use of org.sonar.plugins.web.visitor.WebSourceCode in project sonar-web by SonarSource.
the class PageCountLinesTest method testCountLinesHtmlFile.
@Test
public void testCountLinesHtmlFile() throws FileNotFoundException {
List<Node> nodeList = lexer.parse(new FileReader(TestUtils.getResource("checks/AvoidHtmlCommentCheck/document.html")));
String relativePath = "test/document.html";
WebSourceCode webSourceCode = new WebSourceCode(new DefaultInputFile("key", relativePath).setModuleBaseDir(new File(".").toPath()));
scanner.scan(nodeList, webSourceCode, Charsets.UTF_8);
assertThat(webSourceCode.getMeasure(CoreMetrics.NCLOC)).isEqualTo(8);
assertThat(webSourceCode.getDetailedLinesOfCode()).containsOnly(1, 2, 3, 4, 6, 7, 8, 9);
assertThat(webSourceCode.getMeasure(CoreMetrics.COMMENT_LINES)).isEqualTo(1);
assertThat(webSourceCode.getDetailedLinesOfComments()).containsOnly(5);
}
use of org.sonar.plugins.web.visitor.WebSourceCode in project sonar-web by SonarSource.
the class PageCountLinesTest method testCountLines.
@Test
public void testCountLines() throws FileNotFoundException {
java.io.File file = TestUtils.getResource("src/main/webapp/user-properties.jsp");
List<Node> nodeList = lexer.parse(new FileReader(file));
assertThat(nodeList.size()).isGreaterThan(100);
// new File("test", "user-properties.jsp");
String relativePath = "test/user-properties.jsp";
WebSourceCode webSourceCode = new WebSourceCode(new DefaultInputFile("key", relativePath).setModuleBaseDir(new File(".").toPath()));
scanner.scan(nodeList, webSourceCode, Charsets.UTF_8);
assertThat(webSourceCode.getMeasure(CoreMetrics.NCLOC)).isEqualTo(227);
assertThat(webSourceCode.getDetailedLinesOfCode().size()).isEqualTo(224);
assertThat(webSourceCode.getMeasure(CoreMetrics.COMMENT_LINES)).isEqualTo(14);
assertThat(webSourceCode.getDetailedLinesOfComments().size()).isEqualTo(14);
}
Aggregations