Search in sources :

Example 6 with NewIssueLocation

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;
    }
}
Also used : NewIssueLocation(org.sonar.api.batch.sensor.issue.NewIssueLocation) NewExternalIssue(org.sonar.api.batch.sensor.issue.NewExternalIssue) NewIssueLocation(org.sonar.api.batch.sensor.issue.NewIssueLocation) Location(org.sonar.scanner.externalissue.ReportParser.Location)

Example 7 with NewIssueLocation

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;
}
Also used : NewIssueLocation(org.sonar.api.batch.sensor.issue.NewIssueLocation) ArrayList(java.util.ArrayList) IssueLocation(org.sonar.api.batch.sensor.issue.IssueLocation) NewIssueLocation(org.sonar.api.batch.sensor.issue.NewIssueLocation)

Example 8 with NewIssueLocation

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;
}
Also used : NewIssueLocation(org.sonar.api.batch.sensor.issue.NewIssueLocation) ArrayList(java.util.ArrayList) IssueLocation(org.sonar.api.batch.sensor.issue.IssueLocation) NewIssueLocation(org.sonar.api.batch.sensor.issue.NewIssueLocation)

Example 9 with NewIssueLocation

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);
}
Also used : NewIssueLocation(org.sonar.api.batch.sensor.issue.NewIssueLocation)

Example 10 with NewIssueLocation

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;
}
Also used : NewIssueLocation(org.sonar.api.batch.sensor.issue.NewIssueLocation)

Aggregations

NewIssueLocation (org.sonar.api.batch.sensor.issue.NewIssueLocation)12 NewIssue (org.sonar.api.batch.sensor.issue.NewIssue)5 Map (java.util.Map)3 ArrayList (java.util.ArrayList)2 InputFile (org.sonar.api.batch.fs.InputFile)2 IssueLocation (org.sonar.api.batch.sensor.issue.IssueLocation)2 Metric (org.sonar.api.measures.Metric)2 RuleKey (org.sonar.api.rule.RuleKey)2 PreciseHtmlIssue (org.sonar.plugins.html.checks.PreciseHtmlIssue)2 HashMap (java.util.HashMap)1 TextPointer (org.sonar.api.batch.fs.TextPointer)1 NewExternalIssue (org.sonar.api.batch.sensor.issue.NewExternalIssue)1 HtmlIssue (org.sonar.plugins.html.checks.HtmlIssue)1 WebIssue (org.sonar.plugins.web.checks.WebIssue)1 Location (org.sonar.scanner.externalissue.ReportParser.Location)1