Search in sources :

Example 26 with HtmlSourceCode

use of org.sonar.plugins.html.visitor.HtmlSourceCode in project sonar-web by SonarSource.

the class AvoidHtmlCommentCheckTest method should_detect_on_erb_documents.

@Test
public void should_detect_on_erb_documents() {
    HtmlSourceCode sourceCode = TestHelper.scan(new File("src/test/resources/checks/AvoidHtmlCommentCheck/document.html.erb"), new AvoidHtmlCommentCheck());
    checkMessagesVerifier.verify(sourceCode.getIssues()).next().atLine(6).withMessage("Make sure that the HTML comment does not contain sensitive information.");
}
Also used : HtmlSourceCode(org.sonar.plugins.html.visitor.HtmlSourceCode) File(java.io.File) Test(org.junit.Test)

Example 27 with HtmlSourceCode

use of org.sonar.plugins.html.visitor.HtmlSourceCode in project sonar-web by SonarSource.

the class TodoCommentCheckTest method detected.

@Test
public void detected() {
    HtmlSourceCode sourceCode = TestHelper.scan(new File("src/test/resources/checks/TodoCommentCheck.html"), new TodoCommentCheck());
    checkMessagesVerifier.verify(sourceCode.getIssues()).next().atLine(3).withMessage("Complete the task associated to this \"TODO\" comment.").next().atLine(4).next().atLine(8);
}
Also used : HtmlSourceCode(org.sonar.plugins.html.visitor.HtmlSourceCode) File(java.io.File) Test(org.junit.Test)

Example 28 with HtmlSourceCode

use of org.sonar.plugins.html.visitor.HtmlSourceCode in project sonar-web by SonarSource.

the class IllegalNamespaceCheckTest method custom.

@Test
public void custom() {
    IllegalNamespaceCheck check = new IllegalNamespaceCheck();
    check.namespaces = "foo,baz";
    HtmlSourceCode sourceCode = TestHelper.scan(new File("src/test/resources/checks/IllegalNamespaceCheck.html"), check);
    checkMessagesVerifier.verify(sourceCode.getIssues()).next().atLine(1).withMessage("Using \"baz\" namespace is not allowed.").next().atLine(1).withMessage("Using \"foo\" namespace is not allowed.").next().atLine(6).withMessage("Using \"foo\" namespace is not allowed.");
}
Also used : HtmlSourceCode(org.sonar.plugins.html.visitor.HtmlSourceCode) File(java.io.File) Test(org.junit.Test)

Example 29 with HtmlSourceCode

use of org.sonar.plugins.html.visitor.HtmlSourceCode in project sonar-web by SonarSource.

the class LibraryDependencyCheckTest method illegal_import.

@Test
public void illegal_import() throws FileNotFoundException {
    LibraryDependencyCheck check = new LibraryDependencyCheck();
    check.libraries = "java.sql";
    HtmlSourceCode sourceCode = TestHelper.scan(new File("src/test/resources/checks/LibraryDependencyCheck/IllegalImport.jsp"), check);
    checkMessagesVerifier.verify(sourceCode.getIssues()).next().atLine(2).withMessage("Remove the usage of this library which is not allowed.");
}
Also used : HtmlSourceCode(org.sonar.plugins.html.visitor.HtmlSourceCode) File(java.io.File) Test(org.junit.Test)

Example 30 with HtmlSourceCode

use of org.sonar.plugins.html.visitor.HtmlSourceCode in project sonar-web by SonarSource.

the class IllegalAttributeCheckTest method custom.

@Test
public void custom() {
    IllegalAttributeCheck check = new IllegalAttributeCheck();
    check.attributes = "foo.a,b";
    HtmlSourceCode sourceCode = TestHelper.scan(new File("src/test/resources/checks/IllegalAttributeCheck.html"), check);
    checkMessagesVerifier.verify(sourceCode.getIssues()).next().atLine(1).withMessage("Remove the \"a\" attribute from the \"foo\" tag").next().atLine(3).withMessage("Remove the \"b\" attribute from the \"baz\" tag");
}
Also used : HtmlSourceCode(org.sonar.plugins.html.visitor.HtmlSourceCode) File(java.io.File) Test(org.junit.Test)

Aggregations

HtmlSourceCode (org.sonar.plugins.html.visitor.HtmlSourceCode)115 File (java.io.File)111 Test (org.junit.Test)111 InputFile (org.sonar.api.batch.fs.InputFile)8 TestInputFileBuilder (org.sonar.api.batch.fs.internal.TestInputFileBuilder)3 PageLexer (org.sonar.plugins.html.lex.PageLexer)3 Node (org.sonar.plugins.html.node.Node)3 HtmlAstScanner (org.sonar.plugins.html.visitor.HtmlAstScanner)3 FileReader (java.io.FileReader)2 FileNotFoundException (java.io.FileNotFoundException)1 InputStreamReader (java.io.InputStreamReader)1 Reader (java.io.Reader)1 ExpectedException (org.junit.rules.ExpectedException)1 FilePredicates (org.sonar.api.batch.fs.FilePredicates)1 FileSystem (org.sonar.api.batch.fs.FileSystem)1 ComplexityVisitor (org.sonar.plugins.html.analyzers.ComplexityVisitor)1 PageCountLines (org.sonar.plugins.html.analyzers.PageCountLines)1 VueLexer (org.sonar.plugins.html.lex.VueLexer)1