diff options
author | Julien Lancelot <julien.lancelot@sonarsource.com> | 2013-11-06 20:05:30 +0100 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@sonarsource.com> | 2013-11-06 20:05:30 +0100 |
commit | 2611b65afdf4105194856958326c0d7c20919927 (patch) | |
tree | fc1fde219e8aa56fdc0f728f410d3dd205bf8d22 /sonar-plugin-api | |
parent | 721fa4d6b61c0356b4569bdd83b4fcb436984499 (diff) | |
download | sonarqube-2611b65afdf4105194856958326c0d7c20919927.tar.gz sonarqube-2611b65afdf4105194856958326c0d7c20919927.zip |
SONAR-4776 Add decorator to calculate new technical debt
Diffstat (limited to 'sonar-plugin-api')
3 files changed, 29 insertions, 1 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/issue/internal/FieldDiffs.java b/sonar-plugin-api/src/main/java/org/sonar/api/issue/internal/FieldDiffs.java index 2be7b500f59..7cd29d66d6e 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/issue/internal/FieldDiffs.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/issue/internal/FieldDiffs.java @@ -25,6 +25,7 @@ import com.google.common.collect.Maps; import javax.annotation.CheckForNull; import javax.annotation.Nullable; + import java.io.Serializable; import java.util.Date; import java.util.Map; @@ -38,6 +39,7 @@ public class FieldDiffs implements Serializable { public static final Splitter FIELDS_SPLITTER = Splitter.on(',').omitEmptyStrings(); + private String issueKey; private String userLogin; private Date createdAt, updatedAt; private final Map<String, Diff> diffs = Maps.newLinkedHashMap(); @@ -78,6 +80,14 @@ public class FieldDiffs implements Serializable { return this; } + public String issueKey() { + return issueKey; + } + + public FieldDiffs setIssueKey(String issueKey) { + this.issueKey = issueKey; + return this; + } @SuppressWarnings("unchecked") public FieldDiffs setDiff(String field, @Nullable Serializable oldValue, @Nullable Serializable newValue) { 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 5851311aeb4..ba65a553a2f 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 @@ -2055,6 +2055,24 @@ public final class CoreMetrics { .setQualitative(true) .create(); + /** + * @since 4.1 + */ + public static final String NEW_TECHNICAL_DEBT_KEY = "new_technical_debt"; + + /** + * @since 4.1 + */ + public static final Metric NEW_TECHNICAL_DEBT = new Metric.Builder(NEW_TECHNICAL_DEBT_KEY, "Technical Debt on new code", Metric.ValueType.FLOAT) + .setDescription("Technical Debt of new code") + .setDomain(DOMAIN_TECHNICAL_DEBT) + .setDirection(Metric.DIRECTION_WORST) + .setOptimizedBestValue(true) + .setBestValue(0.0) + .setQualitative(true) + .setDeleteHistoricalData(true) + .create(); + // -------------------------------------------------------------------------------------------------------------------- // diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/resources/CoreMetricsTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/resources/CoreMetricsTest.java index 14abb67a8be..ac33cd953dd 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/resources/CoreMetricsTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/resources/CoreMetricsTest.java @@ -31,7 +31,7 @@ public class CoreMetricsTest { @Test public void shouldReadMetricsFromClassReflection() { List<Metric> metrics = CoreMetrics.getMetrics(); - assertThat(metrics).hasSize(149); + assertThat(metrics).hasSize(150); assertThat(metrics).contains(CoreMetrics.NCLOC, CoreMetrics.DIRECTORIES); } } |