use of org.sonar.api.batch.fs.FileSystem in project sonar-java by SonarSource.
the class JaCoCoSensor method getReportPaths.
private static Set<File> getReportPaths(SensorContext context) {
Set<File> reportPaths = new HashSet<>();
Configuration settings = context.config();
FileSystem fs = context.fileSystem();
for (String reportPath : settings.getStringArray(REPORT_PATHS_PROPERTY)) {
File report = fs.resolvePath(reportPath);
if (!report.isFile()) {
if (settings.hasKey(REPORT_PATHS_PROPERTY)) {
LOG.info("JaCoCo report not found: '{}'", reportPath);
}
} else {
reportPaths.add(report);
}
}
getReport(settings, fs, REPORT_PATH_PROPERTY, "JaCoCo UT report not found: '{}'").ifPresent(reportPaths::add);
getReport(settings, fs, IT_REPORT_PATH_PROPERTY, "JaCoCo IT report not found: '{}'").ifPresent(reportPaths::add);
return reportPaths;
}
use of org.sonar.api.batch.fs.FileSystem in project sonar-go by SonarSource.
the class GoCoverageReport method saveFileCoverage.
private static void saveFileCoverage(SensorContext sensorContext, FileCoverage fileCoverage) {
String absolutePath = fileCoverage.absolutePath.toString();
FileSystem fileSystem = sensorContext.fileSystem();
InputFile inputFile = fileSystem.inputFile(fileSystem.predicates().hasAbsolutePath(absolutePath));
if (inputFile != null) {
LOG.debug("Saving coverage measures for file '{}'", absolutePath);
NewCoverage newCoverage = sensorContext.newCoverage().onFile(inputFile);
for (Map.Entry<Integer, LineCoverage> entry : fileCoverage.lineMap.entrySet()) {
newCoverage.lineHits(entry.getKey(), entry.getValue().hits);
}
newCoverage.save();
} else {
LOG.warn("File '{}' is not included in the project, ignoring coverage", absolutePath);
}
}
use of org.sonar.api.batch.fs.FileSystem 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.FileSystem in project sonarqube by SonarSource.
the class OneIssuePerDirectorySensor method analyse.
private static void analyse(SensorContext context) {
FileSystem fs = context.fileSystem();
FilePredicates p = fs.predicates();
RuleKey ruleKey = RuleKey.of(XooRulesDefinition.XOO_REPOSITORY, RULE_KEY);
StreamSupport.stream(fs.inputFiles(p.hasType(Type.MAIN)).spliterator(), false).map(file -> fs.inputDir(file.file().getParentFile())).filter(Objects::nonNull).distinct().forEach(inputDir -> {
NewIssue newIssue = context.newIssue();
newIssue.forRule(ruleKey).at(newIssue.newLocation().on(inputDir).message("This issue is generated for any non-empty directory")).save();
});
}
use of org.sonar.api.batch.fs.FileSystem in project sonarqube by SonarSource.
the class OneIssuePerLineSensor 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);
}
}
Aggregations