Search in sources :

Example 91 with HtmlSourceCode

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

the class FieldsetWithoutLegendCheckTest method detected.

@Test
public void detected() throws Exception {
    HtmlSourceCode sourceCode = TestHelper.scan(new File("src/test/resources/checks/FieldsetWithoutLegendCheck.html"), new FieldsetWithoutLegendCheck());
    checkMessagesVerifier.verify(sourceCode.getIssues()).next().atLocation(2, 2, 2, 12).withMessage("Add a <legend> tag to this fieldset.");
}
Also used : HtmlSourceCode(org.sonar.plugins.html.visitor.HtmlSourceCode) File(java.io.File) Test(org.junit.Test)

Example 92 with HtmlSourceCode

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

the class FrameWithoutTitleCheckTest method test.

@Test
public void test() throws Exception {
    HtmlSourceCode sourceCode = TestHelper.scan(new File("src/test/resources/checks/FrameWithoutTitleCheck.html"), new FrameWithoutTitleCheck());
    checkMessagesVerifier.verify(sourceCode.getIssues()).next().atLocation(1, 0, 1, 23).withMessage("Add a \"title\" attribute to this <iframe> tag.").next().atLine(2).withMessage("Add a \"title\" attribute to this <fRamE> tag.");
}
Also used : HtmlSourceCode(org.sonar.plugins.html.visitor.HtmlSourceCode) File(java.io.File) Test(org.junit.Test)

Example 93 with HtmlSourceCode

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

the class InputWithoutLabelCheckTest method detected.

@Test
public void detected() throws Exception {
    HtmlSourceCode sourceCode = TestHelper.scan(new File("src/test/resources/checks/InputWithoutLabelCheck.html"), new InputWithoutLabelCheck());
    checkMessagesVerifier.verify(sourceCode.getIssues()).next().atLocation(6, 0, 6, 31).withMessage("Associate a valid label to this input field.").next().atLine(19).next().atLocation(23, 0, 23, 19).withMessage("Add an \"id\" attribute to this input field and associate it with a label.").next().atLine(25).withMessage("Add an \"id\" attribute to this input field and associate it with a label.").next().atLine(26).withMessage("Add an \"id\" attribute to this input field and associate it with a label.").next().atLine(28).withMessage("Associate a valid label to this input field.").next().atLine(32).next().atLine(43).next().atLine(56).next().atLocation(59, 0, 59, 72).withMessage("Use valid ids in \"aria-labelledby\" attribute. Following ids were not found: \"missing\",\"missing2\".");
}
Also used : HtmlSourceCode(org.sonar.plugins.html.visitor.HtmlSourceCode) File(java.io.File) Test(org.junit.Test)

Example 94 with HtmlSourceCode

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

the class MultiplePageDirectivesCheckTest method test3.

@Test
public void test3() throws Exception {
    HtmlSourceCode sourceCode = TestHelper.scan(new File("src/test/resources/checks/multiplePageDirectivesCheck3.html"), new MultiplePageDirectivesCheck());
    assertThat(sourceCode.getIssues()).isEmpty();
}
Also used : HtmlSourceCode(org.sonar.plugins.html.visitor.HtmlSourceCode) File(java.io.File) Test(org.junit.Test)

Example 95 with HtmlSourceCode

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

the class LongJavaScriptCheckTest method custom.

@Test
public void custom() {
    LongJavaScriptCheck check = new LongJavaScriptCheck();
    check.maxLines = 4;
    HtmlSourceCode sourceCode = TestHelper.scan(new File("src/test/resources/checks/LongJavaScriptCheck.html"), check);
    checkMessagesVerifier.verify(sourceCode.getIssues()).next().atLine(7).withCost(2d).withMessage("The length of this JS script (6) exceeds the maximum set to 4.");
}
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