Search in sources :

Example 16 with WebSourceCode

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

the class JspScriptletCheckTest method test.

@Test
public void test() throws Exception {
    WebSourceCode sourceCode = TestHelper.scan(new File("src/test/resources/checks/jspScriptletCheck.html"), new JspScriptletCheck());
    checkMessagesVerifier.verify(sourceCode.getIssues()).next().atLine(1).withMessage("Replace this scriptlet using tag libraries and expression language.").next().atLine(8);
}
Also used : WebSourceCode(org.sonar.plugins.web.visitor.WebSourceCode) File(java.io.File) Test(org.junit.Test)

Example 17 with WebSourceCode

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

the class LongJavaScriptCheckTest method custom.

@Test
public void custom() {
    LongJavaScriptCheck check = new LongJavaScriptCheck();
    check.maxLines = 4;
    WebSourceCode 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 : WebSourceCode(org.sonar.plugins.web.visitor.WebSourceCode) File(java.io.File) Test(org.junit.Test)

Example 18 with WebSourceCode

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

the class UnifiedExpressionCheckTest method should_not_detect_unknown_functions_with_empty_list.

@Test
public void should_not_detect_unknown_functions_with_empty_list() {
    UnifiedExpressionCheck check = new UnifiedExpressionCheck();
    check.functions = "";
    WebSourceCode sourceCode = TestHelper.scan(new File("src/test/resources/checks/UnifiedExpressionCheck.jsp"), check);
    checkMessagesVerifier.verify(sourceCode.getIssues()).next().atLine(5);
}
Also used : WebSourceCode(org.sonar.plugins.web.visitor.WebSourceCode) File(java.io.File) Test(org.junit.Test)

Example 19 with WebSourceCode

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

the class UnifiedExpressionCheckTest method custom.

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

Example 20 with WebSourceCode

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

the class AbsoluteURICheckTest method detected.

@Test
public void detected() {
    WebSourceCode sourceCode = TestHelper.scan(new File("src/test/resources/checks/absoluteURICheck.html"), new AbsoluteURICheck());
    checkMessagesVerifier.verify(sourceCode.getIssues()).next().atLine(3).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 : 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