summaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api/src
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@gmail.com>2013-09-27 14:06:47 +0200
committerJulien Lancelot <julien.lancelot@gmail.com>2013-09-27 14:06:58 +0200
commit42cab973f76e48d80b2d5fb621aaa983ad940254 (patch)
treef5ecab7303736d8a28adaa8ad1e61fc6eda81c6f /sonar-plugin-api/src
parent7bf08fcfdac86a4ada7ad739be733f437d0b95fb (diff)
downloadsonarqube-42cab973f76e48d80b2d5fb621aaa983ad940254.tar.gz
sonarqube-42cab973f76e48d80b2d5fb621aaa983ad940254.zip
SONAR-4715 Compute the new "Technical Debt" metric
Diffstat (limited to 'sonar-plugin-api/src')
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java6
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/measures/CoreMetrics.java29
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/resources/CoreMetricsTest.java2
3 files changed, 36 insertions, 1 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java b/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java
index cc2cfaebf7b..b410c6bc295 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java
@@ -121,6 +121,12 @@ public interface CoreProperties {
*/
String CATEGORY_LICENSES = "licenses";
+ /**
+ * @since 4.0
+ */
+ String CATEGORY_TECHNICAL_DEBT = "technicalDebt";
+
+
/* Global settings */
String SONAR_HOME = "SONAR_HOME";
String PROJECT_BRANCH_PROPERTY = "sonar.branch";
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 8cba132e0dd..5616e6a5690 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
@@ -55,6 +55,11 @@ public final class CoreMetrics {
public static String DOMAIN_DUPLICATION = "Duplication";
public static String DOMAIN_DESIGN = "Design";
+ /**
+ * @since 4.0
+ */
+ public static String DOMAIN_TECHNICAL_DEBT = "Technical Debt";
+
public static final String LINES_KEY = "lines";
public static final Metric LINES = new Metric.Builder(LINES_KEY, "Lines", Metric.ValueType.INT)
.setDescription("Lines")
@@ -2009,6 +2014,30 @@ public final class CoreMetrics {
.setHidden(true)
.create();
+
+ // --------------------------------------------------------------------------------------------------------------------
+ //
+ // TECHNICAL DEBT
+ //
+ // --------------------------------------------------------------------------------------------------------------------
+
+ /**
+ * @since 4.0
+ */
+ public static final String TECHNICAL_DEBT_KEY = "technical_debt";
+
+ /**
+ * @since 4.0
+ */
+ public static final Metric TECHNICAL_DEBT = new Metric.Builder(TECHNICAL_DEBT_KEY, "Technical Debt", Metric.ValueType.FLOAT)
+ .setDomain(DOMAIN_TECHNICAL_DEBT)
+ .setDirection(Metric.DIRECTION_WORST)
+ .setOptimizedBestValue(true)
+ .setBestValue(0.0)
+ .setQualitative(true)
+ .create();
+
+
// --------------------------------------------------------------------------------------------------------------------
//
// FILE DATA
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 4f6e1a9e618..14abb67a8be 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(148);
+ assertThat(metrics).hasSize(149);
assertThat(metrics).contains(CoreMetrics.NCLOC, CoreMetrics.DIRECTORIES);
}
}