aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-core/src
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2014-07-09 18:36:52 +0200
committerJulien Lancelot <julien.lancelot@sonarsource.com>2014-07-09 18:36:52 +0200
commit4d5d1f5be3d1ace0199d39a086165e1086600a26 (patch)
treef44cfe310ddf3cd277fce68fbec36e90fdb255c8 /sonar-core/src
parent6a7de91d1fb7b3197da780079607a2489064d67b (diff)
downloadsonarqube-4d5d1f5be3d1ace0199d39a086165e1086600a26.tar.gz
sonarqube-4d5d1f5be3d1ace0199d39a086165e1086600a26.zip
SONAR-5388 Introduce the SQALE Rating metric in SonarQube Core
Diffstat (limited to 'sonar-core/src')
-rw-r--r--sonar-core/src/main/java/org/sonar/core/config/CorePropertyDefinitions.java14
-rw-r--r--sonar-core/src/main/java/org/sonar/core/config/DebtProperties.java104
-rw-r--r--sonar-core/src/main/resources/org/sonar/l10n/core.properties4
3 files changed, 110 insertions, 12 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/config/CorePropertyDefinitions.java b/sonar-core/src/main/java/org/sonar/core/config/CorePropertyDefinitions.java
index 82bb38e79b6..d98fddab931 100644
--- a/sonar-core/src/main/java/org/sonar/core/config/CorePropertyDefinitions.java
+++ b/sonar-core/src/main/java/org/sonar/core/config/CorePropertyDefinitions.java
@@ -22,7 +22,6 @@ package org.sonar.core.config;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import org.sonar.api.CoreProperties;
-import org.sonar.api.PropertyType;
import org.sonar.api.config.PropertyDefinition;
import org.sonar.api.resources.Qualifiers;
@@ -39,18 +38,9 @@ public class CorePropertyDefinitions {
defs.addAll(IssueExclusionProperties.all());
defs.addAll(ExclusionProperties.all());
defs.addAll(SecurityProperties.all());
+ defs.addAll(DebtProperties.all());
defs.addAll(ImmutableList.of(
-
- // DEBT
- PropertyDefinition.builder(CoreProperties.HOURS_IN_DAY)
- .name("Number of working hours in a day")
- .type(PropertyType.INTEGER)
- .defaultValue("8")
- .category(CoreProperties.CATEGORY_TECHNICAL_DEBT)
- .deprecatedKey("sqale.hoursInDay")
- .build(),
-
// BATCH
PropertyDefinition.builder(CoreProperties.CORE_VIOLATION_LOCALE_PROPERTY)
@@ -111,7 +101,7 @@ public class CorePropertyDefinitions {
.category(CoreProperties.CATEGORY_GENERAL)
.subCategory(CoreProperties.SUBCATEGORY_DIFFERENTIAL_VIEWS)
.build()
- ));
+ ));
return defs;
}
}
diff --git a/sonar-core/src/main/java/org/sonar/core/config/DebtProperties.java b/sonar-core/src/main/java/org/sonar/core/config/DebtProperties.java
new file mode 100644
index 00000000000..8979927ddc7
--- /dev/null
+++ b/sonar-core/src/main/java/org/sonar/core/config/DebtProperties.java
@@ -0,0 +1,104 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.sonar.core.config;
+
+import com.google.common.collect.ImmutableList;
+import org.sonar.api.CoreProperties;
+import org.sonar.api.PropertyType;
+import org.sonar.api.config.PropertyDefinition;
+import org.sonar.api.config.PropertyFieldDefinition;
+import org.sonar.api.measures.CoreMetrics;
+
+import java.util.List;
+
+class DebtProperties {
+
+ private DebtProperties() {
+ // only static stuff
+ }
+
+ static List<PropertyDefinition> all() {
+ return ImmutableList.of(
+ PropertyDefinition.builder(CoreProperties.HOURS_IN_DAY)
+ .name("Number of working hours in a day")
+ .type(PropertyType.INTEGER)
+ .defaultValue("8")
+ .category(CoreProperties.CATEGORY_TECHNICAL_DEBT)
+ .deprecatedKey("sqale.hoursInDay")
+ .build(),
+
+ PropertyDefinition.builder(CoreProperties.SIZE_METRIC)
+ .defaultValue("" + CoreMetrics.NCLOC_KEY)
+ .name("Size metric")
+ .description("Metric used to estimate artifact's development cost.")
+ .type(PropertyType.METRIC)
+ .options("key:^(ncloc|complexity)$")
+ .category(CoreProperties.CATEGORY_TECHNICAL_DEBT)
+ .deprecatedKey("sizeMetric")
+ .build(),
+
+ PropertyDefinition.builder(CoreProperties.MAN_DAYS_BY_SIZE_POINT)
+ .defaultValue("" + CoreProperties.MAN_DAYS_BY_SIZE_POINT_DEF_VALUE)
+ .name("Development cost")
+ .description("Cost to develop one unit of code. If the unit is a line of code (LOC), and the cost to develop 1 LOC has been estimated at 30 minutes, " +
+ "then the value of this property would be 30.")
+ .category(CoreProperties.CATEGORY_TECHNICAL_DEBT)
+ .deprecatedKey("workUnitsBySizePoint")
+ .build(),
+
+ PropertyDefinition.builder(CoreProperties.RATING_GRID)
+ .defaultValue("" + CoreProperties.RATING_GRID_DEF_VALUES)
+ .name("Rating grid")
+ .description("SQALE ratings range from A (very good) to E (very bad). They compare the technical debt on a project to the time that has already gone into writing it. " +
+ "The default values for A through D are 0.1,0.2,0.5,1. Anything over 1 is an E. " +
+ "Assuming the size metric is lines of code (LOC), and the work unit is 30 (minutes to produce 1 LOC), " +
+ "a project with a technical debt of 24,000 minutes for 2,500 LOC will have a ratio of 24000/(30 * 2,500) = 0.32. That yields a SQALE rating of C.")
+ .category(CoreProperties.CATEGORY_TECHNICAL_DEBT)
+ .deprecatedKey("ratingGrid")
+ .build(),
+
+ PropertyDefinition.builder(CoreProperties.LANGUAGE_SPECIFIC_PARAMETERS)
+ .name("Language specific parameters")
+ .description("The parameters specified here for a given language will override the general parameters defined in this section.")
+ .category(CoreProperties.CATEGORY_TECHNICAL_DEBT)
+ .deprecatedKey("languageSpecificParameters")
+ .fields(
+ PropertyFieldDefinition.build(CoreProperties.LANGUAGE_SPECIFIC_PARAMETERS_LANGUAGE_KEY)
+ .name("Language Key")
+ .description("Ex: java, cs, cpp...")
+ .type(PropertyType.STRING)
+ .build(),
+ PropertyFieldDefinition.build(CoreProperties.LANGUAGE_SPECIFIC_PARAMETERS_MAN_DAYS_KEY)
+ .name("Development cost")
+ .description("If left blank, the generic value defined in this section will be used.")
+ .type(PropertyType.FLOAT)
+ .build(),
+ PropertyFieldDefinition.build(CoreProperties.LANGUAGE_SPECIFIC_PARAMETERS_SIZE_METRIC_KEY)
+ .name("Size metric")
+ .description("If left blank, the generic value defined in this section will be used.")
+ .type(PropertyType.METRIC)
+ .options("key:^(ncloc|complexity)$")
+ .build()
+ )
+ .build()
+ );
+ }
+}
diff --git a/sonar-core/src/main/resources/org/sonar/l10n/core.properties b/sonar-core/src/main/resources/org/sonar/l10n/core.properties
index 19d79438e44..ec0bbba4ae5 100644
--- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties
+++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties
@@ -2510,9 +2510,13 @@ metric.confirmed_issues.description=Confirmed issues
metric.sqale_index.name=Technical Debt
metric.sqale_index.description=Total effort (in days) to fix all the issues on the component and therefore to comply to all the requirements.
+
metric.new_technical_debt.name=Technical Debt on new code
metric.new_technical_debt.description=Technical Debt on new code
+metric.sqale_rating.name=SQALE Rating
+metric.sqale_rating.description=Density of technical debt computed by dividing the technical debt by the estimated effort to develop from scratch an application.
+
#------------------------------------------------------------------------------
#