use of org.sonar.java.JavaSquid in project sonar-java by SonarSource.
the class FileLinesVisitorTest method countTrivia.
private int countTrivia(String filename) {
TriviaVisitor triviaVisitor = new TriviaVisitor();
JavaSquid squid = new JavaSquid(new JavaVersionImpl(), null, null, null, null, triviaVisitor);
squid.scan(Lists.newArrayList(new File(baseDir, filename)), Collections.emptyList());
return triviaVisitor.numberTrivia;
}
use of org.sonar.java.JavaSquid in project sonar-java by SonarSource.
the class FileLinesVisitorTest method checkLines.
private void checkLines(String filename, FileLinesContext context) {
SonarComponents sonarComponents = mock(SonarComponents.class);
when(sonarComponents.fileLength(Mockito.any(File.class))).thenAnswer(invocation -> {
File arg = (File) invocation.getArguments()[0];
return Files.readLines(arg, StandardCharsets.UTF_8).size();
});
when(sonarComponents.fileLinesContextFor(Mockito.any(File.class))).thenReturn(context);
JavaSquid squid = new JavaSquid(new JavaVersionImpl(), null, null, null, null, new FileLinesVisitor(sonarComponents));
squid.scan(Lists.newArrayList(new File(baseDir, filename)), Collections.emptyList());
}
use of org.sonar.java.JavaSquid in project sonar-java by SonarSource.
the class JavaSquidSensor method execute.
@Override
public void execute(SensorContext context) {
javaResourceLocator.setSensorContext(context);
sonarComponents.setSensorContext(context);
sonarComponents.setRuleRepositoryKey(CheckList.REPOSITORY_KEY);
List<Class<? extends JavaCheck>> checks = ImmutableList.<Class<? extends JavaCheck>>builder().addAll(CheckList.getJavaChecks()).addAll(CheckList.getDebugChecks()).build();
sonarComponents.registerCheckClasses(CheckList.REPOSITORY_KEY, checks);
sonarComponents.registerTestCheckClasses(CheckList.REPOSITORY_KEY, CheckList.getJavaTestChecks());
Measurer measurer = new Measurer(fs, context, noSonarFilter);
JavaSquid squid = new JavaSquid(getJavaVersion(), isXFileEnabled(), sonarComponents, measurer, javaResourceLocator, postAnalysisIssueFilter, sonarComponents.checkClasses());
squid.scan(getSourceFiles(), getTestFiles());
sonarComponents.saveAnalysisErrors();
}
use of org.sonar.java.JavaSquid in project sonar-java by SonarSource.
the class SyntaxHighlighterVisitorTest method scan.
private void scan(File file) {
JavaSquid squid = new JavaSquid(new JavaVersionImpl(), null, null, null, null, new JavaCheck[] { syntaxHighlighterVisitor });
squid.scan(Lists.newArrayList(file), Collections.<File>emptyList());
}
Aggregations