use of org.sonar.java.Measurer 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.Measurer in project sonar-java by SonarSource.
the class JavaAstScannerTest method comments.
@Test
public void comments() {
File file = new File("src/test/files/metrics/Comments.java");
DefaultInputFile resource = new TestInputFileBuilder("", "src/test/files/metrics/Comments.java").build();
fs.add(resource);
NoSonarFilter noSonarFilter = mock(NoSonarFilter.class);
JavaAstScanner.scanSingleFileForTests(file, new VisitorsBridge(new Measurer(fs, context, noSonarFilter)));
verify(noSonarFilter).noSonarInFile(resource, ImmutableSet.of(15));
}
use of org.sonar.java.Measurer in project sonar-java by SonarSource.
the class JavaAstScannerTest method noSonarLines.
@Test
public void noSonarLines() throws Exception {
File file = new File("src/test/files/metrics/NoSonar.java");
DefaultInputFile resource = new TestInputFileBuilder("", "src/test/files/metrics/NoSonar.java").build();
fs.add(resource);
NoSonarFilter noSonarFilter = mock(NoSonarFilter.class);
JavaAstScanner.scanSingleFileForTests(file, new VisitorsBridge(new Measurer(fs, context, noSonarFilter)));
verify(noSonarFilter).noSonarInFile(resource, ImmutableSet.of(8));
// No Sonar on tests files
NoSonarFilter noSonarFilterForTest = mock(NoSonarFilter.class);
JavaAstScanner.scanSingleFileForTests(file, new VisitorsBridge(new Measurer(fs, context, noSonarFilterForTest).new TestFileMeasurer()));
verify(noSonarFilterForTest).noSonarInFile(resource, ImmutableSet.of(8));
}
Aggregations