use of org.sonar.api.batch.fs.FileSystem in project sonar-php by SonarSource.
the class PHPSensor method execute.
@Override
public void execute(SensorContext context) {
DurationStatistics statistics = new DurationStatistics(context.config());
FileSystem fileSystem = context.fileSystem();
FilePredicate phpFilePredicate = fileSystem.predicates().hasLanguage(Php.KEY);
List<InputFile> inputFiles = new ArrayList<>();
fileSystem.inputFiles(phpFilePredicate).forEach(inputFiles::add);
SymbolScanner symbolScanner = new SymbolScanner(context, statistics);
try {
symbolScanner.execute(inputFiles);
ProjectSymbolData projectSymbolData = symbolScanner.getProjectSymbolData();
new AnalysisScanner(context, projectSymbolData, statistics).execute(inputFiles);
if (!inSonarLint(context)) {
processTestsAndCoverage(context);
}
} catch (CancellationException e) {
LOG.info(e.getMessage());
}
statistics.log();
}
use of org.sonar.api.batch.fs.FileSystem in project sonar-php by SonarSource.
the class PhpIniSensor method execute.
@VisibleForTesting
protected void execute(SensorContext context, Checks<PhpIniCheck> checks) {
PhpIniParser parser = new PhpIniParser();
FileSystem fs = context.fileSystem();
Iterable<InputFile> inputFiles = fs.inputFiles(fs.predicates().matchesPathPattern("**/php.ini"));
for (InputFile inputFile : inputFiles) {
PhpIniFile phpIni;
try {
phpIni = parser.parse(new PhpFileImpl(inputFile));
} catch (RecognitionException e) {
LOG.error("Unable to parse file: " + inputFile.toString());
LOG.error(e.getMessage());
continue;
}
for (PhpIniCheck check : checks.all()) {
List<PhpIniIssue> issues = check.analyze(phpIni);
saveIssues(context, inputFile, checks.ruleKey(check), issues);
}
}
}
Aggregations