aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api/src/main
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2016-03-03 14:50:06 +0100
committerJulien Lancelot <julien.lancelot@sonarsource.com>2016-03-07 13:52:30 +0100
commit42edb969fa18f06b89bcae0fec67f96fd2598cb8 (patch)
tree7f2aa389acd65e835aef8153d2c91c408828f5fd /sonar-plugin-api/src/main
parent566344e3147346029b513132b4c745378b546daf (diff)
downloadsonarqube-42edb969fa18f06b89bcae0fec67f96fd2598cb8.tar.gz
sonarqube-42edb969fa18f06b89bcae0fec67f96fd2598cb8.zip
SONAR-7337 "sqale_index" and "new_technical_debt" only use "Code Smell" issues
Diffstat (limited to 'sonar-plugin-api/src/main')
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/ce/measure/Issue.java3
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/ce/measure/test/TestIssue.java24
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/measures/CoreMetrics.java10
3 files changed, 37 insertions, 0 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/ce/measure/Issue.java b/sonar-plugin-api/src/main/java/org/sonar/api/ce/measure/Issue.java
index 2ce9a6766b5..4dd391e8f39 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/ce/measure/Issue.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/ce/measure/Issue.java
@@ -21,6 +21,7 @@ package org.sonar.api.ce.measure;
import javax.annotation.CheckForNull;
import org.sonar.api.rule.RuleKey;
+import org.sonar.api.rules.RuleType;
import org.sonar.api.utils.Duration;
/**
@@ -53,4 +54,6 @@ public interface Issue {
@CheckForNull
Duration debt();
+ RuleType type();
+
}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/ce/measure/test/TestIssue.java b/sonar-plugin-api/src/main/java/org/sonar/api/ce/measure/test/TestIssue.java
index 4975b1dedd5..aa743661b36 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/ce/measure/test/TestIssue.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/ce/measure/test/TestIssue.java
@@ -25,6 +25,7 @@ import javax.annotation.concurrent.Immutable;
import org.sonar.api.ce.measure.Issue;
import org.sonar.api.rule.RuleKey;
import org.sonar.api.rule.Severity;
+import org.sonar.api.rules.RuleType;
import org.sonar.api.utils.Duration;
import static com.google.common.base.Preconditions.checkArgument;
@@ -39,6 +40,7 @@ public class TestIssue implements Issue {
private String severity;
private RuleKey ruleKey;
private Duration debt;
+ private RuleType type;
private TestIssue(Builder builder) {
this.key = builder.key;
@@ -47,6 +49,7 @@ public class TestIssue implements Issue {
this.severity = builder.severity;
this.ruleKey = builder.ruleKey;
this.debt = builder.debt;
+ this.type = builder.type;
}
@Override
@@ -81,6 +84,15 @@ public class TestIssue implements Issue {
return debt;
}
+ public Duration effort() {
+ return debt;
+ }
+
+ @Override
+ public RuleType type() {
+ return type;
+ }
+
public static class Builder {
private String key;
private String status;
@@ -88,6 +100,7 @@ public class TestIssue implements Issue {
private String severity;
private RuleKey ruleKey;
private Duration debt;
+ private RuleType type;
public Builder setKey(String key) {
this.key = validateKey(key);
@@ -119,6 +132,11 @@ public class TestIssue implements Issue {
return this;
}
+ public Builder setType(RuleType type) {
+ this.type = validateType(type);
+ return this;
+ }
+
private static String validateKey(String key){
checkNotNull(key, "key cannot be null");
return key;
@@ -146,12 +164,18 @@ public class TestIssue implements Issue {
return status;
}
+ private static RuleType validateType(RuleType type){
+ checkNotNull(type, "type cannot be null");
+ return type;
+ }
+
public Issue build(){
validateKey(key);
validateResolution(resolution);
validateSeverity(severity);
validateStatus(status);
validateRuleKey(ruleKey);
+ validateType(type);
return new TestIssue(this);
}
}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoreMetrics.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoreMetrics.java
index c1ad755dcc3..7f4a4d592d7 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoreMetrics.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoreMetrics.java
@@ -2158,11 +2158,13 @@ public final class CoreMetrics {
/**
* @since 4.0
*/
+ // TODO should be renamed to MAINTAINABILITY_REMEDIATION_EFFORT_KEY = "maintainability_remediation_effort"
public static final String TECHNICAL_DEBT_KEY = "sqale_index";
/**
* @since 4.0
*/
+ // TODO should be renamed to MAINTAINABILITY_REMEDIATION_EFFORT
public static final Metric<Long> TECHNICAL_DEBT = new Metric.Builder(TECHNICAL_DEBT_KEY, "Technical Debt", Metric.ValueType.WORK_DUR)
.setDomain(DOMAIN_TECHNICAL_DEBT)
.setDirection(Metric.DIRECTION_WORST)
@@ -2174,11 +2176,13 @@ public final class CoreMetrics {
/**
* @since 4.1
*/
+ // TODO should be renamed to NEW_MAINTAINABILITY_REMEDIATION_EFFORT_KEY = "new_maintainability_remediation_effort"
public static final String NEW_TECHNICAL_DEBT_KEY = "new_technical_debt";
/**
* @since 4.1
*/
+ // TODO should be renamed to NEW_MAINTAINABILITY_REMEDIATION_EFFORT
public static final Metric<Long> NEW_TECHNICAL_DEBT = new Metric.Builder(NEW_TECHNICAL_DEBT_KEY, "Technical Debt on new code", Metric.ValueType.WORK_DUR)
.setDescription("Technical Debt of new code")
.setDomain(DOMAIN_TECHNICAL_DEBT)
@@ -2192,11 +2196,13 @@ public final class CoreMetrics {
/**
* @since 4.5
*/
+ // TODO should be renamed to MAINTAINABILITY_RATING_KEY = "maintainability_rating"
public static final String SQALE_RATING_KEY = "sqale_rating";
/**
* @since 4.5
*/
+ // TODO should be renamed to MAINTAINABILITY_RATING
public static final Metric<Integer> SQALE_RATING = new Metric.Builder(SQALE_RATING_KEY, "SQALE Rating", Metric.ValueType.RATING)
.setDomain(DOMAIN_TECHNICAL_DEBT)
.setDirection(Metric.DIRECTION_WORST)
@@ -2225,11 +2231,13 @@ public final class CoreMetrics {
/**
* @since 4.5
*/
+ // TODO should be renamed to TECHNICALDEBT_RATIO_KEY = "technicaldebt_ratio"
public static final String SQALE_DEBT_RATIO_KEY = "sqale_debt_ratio";
/**
* @since 4.5
*/
+ // TODO should be renamed to TECHNICALDEBT_RATIO
public static final Metric<Double> SQALE_DEBT_RATIO = new Metric.Builder(SQALE_DEBT_RATIO_KEY, "Technical Debt Ratio", Metric.ValueType.PERCENT)
.setDescription("Ratio of the technical debt compared to what it would cost to develop the whole source code from scratch.")
.setDomain(DOMAIN_TECHNICAL_DEBT)
@@ -2242,11 +2250,13 @@ public final class CoreMetrics {
/**
* @since 5.2
*/
+ // TODO should be renamed to TECHNICALDEBT_RATIO_ON_NEW_CODE_KEY = "technicaldebt_ratio_on_new_code"
public static final String NEW_SQALE_DEBT_RATIO_KEY = "new_sqale_debt_ratio";
/**
* @since 5.2
*/
+ // TODO should be renamed to TECHNICALDEBT_RATIO_ON_NEW_CODE
public static final Metric<Double> NEW_SQALE_DEBT_RATIO = new Metric.Builder(NEW_SQALE_DEBT_RATIO_KEY, "Technical Debt Ratio on new code", Metric.ValueType.PERCENT)
.setDescription("Technical Debt Ratio of new/changed code.")
.setDomain(DOMAIN_TECHNICAL_DEBT)