diff options
author | Lukasz Jarocki <lukasz.jarocki@sonarsource.com> | 2022-07-06 09:09:17 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2022-07-08 20:02:48 +0000 |
commit | 39f4503d689f20e83edfbd48d24d1d37acc46c20 (patch) | |
tree | 9180e24e06620012fbdc7820bcb4491789d32177 /sonar-plugin-api-impl/src | |
parent | 7ab8cee5c0551d96cacda12d4df3d3a17c0ac2d2 (diff) | |
download | sonarqube-39f4503d689f20e83edfbd48d24d1d37acc46c20.tar.gz sonarqube-39f4503d689f20e83edfbd48d24d1d37acc46c20.zip |
SONAR-16614 saving detected context in the scanner report
Diffstat (limited to 'sonar-plugin-api-impl/src')
2 files changed, 16 insertions, 1 deletions
diff --git a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/issue/internal/DefaultIssue.java b/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/issue/internal/DefaultIssue.java index c5189dd2d58..b36f7125b8c 100644 --- a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/issue/internal/DefaultIssue.java +++ b/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/issue/internal/DefaultIssue.java @@ -19,6 +19,7 @@ */ package org.sonar.api.batch.sensor.issue.internal; +import java.util.Optional; import javax.annotation.Nullable; import org.sonar.api.batch.rule.Severity; import org.sonar.api.batch.sensor.internal.SensorStorage; @@ -38,6 +39,7 @@ public class DefaultIssue extends AbstractDefaultIssue<DefaultIssue> implements private Double gap; private Severity overriddenSeverity; private boolean quickFixAvailable = false; + private String ruleDescriptionContextKey; public DefaultIssue(DefaultInputProject project) { this(project, null); @@ -76,11 +78,22 @@ public class DefaultIssue extends AbstractDefaultIssue<DefaultIssue> implements } @Override + public DefaultIssue setRuleDescriptionContextKey(@Nullable String ruleDescriptionContextKey) { + this.ruleDescriptionContextKey = ruleDescriptionContextKey; + return this; + } + + @Override public boolean isQuickFixAvailable() { return quickFixAvailable; } @Override + public Optional<String> ruleDescriptionContextKey() { + return Optional.ofNullable(ruleDescriptionContextKey); + } + + @Override public Severity overriddenSeverity() { return this.overriddenSeverity; } diff --git a/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/issue/internal/DefaultIssueTest.java b/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/issue/internal/DefaultIssueTest.java index d0901893e24..686f804812e 100644 --- a/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/issue/internal/DefaultIssueTest.java +++ b/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/issue/internal/DefaultIssueTest.java @@ -67,13 +67,15 @@ public class DefaultIssueTest { .at(inputFile.selectLine(1)) .message("Wrong way!")) .forRule(RuleKey.of("repo", "rule")) - .gap(10.0); + .gap(10.0) + .setRuleDescriptionContextKey("spring"); assertThat(issue.primaryLocation().inputComponent()).isEqualTo(inputFile); assertThat(issue.ruleKey()).isEqualTo(RuleKey.of("repo", "rule")); assertThat(issue.primaryLocation().textRange().start().line()).isOne(); assertThat(issue.gap()).isEqualTo(10.0); assertThat(issue.primaryLocation().message()).isEqualTo("Wrong way!"); + assertThat(issue.ruleDescriptionContextKey()).contains("spring"); issue.save(); |