diff options
author | lukasz-jarocki-sonarsource <lukasz.jarocki@sonarsource.com> | 2023-08-02 12:07:25 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2023-08-18 20:02:47 +0000 |
commit | f3028f632704711d23bd27ce35bb04bd56f0b984 (patch) | |
tree | 288720d69822f7c1b20948c15689ad7e6bbc567c /sonar-scanner-engine/src/main/java/org | |
parent | 5f96642125af3af740f79d19e299ca79dbd89545 (diff) | |
download | sonarqube-f3028f632704711d23bd27ce35bb04bd56f0b984.tar.gz sonarqube-f3028f632704711d23bd27ce35bb04bd56f0b984.zip |
SONAR-20021 passing overriden impacts from analyzer to scanner report
Diffstat (limited to 'sonar-scanner-engine/src/main/java/org')
-rw-r--r-- | sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/IssuePublisher.java | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/IssuePublisher.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/IssuePublisher.java index 5e3b7a6d254..3b2f99fecaf 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/IssuePublisher.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/IssuePublisher.java @@ -19,8 +19,10 @@ */ package org.sonar.scanner.issue; +import java.util.ArrayList; import java.util.Collection; import java.util.List; +import java.util.Map; import java.util.function.Consumer; import java.util.stream.Collectors; import javax.annotation.Nullable; @@ -37,6 +39,7 @@ import org.sonar.api.batch.sensor.issue.Issue.Flow; import org.sonar.api.batch.sensor.issue.MessageFormatting; import org.sonar.api.batch.sensor.issue.NewIssue.FlowType; import org.sonar.api.batch.sensor.issue.internal.DefaultIssueFlow; +import org.sonar.api.issue.impact.SoftwareQuality; import org.sonar.scanner.protocol.Constants.Severity; import org.sonar.scanner.protocol.output.ScannerReport; import org.sonar.scanner.protocol.output.ScannerReport.IssueLocation; @@ -116,6 +119,7 @@ public class IssuePublisher { builder.setRuleKey(issue.ruleKey().rule()); builder.setMsg(primaryMessage); builder.addAllMsgFormatting(toProtobufMessageFormattings(issue.primaryLocation().messageFormattings())); + builder.addAllOverridenImpacts(toProtobufImpacts(issue.overridenImpacts())); locationBuilder.setMsg(primaryMessage); locationBuilder.addAllMsgFormatting(toProtobufMessageFormattings(issue.primaryLocation().messageFormattings())); @@ -138,6 +142,12 @@ public class IssuePublisher { return builder.build(); } + private static List<ScannerReport.Impact> toProtobufImpacts(Map<SoftwareQuality, org.sonar.api.issue.impact.Severity> softwareQualitySeverityMap) { + List<ScannerReport.Impact> impacts = new ArrayList<>(); + softwareQualitySeverityMap.forEach((q, s) -> impacts.add(ScannerReport.Impact.newBuilder().setSoftwareQuality(q.name()).setSeverity(s.name()).build())); + return impacts; + } + private static List<ScannerReport.MessageFormatting> toProtobufMessageFormattings(List<MessageFormatting> messageFormattings) { return messageFormattings.stream() .map(m -> ScannerReport.MessageFormatting.newBuilder() |