aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api
diff options
context:
space:
mode:
authorBenoƮt Gianinetti <benoit.gianinetti@sonarsource.com>2018-11-30 16:51:45 +0100
committerSonarTech <sonartech@sonarsource.com>2018-12-03 20:20:58 +0100
commit10a497515e673120e7d2161b7e01c3d7e299f6a9 (patch)
tree7a42189df8199568228579908cbc5477147debb0 /sonar-plugin-api
parente24615d14077f332fa7b322c9889b1fc49bd656e (diff)
downloadsonarqube-10a497515e673120e7d2161b7e01c3d7e299f6a9.tar.gz
sonarqube-10a497515e673120e7d2161b7e01c3d7e299f6a9.zip
SONAR-11515 Add QProfileKey to ActiveRule in scanner report
Diffstat (limited to 'sonar-plugin-api')
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/ActiveRule.java5
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/internal/DefaultActiveRule.java7
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/internal/NewActiveRule.java8
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/batch/rule/internal/NewActiveRuleTest.java2
4 files changed, 22 insertions, 0 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/ActiveRule.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/ActiveRule.java
index 10290172790..6877c1700c7 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/ActiveRule.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/ActiveRule.java
@@ -72,4 +72,9 @@ public interface ActiveRule {
@CheckForNull
String templateRuleKey();
+ /**
+ * Key of the quality profile the rule belongs to.
+ * @since 7.5
+ */
+ String qpKey();
}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/internal/DefaultActiveRule.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/internal/DefaultActiveRule.java
index 9133b24e8e7..0e826756bbe 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/internal/DefaultActiveRule.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/internal/DefaultActiveRule.java
@@ -36,6 +36,7 @@ public class DefaultActiveRule implements ActiveRule {
private final Map<String, String> params;
private final long createdAt;
private final long updatedAt;
+ private final String qProfileKey;
DefaultActiveRule(NewActiveRule newActiveRule) {
this.severity = newActiveRule.severity;
@@ -46,6 +47,7 @@ public class DefaultActiveRule implements ActiveRule {
this.language = newActiveRule.language;
this.createdAt = newActiveRule.createdAt;
this.updatedAt = newActiveRule.updatedAt;
+ this.qProfileKey = newActiveRule.qProfileKey;
}
@Override
@@ -91,4 +93,9 @@ public class DefaultActiveRule implements ActiveRule {
public long updatedAt() {
return updatedAt;
}
+
+ @Override
+ public String qpKey() {
+ return qProfileKey;
+ }
}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/internal/NewActiveRule.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/internal/NewActiveRule.java
index ab6add0e14b..cc780de8e83 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/internal/NewActiveRule.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/internal/NewActiveRule.java
@@ -41,6 +41,7 @@ public class NewActiveRule {
final String internalKey;
final String language;
final String templateRuleKey;
+ final String qProfileKey;
NewActiveRule(Builder builder) {
this.ruleKey = builder.ruleKey;
@@ -52,6 +53,7 @@ public class NewActiveRule {
this.internalKey = builder.internalKey;
this.language = builder.language;
this.templateRuleKey = builder.templateRuleKey;
+ this.qProfileKey = builder.qProfileKey;
}
public static class Builder {
@@ -64,6 +66,7 @@ public class NewActiveRule {
private String internalKey;
private String language;
private String templateRuleKey;
+ private String qProfileKey;
public Builder setRuleKey(RuleKey ruleKey) {
this.ruleKey = ruleKey;
@@ -115,6 +118,11 @@ public class NewActiveRule {
return this;
}
+ public Builder setQProfileKey(String qProfileKey) {
+ this.qProfileKey = qProfileKey;
+ return this;
+ }
+
public NewActiveRule build() {
return new NewActiveRule(this);
}
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/batch/rule/internal/NewActiveRuleTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/batch/rule/internal/NewActiveRuleTest.java
index 4ecbd6e6917..833f2db040d 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/batch/rule/internal/NewActiveRuleTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/batch/rule/internal/NewActiveRuleTest.java
@@ -48,6 +48,7 @@ public class NewActiveRuleTest {
.setInternalKey("internal_key")
.setLanguage("language")
.setTemplateRuleKey("templateRuleKey")
+ .setQProfileKey("qProfileKey")
.build();
assertThat(rule.ruleKey).isEqualTo(RuleKey.of("foo", "bar"));
@@ -59,6 +60,7 @@ public class NewActiveRuleTest {
assertThat(rule.internalKey).isEqualTo("internal_key");
assertThat(rule.language).isEqualTo("language");
assertThat(rule.templateRuleKey).isEqualTo("templateRuleKey");
+ assertThat(rule.qProfileKey).isEqualTo("qProfileKey");
}
@Test