use of org.sonar.plugins.html.analyzers.PageCountLines in project sonar-web by SonarSource.
the class TestHelper method scan.
public static HtmlSourceCode scan(File file, DefaultNodeVisitor visitor) {
FileReader fileReader;
try {
fileReader = new FileReader(file);
} catch (FileNotFoundException e) {
throw new IllegalStateException(e);
}
HtmlSourceCode result = new HtmlSourceCode(new TestInputFileBuilder("key", file.getPath()).setLanguage(HtmlConstants.LANGUAGE_KEY).setType(InputFile.Type.MAIN).setModuleBaseDir(new File(".").toPath()).setCharset(StandardCharsets.UTF_8).build());
HtmlAstScanner walker = new HtmlAstScanner(Arrays.asList(new PageCountLines(), new ComplexityVisitor()));
walker.addVisitor(visitor);
walker.scan(new PageLexer().parse(fileReader), result);
return result;
}
use of org.sonar.plugins.html.analyzers.PageCountLines in project sonar-web by SonarSource.
the class HtmlSensor method setupScanner.
/**
* Create PageScanner with Visitors.
*/
private HtmlAstScanner setupScanner(SensorContext context) {
List<DefaultNodeVisitor> visitors = new ArrayList<>();
if (context.runtime().getProduct() != SonarProduct.SONARLINT) {
visitors.add(new HtmlTokensVisitor(context));
}
visitors.add(new PageCountLines());
visitors.add(new ComplexityVisitor());
visitors.add(new NoSonarScanner(noSonarFilter));
HtmlAstScanner scanner = new HtmlAstScanner(visitors);
for (Object check : checks.all()) {
((AbstractPageCheck) check).setRuleKey(checks.ruleKey(check));
scanner.addVisitor((AbstractPageCheck) check);
}
return scanner;
}
Aggregations