use of org.sonar.plugins.web.analyzers.ComplexityVisitor in project sonar-web by SonarSource.
the class TestHelper method scan.
public static WebSourceCode scan(File file, DefaultNodeVisitor visitor) {
FileReader fileReader;
try {
fileReader = new FileReader(file);
} catch (FileNotFoundException e) {
throw Throwables.propagate(e);
}
WebSourceCode result = new WebSourceCode(new DefaultInputFile("key", file.getPath()).setLanguage(WebConstants.LANGUAGE_KEY).setType(InputFile.Type.MAIN).setModuleBaseDir(new File(".").toPath()));
HtmlAstScanner walker = new HtmlAstScanner(ImmutableList.of(new PageCountLines(), new ComplexityVisitor()));
walker.addVisitor(visitor);
walker.scan(new PageLexer().parse(fileReader), result, Charsets.UTF_8);
return result;
}
use of org.sonar.plugins.web.analyzers.ComplexityVisitor in project sonar-web by SonarSource.
the class WebSensor method setupScanner.
/**
* Create PageScanner with Visitors.
*/
private HtmlAstScanner setupScanner(SensorContext context) {
HtmlAstScanner scanner = new HtmlAstScanner(ImmutableList.of(new WebTokensVisitor(context), new PageCountLines(), new ComplexityVisitor(), new NoSonarScanner(noSonarFilter)));
for (Object check : checks.all()) {
((AbstractPageCheck) check).setRuleKey(checks.ruleKey(check));
scanner.addVisitor((AbstractPageCheck) check);
}
return scanner;
}
Aggregations