diff options
author | Julien Lancelot <julien.lancelot@gmail.com> | 2013-09-27 14:06:47 +0200 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@gmail.com> | 2013-09-27 14:06:58 +0200 |
commit | 42cab973f76e48d80b2d5fb621aaa983ad940254 (patch) | |
tree | f5ecab7303736d8a28adaa8ad1e61fc6eda81c6f /sonar-plugin-api/src | |
parent | 7bf08fcfdac86a4ada7ad739be733f437d0b95fb (diff) | |
download | sonarqube-42cab973f76e48d80b2d5fb621aaa983ad940254.tar.gz sonarqube-42cab973f76e48d80b2d5fb621aaa983ad940254.zip |
SONAR-4715 Compute the new "Technical Debt" metric
Diffstat (limited to 'sonar-plugin-api/src')
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); } } |