use of org.sonar.api.batch.fs.FilePredicates in project sonarqube by SonarSource.
the class MultilineIssuesSensor method execute.
@Override
public void execute(SensorContext context) {
FileSystem fs = context.fileSystem();
FilePredicates p = fs.predicates();
for (InputFile file : fs.inputFiles(p.and(p.hasLanguages(Xoo.KEY), p.hasType(Type.MAIN)))) {
createIssues(file, context);
}
}
use of org.sonar.api.batch.fs.FilePredicates in project sonarqube by SonarSource.
the class CreateIssueByInternalKeySensor method execute.
@Override
public void execute(SensorContext context) {
FileSystem fs = context.fileSystem();
FilePredicates p = fs.predicates();
for (InputFile file : fs.inputFiles(p.and(p.hasLanguages(Xoo.KEY), p.hasType(Type.MAIN)))) {
createIssues(file, context);
}
}
use of org.sonar.api.batch.fs.FilePredicates in project sonarqube by SonarSource.
the class OneBugIssuePerLineSensor method analyse.
private void analyse(SensorContext context, String language, String repo) {
FileSystem fs = context.fileSystem();
FilePredicates p = fs.predicates();
for (InputFile file : fs.inputFiles(p.and(p.hasLanguages(language), p.hasType(Type.MAIN)))) {
createIssues(file, context, repo);
}
}
use of org.sonar.api.batch.fs.FilePredicates in project sonarqube by SonarSource.
the class RandomAccessSensor method execute.
@Override
public void execute(SensorContext context) {
File f = new File(context.settings().getString(SONAR_XOO_RANDOM_ACCESS_ISSUE_PATHS));
FileSystem fs = context.fileSystem();
FilePredicates p = fs.predicates();
try {
for (String path : FileUtils.readLines(f)) {
createIssues(fs.inputFile(p.and(p.hasPath(path), p.hasType(Type.MAIN), p.hasLanguage(Xoo.KEY))), context);
}
} catch (IOException e) {
throw new IllegalStateException(e);
}
}
use of org.sonar.api.batch.fs.FilePredicates in project sonar-web by SonarSource.
the class WebSensor method execute.
@Override
public void execute(SensorContext sensorContext) {
// configure the lexer
final PageLexer lexer = new PageLexer();
FileSystem fileSystem = sensorContext.fileSystem();
// configure page scanner and the visitors
final HtmlAstScanner scanner = setupScanner(sensorContext);
FilePredicates predicates = fileSystem.predicates();
Iterable<InputFile> inputFiles = fileSystem.inputFiles(predicates.and(predicates.hasType(InputFile.Type.MAIN), predicates.hasLanguage(WebConstants.LANGUAGE_KEY)));
for (InputFile inputFile : inputFiles) {
WebSourceCode sourceCode = new WebSourceCode(inputFile);
try (FileReader reader = new FileReader(inputFile.file())) {
scanner.scan(lexer.parse(reader), sourceCode, fileSystem.encoding());
saveMetrics(sensorContext, sourceCode);
saveLineLevelMeasures(inputFile, sourceCode);
} catch (Exception e) {
LOG.error("Cannot analyze file " + inputFile.file().getAbsolutePath(), e);
}
}
}
Aggregations