dependency 'org.sonarsource.kotlin:sonar-kotlin-plugin:2.9.0.1147'
dependency 'org.sonarsource.slang:sonar-ruby-plugin:1.9.0.3429'
dependency 'org.sonarsource.slang:sonar-scala-plugin:1.9.0.3429'
- dependency 'org.sonarsource.api.plugin:sonar-plugin-api:9.7.0.160'
+ dependency 'org.sonarsource.api.plugin:sonar-plugin-api:9.8.0.196'
dependency 'org.sonarsource.xml:sonar-xml-plugin:2.5.0.3376'
dependency 'org.sonarsource.iac:sonar-iac-plugin:1.7.0.2012'
dependency 'org.sonarsource.text:sonar-text-plugin:1.1.0.282'
*/
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;
private Double gap;
private Severity overriddenSeverity;
private boolean quickFixAvailable = false;
+ private String ruleDescriptionContextKey;
public DefaultIssue(DefaultInputProject project) {
this(project, null);
return this;
}
+ @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;
.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();
}
applyFlows(builder::addFlow, locationBuilder, textRangeBuilder, issue.flows());
builder.setQuickFixAvailable(issue.isQuickFixAvailable());
+ issue.ruleDescriptionContextKey().ifPresent(builder::setRuleDescriptionContextKey);
return builder.build();
}
.build());
initModuleIssues();
+ final String ruleDescriptionContextKey = "spring";
DefaultIssue issue = new DefaultIssue(project)
.at(new DefaultIssueLocation().on(file).at(file.selectLine(3)).message("Foo"))
.forRule(JAVA_RULE_KEY)
.overrideSeverity(org.sonar.api.batch.rule.Severity.CRITICAL)
- .setQuickFixAvailable(true);
+ .setQuickFixAvailable(true)
+ .setRuleDescriptionContextKey(ruleDescriptionContextKey);
when(filters.accept(any(InputComponent.class), any(ScannerReport.Issue.class))).thenReturn(true);
verify(reportPublisher.getWriter()).appendComponentIssue(eq(file.scannerId()), argument.capture());
assertThat(argument.getValue().getSeverity()).isEqualTo(org.sonar.scanner.protocol.Constants.Severity.CRITICAL);
assertThat(argument.getValue().getQuickFixAvailable()).isTrue();
+ assertThat(argument.getValue().getRuleDescriptionContextKey()).isEqualTo(ruleDescriptionContextKey);
}
@Test
TextRange text_range = 6;
repeated Flow flow = 7;
bool quickFixAvailable = 8;
+ optional string ruleDescriptionContextKey = 9;
}
message ExternalIssue {