Search in sources :

Example 46 with HtmlSourceCode

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

the class ImgWithoutWidthOrHeightCheckTest method detected.

@Test
public void detected() throws Exception {
    HtmlSourceCode sourceCode = TestHelper.scan(new File("src/test/resources/checks/ImgWithoutWidthOrHeightCheck.html"), new ImgWithoutWidthOrHeightCheck());
    checkMessagesVerifier.verify(sourceCode.getIssues()).next().atLocation(1, 0, 1, 7).withMessage("Add both a 'width' and a 'height' attribute to this image.").next().atLine(2).next().atLine(3).next().atLine(4).next().atLine(8).next().atLine(10);
}
Also used : HtmlSourceCode(org.sonar.plugins.html.visitor.HtmlSourceCode) File(java.io.File) Test(org.junit.Test)

Example 47 with HtmlSourceCode

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

the class MultiplePageDirectivesCheckTest method test1.

@Test
public void test1() throws Exception {
    HtmlSourceCode sourceCode = TestHelper.scan(new File("src/test/resources/checks/multiplePageDirectivesCheck1.html"), new MultiplePageDirectivesCheck());
    checkMessagesVerifier.verify(sourceCode.getIssues()).next().atLine(3).withMessage("Combine these 2 page directives into one.");
}
Also used : HtmlSourceCode(org.sonar.plugins.html.visitor.HtmlSourceCode) File(java.io.File) Test(org.junit.Test)

Example 48 with HtmlSourceCode

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

the class MultiplePageDirectivesCheckTest method test2.

@Test
public void test2() throws Exception {
    HtmlSourceCode sourceCode = TestHelper.scan(new File("src/test/resources/checks/multiplePageDirectivesCheck2.html"), new MultiplePageDirectivesCheck());
    checkMessagesVerifier.verify(sourceCode.getIssues()).next().atLine(3).withMessage("Combine these 2 page directives into one.");
}
Also used : HtmlSourceCode(org.sonar.plugins.html.visitor.HtmlSourceCode) File(java.io.File) Test(org.junit.Test)

Example 49 with HtmlSourceCode

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

the class LinkToImageCheckTest method test.

@Test
public void test() {
    HtmlSourceCode sourceCode = TestHelper.scan(new File("src/test/resources/checks/LinkToImageCheck.html"), new LinkToImageCheck());
    checkMessagesVerifier.verify(sourceCode.getIssues()).next().atLocation(3, 0, 3, 18).withMessage("Change this link to not directly target an image.").next().atLine(4).next().atLine(5).next().atLine(6).next().atLine(7).next().atLine(8);
}
Also used : HtmlSourceCode(org.sonar.plugins.html.visitor.HtmlSourceCode) File(java.io.File) Test(org.junit.Test)

Example 50 with HtmlSourceCode

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

the class LinkToNothingCheckTest method detected.

@Test
public void detected() throws Exception {
    HtmlSourceCode sourceCode = TestHelper.scan(new File("src/test/resources/checks/LinkToNothingCheck.html"), new LinkToNothingCheck());
    checkMessagesVerifier.verify(sourceCode.getIssues()).next().atLocation(3, 0, 3, 12).withMessage("Give this link a valid reference or remove the reference.").next().atLine(4).next().atLine(5).next().atLine(6);
}
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