use of org.sonar.api.batch.sensor.issue.NewIssue in project sonarqube by SonarSource.
the class OneIssuePerUnknownFileSensor method execute.
@Override
public void execute(SensorContext context) {
RuleKey ruleKey = RuleKey.of(XooRulesDefinition.XOO_REPOSITORY, RULE_KEY);
FilePredicate unknownFilesPredicate = context.fileSystem().predicates().matchesPathPattern("**/*.unknown");
Iterable<InputFile> unknownFiles = context.fileSystem().inputFiles(unknownFilesPredicate);
unknownFiles.forEach(inputFile -> {
NewIssue newIssue = context.newIssue();
newIssue.forRule(ruleKey).at(newIssue.newLocation().on(inputFile).message("This issue is generated on each file with extension 'unknown'")).save();
});
}
use of org.sonar.api.batch.sensor.issue.NewIssue in project sonarqube by SonarSource.
the class OneVulnerabilityIssuePerModuleSensor method analyse.
private void analyse(SensorContext context, String repo) {
RuleKey ruleKey = RuleKey.of(repo, RULE_KEY);
NewIssue newIssue = context.newIssue();
newIssue.forRule(ruleKey).at(newIssue.newLocation().on(context.module()).message("This issue is generated on each module")).save();
}
use of org.sonar.api.batch.sensor.issue.NewIssue in project sonarqube by SonarSource.
the class SensorContextTesterTest method testIssues.
@Test
public void testIssues() {
assertThat(tester.allIssues()).isEmpty();
NewIssue newIssue = tester.newIssue();
newIssue.at(newIssue.newLocation().on(new TestInputFileBuilder("foo", "src/Foo.java").build())).forRule(RuleKey.of("repo", "rule")).save();
newIssue = tester.newIssue();
newIssue.at(newIssue.newLocation().on(new TestInputFileBuilder("foo", "src/Foo.java").build())).forRule(RuleKey.of("repo", "rule")).save();
assertThat(tester.allIssues()).hasSize(2);
}
Aggregations