use of org.sonar.api.batch.fs.InputFile in project sonarqube by SonarSource.
the class UtCoverageSensorTest method testNoExecutionIfNoCoverageFile.
@Test
public void testNoExecutionIfNoCoverageFile() {
InputFile inputFile = new TestInputFileBuilder("foo", "src/foo.xoo").setLanguage("xoo").setModuleBaseDir(baseDir.toPath()).build();
context.fileSystem().add(inputFile);
sensor.execute(context);
}
use of org.sonar.api.batch.fs.InputFile in project sonarqube by SonarSource.
the class MeasureSensorTest method testNoExecutionIfNoMeasureFile.
@Test
public void testNoExecutionIfNoMeasureFile() {
InputFile inputFile = new TestInputFileBuilder("foo", "src/foo.xoo").setLanguage("xoo").build();
context.fileSystem().add(inputFile);
sensor.execute(context);
}
use of org.sonar.api.batch.fs.InputFile in project sonar-web by SonarSource.
the class WebSensor method saveMetrics.
private static void saveMetrics(SensorContext context, WebSourceCode sourceCode) {
InputFile inputFile = sourceCode.inputFile();
saveComplexityDistribution(context, sourceCode);
for (Map.Entry<Metric<Integer>, Integer> entry : sourceCode.getMeasures().entrySet()) {
context.<Integer>newMeasure().on(inputFile).forMetric(entry.getKey()).withValue(entry.getValue()).save();
}
for (WebIssue issue : sourceCode.getIssues()) {
NewIssue newIssue = context.newIssue().forRule(issue.ruleKey()).gap(issue.cost());
Integer line = issue.line();
NewIssueLocation location = newIssue.newLocation().on(inputFile).message(issue.message());
if (line != null) {
location.at(inputFile.selectLine(line));
}
newIssue.at(location);
newIssue.save();
}
}
use of org.sonar.api.batch.fs.InputFile in project sonarqube by SonarSource.
the class DecimalScaleSensor method analyse.
@Override
public void analyse(Project module, SensorContext context) {
if (context.settings().getBoolean(DecimalScaleProperty.KEY)) {
FilePredicate all = context.fileSystem().predicates().all();
Iterable<InputFile> files = context.fileSystem().inputFiles(all);
double value = 0.0001;
for (InputFile file : files) {
LOG.info("Value for {}: {}", file.relativePath(), value);
context.newMeasure().on(file).forMetric(DecimalScaleMetric.definition()).withValue(value).save();
value += 0.0001;
}
}
}
use of org.sonar.api.batch.fs.InputFile 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);
}
}
Aggregations