diff options
author | Duarte Meneses <duarte.meneses@sonarsource.com> | 2022-09-06 16:28:00 -0500 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2022-09-16 20:03:13 +0000 |
commit | 00431799f91fa3b5e7b28d4379991e2456a41ea4 (patch) | |
tree | a1e89e9094e4cbacc77a2799daf913c9c4cd36d6 /sonar-scanner-engine/src/main/java/org | |
parent | dcc6a1c62033cec81c70f740fe3e7a7f745a3e79 (diff) | |
download | sonarqube-00431799f91fa3b5e7b28d4379991e2456a41ea4.tar.gz sonarqube-00431799f91fa3b5e7b28d4379991e2456a41ea4.zip |
SONAR-17287 Scanner supports flow types and description
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 | 23 | ||||
-rw-r--r-- | sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ReportPublisher.java | 6 |
2 files changed, 23 insertions, 6 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 48ac551dd1c..f9b38d860cb 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 @@ -25,13 +25,14 @@ import javax.annotation.Nullable; import javax.annotation.concurrent.ThreadSafe; import org.apache.commons.lang.StringUtils; import org.sonar.api.batch.fs.TextRange; +import org.sonar.api.batch.fs.internal.DefaultInputComponent; +import org.sonar.api.batch.fs.internal.DefaultInputFile; import org.sonar.api.batch.rule.ActiveRule; import org.sonar.api.batch.rule.ActiveRules; import org.sonar.api.batch.sensor.issue.ExternalIssue; import org.sonar.api.batch.sensor.issue.Issue; import org.sonar.api.batch.sensor.issue.Issue.Flow; -import org.sonar.api.batch.fs.internal.DefaultInputComponent; -import org.sonar.api.batch.fs.internal.DefaultInputFile; +import org.sonar.api.batch.sensor.issue.internal.DefaultIssueFlow; import org.sonar.scanner.protocol.Constants.Severity; import org.sonar.scanner.protocol.output.ScannerReport; import org.sonar.scanner.protocol.output.ScannerReport.IssueLocation; @@ -160,7 +161,8 @@ public class IssuePublisher { private static void applyFlows(Consumer<ScannerReport.Flow> consumer, ScannerReport.IssueLocation.Builder locationBuilder, ScannerReport.TextRange.Builder textRangeBuilder, Collection<Flow> flows) { ScannerReport.Flow.Builder flowBuilder = ScannerReport.Flow.newBuilder(); - for (Flow flow : flows) { + for (Flow f : flows) { + DefaultIssueFlow flow = (DefaultIssueFlow) f; if (flow.locations().isEmpty()) { return; } @@ -179,10 +181,25 @@ public class IssuePublisher { } flowBuilder.addLocation(locationBuilder.build()); } + if (flow.getDescription() != null) { + flowBuilder.setDescription(flow.getDescription()); + } + flowBuilder.setType(toProtobufFlowType(flow.getType())); consumer.accept(flowBuilder.build()); } } + private static ScannerReport.FlowType toProtobufFlowType(DefaultIssueFlow.Type flowType) { + switch (flowType) { + case EXECUTION: + return ScannerReport.FlowType.EXECUTION; + case DATA: + return ScannerReport.FlowType.DATA; + default: + return ScannerReport.FlowType.UNDEFINED; + } + } + private static ScannerReport.TextRange toProtobufTextRange(ScannerReport.TextRange.Builder textRangeBuilder, TextRange primaryTextRange) { textRangeBuilder.clear(); textRangeBuilder.setStartLine(primaryTextRange.start().line()); diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ReportPublisher.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ReportPublisher.java index 574fdd1e2a1..0fc66aa1c5f 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ReportPublisher.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ReportPublisher.java @@ -79,9 +79,9 @@ public class ReportPublisher implements Startable { private final ScanProperties properties; private final CeTaskReportDataHolder ceTaskReportDataHolder; - private Path reportDir; - private ScannerReportWriter writer; - private ScannerReportReader reader; + private final Path reportDir; + private final ScannerReportWriter writer; + private final ScannerReportReader reader; public ReportPublisher(ScanProperties properties, DefaultScannerWsClient wsClient, Server server, AnalysisContextReportPublisher contextPublisher, InputModuleHierarchy moduleHierarchy, GlobalAnalysisMode analysisMode, TempFolder temp, ReportPublisherStep[] publishers, BranchConfiguration branchConfiguration, |