use of org.sonar.api.batch.sensor.issue.NewExternalIssue in project sonarqube by SonarSource.
the class OnePredefinedAndAdHocRuleExternalIssuePerLineSensor method createIssues.
private static void createIssues(InputFile file, SensorContext context) {
for (int line = 1; line <= file.lines(); line++) {
NewExternalIssue newIssue = context.newExternalIssue();
newIssue.engineId(OnePredefinedRuleExternalIssuePerLineSensor.ENGINE_ID).ruleId(OnePredefinedRuleExternalIssuePerLineSensor.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(OnePredefinedRuleExternalIssuePerLineSensor.SEVERITY)).remediationEffortMinutes(OnePredefinedRuleExternalIssuePerLineSensor.EFFORT).type(OnePredefinedRuleExternalIssuePerLineSensor.TYPE).save();
// Even if the issue is on a predefined rule, the sensor is declaring an adHoc rule => this info should be ignored
context.newAdHocRule().engineId(OnePredefinedRuleExternalIssuePerLineSensor.ENGINE_ID).ruleId(OnePredefinedRuleExternalIssuePerLineSensor.RULE_ID).name("An ad hoc rule").description("blah blah").severity(Severity.BLOCKER).type(RuleType.BUG).save();
}
}
use of org.sonar.api.batch.sensor.issue.NewExternalIssue in project sonarqube by SonarSource.
the class OneExternalIssuePerLineWithoutMessageSensor 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("")).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 OneExternalIssuePerLineSensor 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")).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 ExternalIssueImporter method importIssue.
private boolean importIssue(Issue issue) {
NewExternalIssue externalIssue = context.newExternalIssue().engineId(issue.engineId).ruleId(issue.ruleId).severity(Severity.valueOf(issue.severity)).type(RuleType.valueOf(issue.type));
if (issue.effortMinutes != null) {
externalIssue.remediationEffortMinutes(Long.valueOf(issue.effortMinutes));
}
NewIssueLocation primary = fillLocation(context, externalIssue.newLocation(), issue.primaryLocation);
if (primary != null) {
knownFiles.add(issue.primaryLocation.filePath);
externalIssue.at(primary);
if (issue.secondaryLocations != null) {
for (Location l : issue.secondaryLocations) {
NewIssueLocation secondary = fillLocation(context, externalIssue.newLocation(), l);
if (secondary != null) {
externalIssue.addLocation(secondary);
}
}
}
externalIssue.save();
return true;
} else {
unknownFiles.add(issue.primaryLocation.filePath);
return false;
}
}
use of org.sonar.api.batch.sensor.issue.NewExternalIssue in project sonarqube by SonarSource.
the class OneExternalIssueOnProjectSensor method analyse.
private static void analyse(SensorContext context) {
NewExternalIssue newIssue = context.newExternalIssue();
newIssue.engineId(ENGINE_ID).ruleId(RULE_ID).at(newIssue.newLocation().on(context.project()).message("This issue is generated at project level")).severity(Severity.valueOf(SEVERITY)).type(TYPE).save();
}
Aggregations