Search in sources :

Example 51 with WebSourceCode

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

the class InternationalizationCheckTest method custom2.

@Test
public void custom2() {
    InternationalizationCheck check = new InternationalizationCheck();
    check.attributes = "";
    WebSourceCode sourceCode = TestHelper.scan(new File("src/test/resources/checks/InternationalizationCheck.html"), check);
    checkMessagesVerifier.verify(sourceCode.getIssues()).next().atLine(1).withMessage("Define this label in the resource bundle.");
}
Also used : WebSourceCode(org.sonar.plugins.web.visitor.WebSourceCode) File(java.io.File) Test(org.junit.Test)

Example 52 with WebSourceCode

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

the class MaxLineLengthCheckTest method test.

@Test
public void test() {
    WebSourceCode file = TestHelper.scan(new File("src/test/resources/checks/MaxLineLengthCheck.html"), new MaxLineLengthCheck());
    checkMessagesVerifier.verify(file.getIssues()).next().atLine(2).withMessage("Split this 121 characters long line (which is greater than 120 authorized).").next().atLine(3).withMessage("Split this 122 characters long line (which is greater than 120 authorized).");
}
Also used : WebSourceCode(org.sonar.plugins.web.visitor.WebSourceCode) File(java.io.File) Test(org.junit.Test)

Example 53 with WebSourceCode

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

the class MaxLineLengthCheckTest method custom.

@Test
public void custom() {
    MaxLineLengthCheck check = new MaxLineLengthCheck();
    check.maxLength = 40;
    WebSourceCode file = TestHelper.scan(new File("src/test/resources/checks/MaxLineLengthCheck.html"), check);
    checkMessagesVerifier.verify(file.getIssues()).next().atLine(1).next().atLine(2).next().atLine(3).next().atLine(6).withMessage("Split this 41 characters long line (which is greater than 40 authorized).");
}
Also used : WebSourceCode(org.sonar.plugins.web.visitor.WebSourceCode) File(java.io.File) Test(org.junit.Test)

Example 54 with WebSourceCode

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

the class UnclosedTagCheckTest method custom.

@Test
public void custom() {
    UnclosedTagCheck check = new UnclosedTagCheck();
    check.ignoreTags = "html,foo";
    WebSourceCode sourceCode = TestHelper.scan(new File("src/test/resources/checks/UnclosedTagCheck.html"), check);
    checkMessagesVerifier.verify(sourceCode.getIssues()).next().atLine(4).withMessage("The tag \"li\" has no corresponding closing tag.").next().atLine(7).withMessage("The tag \"br\" has no corresponding closing tag.");
}
Also used : WebSourceCode(org.sonar.plugins.web.visitor.WebSourceCode) File(java.io.File) Test(org.junit.Test)

Example 55 with WebSourceCode

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

the class IllegalNamespaceCheckTest method custom.

@Test
public void custom() {
    IllegalNamespaceCheck check = new IllegalNamespaceCheck();
    check.namespaces = "foo,baz";
    WebSourceCode 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 : WebSourceCode(org.sonar.plugins.web.visitor.WebSourceCode) File(java.io.File) Test(org.junit.Test)

Aggregations

WebSourceCode (org.sonar.plugins.web.visitor.WebSourceCode)93 File (java.io.File)91 Test (org.junit.Test)89 DefaultInputFile (org.sonar.api.batch.fs.internal.DefaultInputFile)10 InputFile (org.sonar.api.batch.fs.InputFile)8 FileReader (java.io.FileReader)6 PageLexer (org.sonar.plugins.web.lex.PageLexer)3 Node (org.sonar.plugins.web.node.Node)3 HtmlAstScanner (org.sonar.plugins.web.visitor.HtmlAstScanner)3 FileNotFoundException (java.io.FileNotFoundException)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.web.analyzers.ComplexityVisitor)1 PageCountLines (org.sonar.plugins.web.analyzers.PageCountLines)1