use of org.sonar.api.batch.sensor.issue.NewIssueLocation 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.NewIssueLocation in project sonarqube by SonarSource.
the class AbstractDefaultIssue method addFlow.
public T addFlow(Iterable<NewIssueLocation> locations) {
List<IssueLocation> flowAsList = new ArrayList<>();
for (NewIssueLocation issueLocation : locations) {
flowAsList.add(rewriteLocation((DefaultIssueLocation) issueLocation));
}
flows.add(flowAsList);
return (T) this;
}
use of org.sonar.api.batch.sensor.issue.NewIssueLocation in project sonarqube by SonarSource.
the class DefaultIssue method addFlow.
@Override
public DefaultIssue addFlow(Iterable<NewIssueLocation> locations) {
List<IssueLocation> flowAsList = new ArrayList<>();
for (NewIssueLocation issueLocation : locations) {
flowAsList.add((DefaultIssueLocation) issueLocation);
}
flows.add(flowAsList);
return this;
}
use of org.sonar.api.batch.sensor.issue.NewIssueLocation in project sonarqube by SonarSource.
the class DeprecatedIssueBuilderWrapper method build.
@Override
public Issue build() {
if (newIssue.primaryLocation() == null) {
NewIssueLocation newLocation = newIssue.newLocation().on(primaryComponent);
if (primaryMessage != null) {
newLocation.message(primaryMessage);
}
if (primaryComponent.isFile() && primaryRange != null) {
newLocation.at(primaryRange);
}
newIssue.at(newLocation);
}
return new DeprecatedIssueWrapper(newIssue);
}
use of org.sonar.api.batch.sensor.issue.NewIssueLocation in project sonar-java by SonarSource.
the class JavaIssue method setPrimaryLocation.
public JavaIssue setPrimaryLocation(InputFile file, String message, int startLine, int startLineOffset, int endLine, int endLineOffset) {
NewIssueLocation newIssueLocation;
if (startLineOffset == -1) {
newIssueLocation = newIssue.newLocation().on(file).at(file.selectLine(startLine)).message(message);
} else {
newIssueLocation = newIssue.newLocation().on(file).at(file.newRange(startLine, startLineOffset, endLine, endLineOffset)).message(message);
}
newIssue.at(newIssueLocation);
return this;
}
Aggregations