use of org.sonar.api.batch.sensor.issue.NewExternalIssue in project sonarqube by SonarSource.
the class OnePredefinedRuleExternalIssuePerLineSensor method createIssues.
private static void createIssues(InputFile file, SensorContext context) {
for (int line = 1; line <= file.lines(); line++) {
NewExternalIssue newIssue = context.newExternalIssue();
newIssue.engineId(ENGINE_ID).ruleId(RULE_ID).at(newIssue.newLocation().on(file).at(file.selectLine(line)).message("This issue is generated on each line and the rule is predefined")).severity(Severity.valueOf(SEVERITY)).remediationEffortMinutes(EFFORT).type(TYPE).save();
}
}
use of org.sonar.api.batch.sensor.issue.NewExternalIssue in project sonarqube by SonarSource.
the class SensorContextTesterTest method testExternalIssues.
@Test
public void testExternalIssues() {
assertThat(tester.allExternalIssues()).isEmpty();
NewExternalIssue newExternalIssue = tester.newExternalIssue();
newExternalIssue.at(newExternalIssue.newLocation().message("message").on(new TestInputFileBuilder("foo", "src/Foo.java").build())).forRule(RuleKey.of("repo", "rule")).type(RuleType.BUG).severity(Severity.BLOCKER).save();
newExternalIssue = tester.newExternalIssue();
newExternalIssue.at(newExternalIssue.newLocation().message("message").on(new TestInputFileBuilder("foo", "src/Foo.java").build())).type(RuleType.BUG).severity(Severity.BLOCKER).forRule(RuleKey.of("repo", "rule")).save();
assertThat(tester.allExternalIssues()).hasSize(2);
}
Aggregations