Search in sources :

Example 36 with HtmlSourceCode

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

the class UnifiedExpressionCheckTest method custom.

@Test
public void custom() {
    UnifiedExpressionCheck check = new UnifiedExpressionCheck();
    check.functions = "myMethod2,myMethod3";
    HtmlSourceCode sourceCode = TestHelper.scan(new File("src/test/resources/checks/UnifiedExpressionCheck.jsp"), check);
    checkMessagesVerifier.verify(sourceCode.getIssues()).next().atLine(2).withMessage("Fix this expression: Unknown function \"myMethod1\".").next().atLine(5).withMessage("Fix this expression: Error Parsing: ${}");
}
Also used : HtmlSourceCode(org.sonar.plugins.html.visitor.HtmlSourceCode) File(java.io.File) Test(org.junit.Test)

Example 37 with HtmlSourceCode

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

the class AbsoluteURICheckTest method detected.

@Test
public void detected() {
    HtmlSourceCode sourceCode = TestHelper.scan(new File("src/test/resources/checks/absoluteURICheck.html"), new AbsoluteURICheck());
    checkMessagesVerifier.verify(sourceCode.getIssues()).next().atLocation(3, 0, 3, 30).withMessage("Replace this absolute URI \"href\" with a relative one, or move this absolute URI to a configuration file.").next().atLine(4).withMessage("Replace this absolute URI \"href\" with a relative one, or move this absolute URI to a configuration file.").next().atLine(7).withMessage("Replace this absolute URI \"src\" with a relative one, or move this absolute URI to a configuration file.").next().atLine(8).withMessage("Replace this absolute URI \"src\" with a relative one, or move this absolute URI to a configuration file.").next().atLine(9).withMessage("Replace this absolute URI \"src\" with a relative one, or move this absolute URI to a configuration file.");
}
Also used : HtmlSourceCode(org.sonar.plugins.html.visitor.HtmlSourceCode) File(java.io.File) Test(org.junit.Test)

Example 38 with HtmlSourceCode

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

the class AbsoluteURICheckTest method custom.

@Test
public void custom() {
    AbsoluteURICheck check = new AbsoluteURICheck();
    check.attributes = "img.src";
    HtmlSourceCode sourceCode = TestHelper.scan(new File("src/test/resources/checks/absoluteURICheck.html"), check);
    checkMessagesVerifier.verify(sourceCode.getIssues()).next().atLine(7).withMessage("Replace this absolute URI \"src\" with a relative one, or move this absolute URI to a configuration file.").next().atLine(8).withMessage("Replace this absolute URI \"src\" with a relative one, or move this absolute URI to a configuration file.").next().atLine(9).withMessage("Replace this absolute URI \"src\" with a relative one, or move this absolute URI to a configuration file.");
}
Also used : HtmlSourceCode(org.sonar.plugins.html.visitor.HtmlSourceCode) File(java.io.File) Test(org.junit.Test)

Example 39 with HtmlSourceCode

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

the class DeprecatedAttributesInHtml5CheckTest method test.

@Test
public void test() {
    HtmlSourceCode sourceCode = TestHelper.scan(new File("src/test/resources/checks/deprecatedAttributesInHtml5.html"), new DeprecatedAttributesInHtml5Check());
    this.checkMessagesVerifier.verify(sourceCode.getIssues()).next().atLocation(3, 2, 3, 209).withMessage("Remove this deprecated \"CHARSET\" attribute.").next().atLine(3).withMessage("Remove this deprecated \"COORDS\" attribute.").next().atLine(3).withMessage("Remove this deprecated \"NAME\" attribute.").next().atLine(3).withMessage("Remove this deprecated \"SHAPE\" attribute.").next().atLine(6).withMessage("Remove this deprecated \"bordercolor\" attribute.").next().atLine(15).withMessage("Remove this deprecated \"code\" attribute.").next().atLine(18).withMessage("Remove this deprecated \"border\" attribute.").next().atLine(20).withMessage("Remove this deprecated \"name\" attribute.").next().atLine(22).withMessage("Remove this deprecated \"name\" attribute.").next().atLine(25).withMessage("Remove this deprecated \"align\" attribute.").next().atLine(27).withMessage("Remove this deprecated \"language\" attribute.").next().atLine(32).withMessage("Remove this deprecated \"[border]\" attribute.").next().atLine(33).withMessage("Remove this deprecated \"[datafld]\" attribute.").next().atLine(35).withMessage("Remove this deprecated \"[attr.datafld]\" attribute.");
}
Also used : HtmlSourceCode(org.sonar.plugins.html.visitor.HtmlSourceCode) File(java.io.File) Test(org.junit.Test)

Example 40 with HtmlSourceCode

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

the class FlashUsesBothObjectAndEmbedCheckTest method detected.

@Test
public void detected() throws Exception {
    HtmlSourceCode sourceCode = TestHelper.scan(new File("src/test/resources/checks/FlashUsesBothObjectAndEmbedCheck.html"), new FlashUsesBothObjectAndEmbedCheck());
    checkMessagesVerifier.verify(sourceCode.getIssues()).next().atLocation(1, 0, 1, 86).withMessage("Add an <embed> tag within this <object> one.").next().atLine(5).next().atLine(9).next().atLocation(25, 0, 28, 67).withMessage("Surround this <embed> tag by an <object> one.").next().atLine(30).next().atLine(54);
}
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