aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2014-07-03 17:29:23 +0200
committerJulien Lancelot <julien.lancelot@sonarsource.com>2014-07-03 17:51:11 +0200
commit5b9dfc041ae3355dc68dcc4cb0a97b76d33dc106 (patch)
tree99472a4ac8eac0b272c0941a9765c1ba977fd8e6
parent10244be8668b4adba0dbdfcb9488a235eedabb6e (diff)
downloadsonarqube-5b9dfc041ae3355dc68dcc4cb0a97b76d33dc106.tar.gz
sonarqube-5b9dfc041ae3355dc68dcc4cb0a97b76d33dc106.zip
SONAR-5432 Remove RCI and Weighted issues metrics
-rw-r--r--plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java94
-rw-r--r--plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/dashboards/ProjectTimeMachineDashboard.java1
-rw-r--r--plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/IssuesDensityDecorator.java94
-rw-r--r--plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/WeightedIssuesDecorator.java124
-rw-r--r--plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/issue/IssuesDensityDecoratorTest.java107
-rw-r--r--plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/issue/WeightedIssuesDecoratorTest.java95
-rw-r--r--sonar-core/src/main/resources/org/sonar/l10n/core.properties7
-rw-r--r--sonar-deprecated/src/main/java/org/sonar/api/rules/RuleUtils.java57
-rw-r--r--sonar-deprecated/src/test/java/org/sonar/api/rules/RuleUtilsTest.java64
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java3
-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/measures/MeasuresFiltersTest.java4
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/resources/CoreMetricsTest.java2
-rw-r--r--sonar-server/src/main/java/org/sonar/server/measure/ws/TimeMachineWs.java2
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/models/metric.rb8
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/models/sonar/components_configuration.rb2
16 files changed, 16 insertions, 677 deletions
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java
index 44e3b343aa0..114597c0ae4 100644
--- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java
+++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java
@@ -20,11 +20,7 @@
package org.sonar.plugins.core;
import com.google.common.collect.ImmutableList;
-import org.sonar.api.CoreProperties;
-import org.sonar.api.Properties;
-import org.sonar.api.Property;
-import org.sonar.api.PropertyType;
-import org.sonar.api.SonarPlugin;
+import org.sonar.api.*;
import org.sonar.api.checks.NoSonarFilter;
import org.sonar.core.timemachine.Periods;
import org.sonar.plugins.core.batch.IndexProjectPostJob;
@@ -32,88 +28,18 @@ import org.sonar.plugins.core.charts.DistributionAreaChart;
import org.sonar.plugins.core.charts.DistributionBarChart;
import org.sonar.plugins.core.charts.XradarChart;
import org.sonar.plugins.core.colorizers.JavaColorizerFormat;
-import org.sonar.plugins.core.dashboards.GlobalDefaultDashboard;
-import org.sonar.plugins.core.dashboards.ProjectDefaultDashboard;
-import org.sonar.plugins.core.dashboards.ProjectHotspotDashboard;
-import org.sonar.plugins.core.dashboards.ProjectIssuesDashboard;
-import org.sonar.plugins.core.dashboards.ProjectTimeMachineDashboard;
-import org.sonar.plugins.core.issue.CountFalsePositivesDecorator;
-import org.sonar.plugins.core.issue.CountUnresolvedIssuesDecorator;
-import org.sonar.plugins.core.issue.InitialOpenIssuesSensor;
-import org.sonar.plugins.core.issue.InitialOpenIssuesStack;
-import org.sonar.plugins.core.issue.IssueHandlers;
-import org.sonar.plugins.core.issue.IssueTracking;
-import org.sonar.plugins.core.issue.IssueTrackingDecorator;
-import org.sonar.plugins.core.issue.IssuesDensityDecorator;
-import org.sonar.plugins.core.issue.WeightedIssuesDecorator;
-import org.sonar.plugins.core.issue.notification.ChangesOnMyIssueNotificationDispatcher;
-import org.sonar.plugins.core.issue.notification.IssueChangesEmailTemplate;
-import org.sonar.plugins.core.issue.notification.NewFalsePositiveNotificationDispatcher;
-import org.sonar.plugins.core.issue.notification.NewIssuesEmailTemplate;
-import org.sonar.plugins.core.issue.notification.NewIssuesNotificationDispatcher;
-import org.sonar.plugins.core.issue.notification.SendIssueNotificationsPostJob;
+import org.sonar.plugins.core.dashboards.*;
+import org.sonar.plugins.core.issue.*;
+import org.sonar.plugins.core.issue.notification.*;
import org.sonar.plugins.core.measurefilters.MyFavouritesFilter;
import org.sonar.plugins.core.measurefilters.ProjectFilter;
import org.sonar.plugins.core.notifications.alerts.NewAlerts;
import org.sonar.plugins.core.security.ApplyProjectRolesDecorator;
-import org.sonar.plugins.core.sensors.BranchCoverageDecorator;
-import org.sonar.plugins.core.sensors.CommentDensityDecorator;
-import org.sonar.plugins.core.sensors.CoverageDecorator;
-import org.sonar.plugins.core.sensors.CoverageMeasurementFilter;
-import org.sonar.plugins.core.sensors.DirectoriesDecorator;
-import org.sonar.plugins.core.sensors.FileHashSensor;
-import org.sonar.plugins.core.sensors.FilesDecorator;
-import org.sonar.plugins.core.sensors.ItBranchCoverageDecorator;
-import org.sonar.plugins.core.sensors.ItCoverageDecorator;
-import org.sonar.plugins.core.sensors.ItLineCoverageDecorator;
-import org.sonar.plugins.core.sensors.LineCoverageDecorator;
-import org.sonar.plugins.core.sensors.ManualMeasureDecorator;
-import org.sonar.plugins.core.sensors.OverallBranchCoverageDecorator;
-import org.sonar.plugins.core.sensors.OverallCoverageDecorator;
-import org.sonar.plugins.core.sensors.OverallLineCoverageDecorator;
-import org.sonar.plugins.core.sensors.ProjectLinksSensor;
-import org.sonar.plugins.core.sensors.UnitTestDecorator;
-import org.sonar.plugins.core.sensors.VersionEventsSensor;
-import org.sonar.plugins.core.timemachine.NewCoverageAggregator;
-import org.sonar.plugins.core.timemachine.NewCoverageFileAnalyzer;
-import org.sonar.plugins.core.timemachine.NewItCoverageFileAnalyzer;
-import org.sonar.plugins.core.timemachine.NewOverallCoverageFileAnalyzer;
-import org.sonar.plugins.core.timemachine.TendencyDecorator;
-import org.sonar.plugins.core.timemachine.TimeMachineConfigurationPersister;
-import org.sonar.plugins.core.timemachine.VariationDecorator;
-import org.sonar.plugins.core.widgets.AlertsWidget;
-import org.sonar.plugins.core.widgets.BubbleChartWidget;
-import org.sonar.plugins.core.widgets.ComplexityWidget;
-import org.sonar.plugins.core.widgets.CoverageWidget;
-import org.sonar.plugins.core.widgets.CustomMeasuresWidget;
-import org.sonar.plugins.core.widgets.DescriptionWidget;
-import org.sonar.plugins.core.widgets.DocumentationCommentsWidget;
-import org.sonar.plugins.core.widgets.DuplicationsWidget;
-import org.sonar.plugins.core.widgets.EventsWidget;
-import org.sonar.plugins.core.widgets.HotspotMetricWidget;
-import org.sonar.plugins.core.widgets.HotspotMostViolatedResourcesWidget;
-import org.sonar.plugins.core.widgets.HotspotMostViolatedRulesWidget;
-import org.sonar.plugins.core.widgets.ItCoverageWidget;
-import org.sonar.plugins.core.widgets.ProjectFileCloudWidget;
-import org.sonar.plugins.core.widgets.SizeWidget;
-import org.sonar.plugins.core.widgets.TechnicalDebtPyramidWidget;
-import org.sonar.plugins.core.widgets.TimeMachineWidget;
-import org.sonar.plugins.core.widgets.TimelineWidget;
-import org.sonar.plugins.core.widgets.TreemapWidget;
-import org.sonar.plugins.core.widgets.WelcomeWidget;
-import org.sonar.plugins.core.widgets.issues.ActionPlansWidget;
-import org.sonar.plugins.core.widgets.issues.FalsePositiveIssuesWidget;
-import org.sonar.plugins.core.widgets.issues.IssueFilterWidget;
-import org.sonar.plugins.core.widgets.issues.IssuesWidget;
-import org.sonar.plugins.core.widgets.issues.MyUnresolvedIssuesWidget;
-import org.sonar.plugins.core.widgets.issues.UnresolvedIssuesPerAssigneeWidget;
-import org.sonar.plugins.core.widgets.issues.UnresolvedIssuesStatusesWidget;
-import org.sonar.plugins.core.widgets.measures.MeasureFilterAsBubbleChartWidget;
-import org.sonar.plugins.core.widgets.measures.MeasureFilterAsCloudWidget;
-import org.sonar.plugins.core.widgets.measures.MeasureFilterAsHistogramWidget;
-import org.sonar.plugins.core.widgets.measures.MeasureFilterAsPieChartWidget;
-import org.sonar.plugins.core.widgets.measures.MeasureFilterListWidget;
-import org.sonar.plugins.core.widgets.measures.MeasureFilterTreemapWidget;
+import org.sonar.plugins.core.sensors.*;
+import org.sonar.plugins.core.timemachine.*;
+import org.sonar.plugins.core.widgets.*;
+import org.sonar.plugins.core.widgets.issues.*;
+import org.sonar.plugins.core.widgets.measures.*;
import java.util.List;
@@ -322,8 +248,6 @@ public final class CorePlugin extends SonarPlugin {
IssueHandlers.class,
CountUnresolvedIssuesDecorator.class,
CountFalsePositivesDecorator.class,
- WeightedIssuesDecorator.class,
- IssuesDensityDecorator.class,
InitialOpenIssuesSensor.class,
InitialOpenIssuesStack.class,
HotspotMostViolatedResourcesWidget.class,
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/dashboards/ProjectTimeMachineDashboard.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/dashboards/ProjectTimeMachineDashboard.java
index ae4f75d12e1..cf7b3ab6a5a 100644
--- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/dashboards/ProjectTimeMachineDashboard.java
+++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/dashboards/ProjectTimeMachineDashboard.java
@@ -91,7 +91,6 @@ public final class ProjectTimeMachineDashboard extends DashboardTemplate {
rulesTimeMachineWidget.setProperty(METRIC4, CoreMetrics.MAJOR_VIOLATIONS_KEY);
rulesTimeMachineWidget.setProperty(METRIC5, CoreMetrics.MINOR_VIOLATIONS_KEY);
rulesTimeMachineWidget.setProperty(METRIC6, CoreMetrics.INFO_VIOLATIONS_KEY);
- rulesTimeMachineWidget.setProperty(METRIC7, CoreMetrics.WEIGHTED_VIOLATIONS_KEY);
Widget complexityTimeMachineWidget = addTimeMachineWidgetOnSecondColumn(dashboard);
complexityTimeMachineWidget.setProperty(METRIC1, CoreMetrics.COMPLEXITY_KEY);
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/IssuesDensityDecorator.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/IssuesDensityDecorator.java
deleted file mode 100644
index a804bbd9a42..00000000000
--- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/IssuesDensityDecorator.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * 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.plugins.core.issue;
-
-import org.sonar.api.batch.Decorator;
-import org.sonar.api.batch.DecoratorBarriers;
-import org.sonar.api.batch.DecoratorContext;
-import org.sonar.api.batch.DependedUpon;
-import org.sonar.api.batch.DependsUpon;
-import org.sonar.api.measures.CoreMetrics;
-import org.sonar.api.measures.Measure;
-import org.sonar.api.measures.MeasureUtils;
-import org.sonar.api.measures.Metric;
-import org.sonar.api.resources.Project;
-import org.sonar.api.resources.Resource;
-
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * @since 3.6
- */
-@DependsUpon(DecoratorBarriers.END_OF_VIOLATION_TRACKING)
-public class IssuesDensityDecorator implements Decorator {
-
- public boolean shouldExecuteOnProject(Project project) {
- return true;
- }
-
- @DependsUpon
- public List<Metric> dependsUponWeightedIissuesAndNcloc() {
- return Arrays.<Metric>asList(CoreMetrics.WEIGHTED_VIOLATIONS, CoreMetrics.NCLOC);
- }
-
- @DependedUpon
- public Metric generatesIssuesDensity() {
- return CoreMetrics.VIOLATIONS_DENSITY;
- }
-
- public void decorate(Resource resource, DecoratorContext context) {
- if (shouldDecorateResource(context)) {
- decorateDensity(context);
- }
- }
-
- protected boolean shouldDecorateResource(DecoratorContext context) {
- return context.getMeasure(CoreMetrics.VIOLATIONS_DENSITY) == null;
- }
-
- private void decorateDensity(DecoratorContext context) {
- Measure ncloc = context.getMeasure(CoreMetrics.NCLOC);
- if (MeasureUtils.hasValue(ncloc) && ncloc.getValue() > 0.0) {
- saveDensity(context, ncloc.getValue().intValue());
- }
- }
-
- private void saveDensity(DecoratorContext context, int ncloc) {
- Measure debt = context.getMeasure(CoreMetrics.WEIGHTED_VIOLATIONS);
- Integer debtValue = 0;
- if (MeasureUtils.hasValue(debt)) {
- debtValue = debt.getValue().intValue();
- }
- double density = calculate(debtValue, ncloc);
- context.saveMeasure(CoreMetrics.VIOLATIONS_DENSITY, density);
- }
-
- protected static double calculate(int debt, int ncloc) {
- double rci = (1.0 - ((double) debt / (double) ncloc)) * 100.0;
- rci = Math.max(rci, 0.0);
- return rci;
- }
-
- @Override
- public String toString() {
- return getClass().getSimpleName();
- }
-}
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/WeightedIssuesDecorator.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/WeightedIssuesDecorator.java
deleted file mode 100644
index a7af9d3ff29..00000000000
--- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/WeightedIssuesDecorator.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * 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.plugins.core.issue;
-
-import com.google.common.base.Strings;
-import com.google.common.collect.Multiset;
-import com.google.common.collect.TreeMultiset;
-import org.sonar.api.CoreProperties;
-import org.sonar.api.Properties;
-import org.sonar.api.Property;
-import org.sonar.api.batch.Decorator;
-import org.sonar.api.batch.DecoratorContext;
-import org.sonar.api.batch.DependedUpon;
-import org.sonar.api.batch.DependsUpon;
-import org.sonar.api.config.Settings;
-import org.sonar.api.measures.CoreMetrics;
-import org.sonar.api.measures.Measure;
-import org.sonar.api.measures.MeasureUtils;
-import org.sonar.api.measures.Metric;
-import org.sonar.api.resources.Project;
-import org.sonar.api.resources.Resource;
-import org.sonar.api.rules.RulePriority;
-import org.sonar.api.utils.KeyValueFormat;
-
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-
-@Properties(@Property(
- key = CoreProperties.CORE_RULE_WEIGHTS_PROPERTY,
- defaultValue = CoreProperties.CORE_RULE_WEIGHTS_DEFAULT_VALUE,
- name = "Rules weight",
- description = "A weight is associated to each severity to emphasize the most critical issues.",
- project = false,
- global = true,
- category = CoreProperties.CATEGORY_GENERAL))
-public class WeightedIssuesDecorator implements Decorator {
-
- private Settings settings;
- private Map<RulePriority, Integer> weightsBySeverity;
-
- public WeightedIssuesDecorator(Settings settings) {
- this.settings = settings;
- }
-
- @DependsUpon
- public List<Metric> dependsUponIssues() {
- return Arrays.<Metric>asList(CoreMetrics.BLOCKER_VIOLATIONS, CoreMetrics.CRITICAL_VIOLATIONS,
- CoreMetrics.MAJOR_VIOLATIONS, CoreMetrics.MINOR_VIOLATIONS, CoreMetrics.INFO_VIOLATIONS);
- }
-
- @DependedUpon
- public Metric generatesWeightedIssues() {
- return CoreMetrics.WEIGHTED_VIOLATIONS;
- }
-
- @Override
- public boolean shouldExecuteOnProject(Project project) {
- return true;
- }
-
- public void start() {
- weightsBySeverity = getWeights(settings);
- }
-
- Map<RulePriority, Integer> getWeightsBySeverity() {
- return weightsBySeverity;
- }
-
- static Map<RulePriority, Integer> getWeights(final Settings settings) {
- String value = settings.getString(CoreProperties.CORE_RULE_WEIGHTS_PROPERTY);
-
- Map<RulePriority, Integer> weights = KeyValueFormat.parse(value, KeyValueFormat.newPriorityConverter(), KeyValueFormat.newIntegerConverter());
-
- for (RulePriority priority : RulePriority.values()) {
- if (!weights.containsKey(priority)) {
- weights.put(priority, 1);
- }
- }
- return weights;
- }
-
- @Override
- public void decorate(Resource resource, DecoratorContext context) {
- decorate(context);
- }
-
- void decorate(DecoratorContext context) {
- double debt = 0.0;
- Multiset<RulePriority> distribution = TreeMultiset.create();
-
- for (RulePriority severity : RulePriority.values()) {
- Measure measure = context.getMeasure(SeverityUtils.severityToIssueMetric(severity));
- if (measure != null && MeasureUtils.hasValue(measure)) {
- distribution.add(severity, measure.getIntValue());
- double add = weightsBySeverity.get(severity) * measure.getIntValue();
- debt += add;
- }
- }
-
- String distributionFormatted = KeyValueFormat.format(distribution);
- // SONAR-4987 We should store store an empty string for the distribution value
- Measure debtMeasure = new Measure(CoreMetrics.WEIGHTED_VIOLATIONS, debt, Strings.emptyToNull(distributionFormatted));
- context.saveMeasure(debtMeasure);
- }
-
-}
diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/issue/IssuesDensityDecoratorTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/issue/IssuesDensityDecoratorTest.java
deleted file mode 100644
index 9d97903f22c..00000000000
--- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/issue/IssuesDensityDecoratorTest.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * 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.plugins.core.issue;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Matchers;
-import org.sonar.api.batch.DecoratorContext;
-import org.sonar.api.measures.CoreMetrics;
-import org.sonar.api.measures.Measure;
-import org.sonar.api.resources.Resource;
-import org.sonar.api.resources.Scopes;
-
-import static org.fest.assertions.Assertions.assertThat;
-import static org.mockito.Mockito.*;
-
-public class IssuesDensityDecoratorTest {
-
- private IssuesDensityDecorator decorator;
- private Resource resource;
-
- @Before
- public void before() {
- resource = mock(Resource.class);
- when(resource.getScope()).thenReturn(Scopes.PROJECT);
- decorator = new IssuesDensityDecorator();
- }
-
- @Test
- public void calculate_density() {
- assertThat(IssuesDensityDecorator.calculate(4000, 200)).isEqualTo(0.0);
- assertThat(IssuesDensityDecorator.calculate(200, 200)).isEqualTo(0.0);
- assertThat(IssuesDensityDecorator.calculate(50, 200)).isEqualTo(75.0);
- assertThat(IssuesDensityDecorator.calculate(0, 200)).isEqualTo(100.0);
- }
-
- @Test
- public void decorate_density() {
- DecoratorContext context = mock(DecoratorContext.class);
- when(context.getMeasure(CoreMetrics.NCLOC)).thenReturn(new Measure(CoreMetrics.NCLOC, 200.0));
- when(context.getMeasure(CoreMetrics.WEIGHTED_VIOLATIONS)).thenReturn(new Measure(CoreMetrics.WEIGHTED_VIOLATIONS, 50.0));
-
- decorator.decorate(resource, context);
-
- verify(context).saveMeasure(CoreMetrics.VIOLATIONS_DENSITY, 75.0);
- }
-
- @Test
- public void no_density_if_no_ncloc() {
- DecoratorContext context = mock(DecoratorContext.class);
- when(context.getMeasure(CoreMetrics.NCLOC)).thenReturn(new Measure(CoreMetrics.NCLOC, 0.0));
- when(context.getMeasure(CoreMetrics.WEIGHTED_VIOLATIONS)).thenReturn(new Measure(CoreMetrics.WEIGHTED_VIOLATIONS, 50.0));
-
- decorator.decorate(resource, context);
-
- verify(context, never()).saveMeasure(Matchers.eq(CoreMetrics.VIOLATIONS_DENSITY), Matchers.anyDouble());
- }
-
- @Test
- public void save_density_if_value_is_zero() {
- DecoratorContext context = mock(DecoratorContext.class);
- when(context.getMeasure(CoreMetrics.NCLOC)).thenReturn(new Measure(CoreMetrics.NCLOC, 200.0));
- when(context.getMeasure(CoreMetrics.WEIGHTED_VIOLATIONS)).thenReturn(new Measure(CoreMetrics.WEIGHTED_VIOLATIONS, 5000.0));
-
- decorator.decorate(resource, context);
-
- verify(context).saveMeasure(CoreMetrics.VIOLATIONS_DENSITY, 0.0);
- }
-
- @Test
- public void density_is_hundred_when_no_debt() {
- DecoratorContext context = mock(DecoratorContext.class);
- when(context.getMeasure(CoreMetrics.NCLOC)).thenReturn(new Measure(CoreMetrics.NCLOC, 200.0));
-
- decorator.decorate(resource, context);
-
- verify(context).saveMeasure(CoreMetrics.VIOLATIONS_DENSITY, 100.0);
- }
-
- @Test
- public void density_is_hundred_when_debt_is_zero() {
- DecoratorContext context = mock(DecoratorContext.class);
- when(context.getMeasure(CoreMetrics.NCLOC)).thenReturn(new Measure(CoreMetrics.NCLOC, 200.0));
- when(context.getMeasure(CoreMetrics.WEIGHTED_VIOLATIONS)).thenReturn(new Measure(CoreMetrics.WEIGHTED_VIOLATIONS, 0.0));
-
- decorator.decorate(resource, context);
-
- verify(context).saveMeasure(CoreMetrics.VIOLATIONS_DENSITY, 100.0);
- }
-}
diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/issue/WeightedIssuesDecoratorTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/issue/WeightedIssuesDecoratorTest.java
deleted file mode 100644
index 81a19376779..00000000000
--- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/issue/WeightedIssuesDecoratorTest.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * 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.plugins.core.issue;
-
-import org.junit.Test;
-import org.sonar.api.CoreProperties;
-import org.sonar.api.batch.DecoratorContext;
-import org.sonar.api.config.Settings;
-import org.sonar.api.measures.CoreMetrics;
-import org.sonar.api.measures.Measure;
-import org.sonar.api.rules.RulePriority;
-import org.sonar.api.test.IsMeasure;
-
-import static org.fest.assertions.Assertions.assertThat;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.argThat;
-import static org.mockito.Mockito.*;
-
-
-public class WeightedIssuesDecoratorTest {
-
- @Test
- public void test_weighted_VIOLATIONS() {
- Settings settings = new Settings();
- settings.setProperty(CoreProperties.CORE_RULE_WEIGHTS_PROPERTY, "BLOCKER=10;CRITICAL=5;MAJOR=2;MINOR=1;INFO=0");
- WeightedIssuesDecorator decorator = new WeightedIssuesDecorator(settings);
- DecoratorContext context = mock(DecoratorContext.class);
- when(context.getMeasure(CoreMetrics.INFO_VIOLATIONS)).thenReturn(new Measure(CoreMetrics.INFO_VIOLATIONS, 50.0));
- when(context.getMeasure(CoreMetrics.CRITICAL_VIOLATIONS)).thenReturn(new Measure(CoreMetrics.CRITICAL_VIOLATIONS, 80.0));
- when(context.getMeasure(CoreMetrics.BLOCKER_VIOLATIONS)).thenReturn(new Measure(CoreMetrics.BLOCKER_VIOLATIONS, 100.0));
-
- decorator.start();
- decorator.decorate(context);
-
- verify(context).saveMeasure(argThat(new IsMeasure(CoreMetrics.WEIGHTED_VIOLATIONS, (double) (100 * 10 + 80 * 5 + 50 * 0))));
- verify(context).saveMeasure(argThat(new IsMeasure(CoreMetrics.WEIGHTED_VIOLATIONS, "INFO=50;CRITICAL=80;BLOCKER=100")));
- }
-
- // SONAR-3092
- @Test
- public void do_save_zero() {
- Settings settings = new Settings();
- settings.setProperty(CoreProperties.CORE_RULE_WEIGHTS_PROPERTY, "BLOCKER=10;CRITICAL=5;MAJOR=2;MINOR=1;INFO=0");
- DecoratorContext context = mock(DecoratorContext.class);
-
- WeightedIssuesDecorator decorator = new WeightedIssuesDecorator(settings);
- decorator.start();
- decorator.decorate(context);
-
- verify(context).saveMeasure(any(Measure.class));
- // SONAR-4987
- verify(context, never()).saveMeasure(argThat(new IsMeasure(CoreMetrics.WEIGHTED_VIOLATIONS, "")));
- }
-
- @Test
- public void should_load_severity_weights_at_startup() {
- Settings settings = new Settings();
- settings.setProperty(CoreProperties.CORE_RULE_WEIGHTS_PROPERTY, "BLOCKER=2;CRITICAL=1;MAJOR=0;MINOR=0;INFO=0");
-
- WeightedIssuesDecorator decorator = new WeightedIssuesDecorator(settings);
- decorator.start();
-
- assertThat(decorator.getWeightsBySeverity().get(RulePriority.BLOCKER)).isEqualTo(2);
- assertThat(decorator.getWeightsBySeverity().get(RulePriority.CRITICAL)).isEqualTo(1);
- assertThat(decorator.getWeightsBySeverity().get(RulePriority.MAJOR)).isEqualTo(0);
- }
-
- @Test
- public void weights_setting_should_be_optional() {
- Settings settings = new Settings();
- settings.setProperty(CoreProperties.CORE_RULE_WEIGHTS_PROPERTY, "BLOCKER=2");
-
- WeightedIssuesDecorator decorator = new WeightedIssuesDecorator(settings);
- decorator.start();
-
- assertThat(decorator.getWeightsBySeverity().get(RulePriority.MAJOR)).isEqualTo(1);
- }
-}
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 8c2868f8c2b..367e8181bfc 100644
--- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties
+++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties
@@ -2339,13 +2339,6 @@ metric.portability.description=Portability
metric.maintainability.name=Maintainability
metric.maintainability.description=Maintainability
-metric.weighted_violations.name=Weighted issues
-metric.weighted_violations.description=Weighted issues
-
-metric.violations_density.name=Rules compliance
-metric.violations_density.description=Rules compliance
-metric.violations_density.abbreviation=RCI
-
metric.violations.name=Issues
metric.violations.description=Issues
diff --git a/sonar-deprecated/src/main/java/org/sonar/api/rules/RuleUtils.java b/sonar-deprecated/src/main/java/org/sonar/api/rules/RuleUtils.java
deleted file mode 100644
index ba3f02bacc8..00000000000
--- a/sonar-deprecated/src/main/java/org/sonar/api/rules/RuleUtils.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * 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.api.rules;
-
-import java.util.Map;
-
-import org.apache.commons.configuration.Configuration;
-import org.sonar.api.CoreProperties;
-import org.sonar.api.utils.KeyValueFormat;
-
-/**
- * A utility class to manipulate concepts around rules
- * @deprecated in 3.7. Commons Configuration must be replaced by {@link org.sonar.api.config.Settings}
- */
-@Deprecated
-public final class RuleUtils {
-
- private RuleUtils() {
- }
-
- /**
- * Gets a Map<RulePriority, Integer> containing the weights defined in the settings
- * Default value is used when the property is not set (see property key and default value in the class CoreProperties)
- *
- * @param configuration the Sonar configuration
- * @return a map
- */
- public static Map<RulePriority, Integer> getPriorityWeights(final Configuration configuration) {
- String levelWeight = configuration.getString(CoreProperties.CORE_RULE_WEIGHTS_PROPERTY, CoreProperties.CORE_RULE_WEIGHTS_DEFAULT_VALUE);
-
- Map<RulePriority, Integer> weights = KeyValueFormat.parse(levelWeight, new KeyValueFormat.RulePriorityNumbersPairTransformer());
-
- for (RulePriority priority : RulePriority.values()) {
- if (!weights.containsKey(priority)) {
- weights.put(priority, 1);
- }
- }
- return weights;
- }
-}
diff --git a/sonar-deprecated/src/test/java/org/sonar/api/rules/RuleUtilsTest.java b/sonar-deprecated/src/test/java/org/sonar/api/rules/RuleUtilsTest.java
deleted file mode 100644
index 643f673f89c..00000000000
--- a/sonar-deprecated/src/test/java/org/sonar/api/rules/RuleUtilsTest.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * 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.api.rules;
-
-import org.apache.commons.configuration.Configuration;
-import org.junit.Test;
-import org.mockito.Matchers;
-import org.sonar.api.CoreProperties;
-
-import java.util.Map;
-
-import static org.fest.assertions.Assertions.assertThat;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-public class RuleUtilsTest {
-
- @Test
- public void getPriorityWeights() {
- Configuration conf = mock(Configuration.class);
- when(conf.getString(Matchers.eq(CoreProperties.CORE_RULE_WEIGHTS_PROPERTY), anyString())).thenReturn("info=0;minor=1;major=2;critical=5;blocker=10");
-
- final Map<RulePriority, Integer> map = RuleUtils.getPriorityWeights(conf);
-
- assertThat(map.get(RulePriority.BLOCKER)).isEqualTo(10);
- assertThat(map.get(RulePriority.CRITICAL)).isEqualTo(5);
- assertThat(map.get(RulePriority.MAJOR)).isEqualTo(2);
- assertThat(map.get(RulePriority.MINOR)).isEqualTo(1);
- assertThat(map.get(RulePriority.INFO)).isEqualTo(0);
- }
-
- @Test
- public void loadMissingWeights() {
- Configuration conf = mock(Configuration.class);
- when(conf.getString(Matchers.eq(CoreProperties.CORE_RULE_WEIGHTS_PROPERTY), anyString())).thenReturn("foo=0;bar=1;CRITICAL=5");
-
- final Map<RulePriority, Integer> map = RuleUtils.getPriorityWeights(conf);
-
- assertThat(map.get(RulePriority.BLOCKER)).isEqualTo(1);
- assertThat(map.get(RulePriority.CRITICAL)).isEqualTo(5);
- assertThat(map.get(RulePriority.MAJOR)).isEqualTo(1);
- assertThat(map.get(RulePriority.MINOR)).isEqualTo(1);
- assertThat(map.get(RulePriority.INFO)).isEqualTo(1);
- }
-
-}
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 ee0d032f215..81765da230e 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
@@ -211,9 +211,6 @@ public interface CoreProperties {
@Deprecated
String CORE_SKIPPED_MODULES_PROPERTY = "sonar.skippedModules";
- String CORE_RULE_WEIGHTS_PROPERTY = "sonar.core.rule.weight";
- String CORE_RULE_WEIGHTS_DEFAULT_VALUE = "INFO=0;MINOR=1;MAJOR=3;CRITICAL=5;BLOCKER=10";
-
/**
* @since 4.0
* @deprecated since 4.3. See http://jira.codehaus.org/browse/SONAR-5109
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 3585f200629..5051dd5e2e1 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
@@ -1351,35 +1351,6 @@ public final class CoreMetrics {
//
// --------------------------------------------------------------------------------------------------------------------
- public static final String WEIGHTED_VIOLATIONS_KEY = "weighted_violations";
-
- public static final Metric<Integer> WEIGHTED_VIOLATIONS = new Metric.Builder(WEIGHTED_VIOLATIONS_KEY, "Weighted issues", Metric.ValueType.INT)
- .setDescription("Weighted Issues")
- .setDirection(Metric.DIRECTION_WORST)
- .setQualitative(true)
- .setDomain(DOMAIN_ISSUES)
- .setBestValue(0.0)
- .setOptimizedBestValue(true)
- .create();
-
- /**
- * @deprecated since 4.0. See SONAR-4755
- */
- @Deprecated
- public static final String VIOLATIONS_DENSITY_KEY = "violations_density";
-
- /**
- * @deprecated since 4.0. See SONAR-4755
- */
- @Deprecated
- public static final Metric<Double> VIOLATIONS_DENSITY = new Metric.Builder(VIOLATIONS_DENSITY_KEY, "Rules compliance", Metric.ValueType.PERCENT)
- .setDescription("Rules compliance")
- .setDirection(Metric.DIRECTION_BETTER)
- .setQualitative(true)
- .setDomain(DOMAIN_ISSUES)
- .setHidden(true)
- .create();
-
public static final String VIOLATIONS_KEY = "violations";
public static final Metric<Integer> VIOLATIONS = new Metric.Builder(VIOLATIONS_KEY, "Issues", Metric.ValueType.INT)
.setDescription("Issues")
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/measures/MeasuresFiltersTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/measures/MeasuresFiltersTest.java
index ea075ed2a99..f0abf37582b 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/measures/MeasuresFiltersTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/measures/MeasuresFiltersTest.java
@@ -64,7 +64,7 @@ public class MeasuresFiltersTest {
List<Measure> measures = Arrays.asList(
RuleMeasure.createForRule(CoreMetrics.VIOLATIONS, rule1, 50.0),
RuleMeasure.createForRule(CoreMetrics.VIOLATIONS, rule2, 10.0),
- RuleMeasure.createForRule(CoreMetrics.VIOLATIONS_DENSITY, rule2, 3.3),
+ RuleMeasure.createForRule(CoreMetrics.INFO_VIOLATIONS, rule2, 3.3),
RuleMeasure.createForPriority(CoreMetrics.VIOLATIONS, RulePriority.CRITICAL, 400.0),
RuleMeasure.createForPriority(CoreMetrics.COVERAGE, RulePriority.CRITICAL, 400.0),
@@ -81,7 +81,7 @@ public class MeasuresFiltersTest {
List<Measure> measures = Arrays.asList(
RuleMeasure.createForRule(CoreMetrics.VIOLATIONS, rule1, 50.0),
RuleMeasure.createForRule(CoreMetrics.VIOLATIONS, rule2, 10.0),
- RuleMeasure.createForRule(CoreMetrics.VIOLATIONS_DENSITY, rule2, 3.3),
+ RuleMeasure.createForRule(CoreMetrics.INFO_VIOLATIONS, rule2, 3.3),
RuleMeasure.createForPriority(CoreMetrics.VIOLATIONS, RulePriority.CRITICAL, 400.0),
RuleMeasure.createForPriority(CoreMetrics.COVERAGE, RulePriority.CRITICAL, 400.0),
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 086005be0f8..1db080ea3c3 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
@@ -32,7 +32,7 @@ public class CoreMetricsTest {
@Test
public void read_metrics_from_class_reflection() {
List<Metric> metrics = CoreMetrics.getMetrics();
- assertThat(metrics).hasSize(152);
+ assertThat(metrics).hasSize(150);
assertThat(metrics).contains(CoreMetrics.NCLOC, CoreMetrics.DIRECTORIES);
}
diff --git a/sonar-server/src/main/java/org/sonar/server/measure/ws/TimeMachineWs.java b/sonar-server/src/main/java/org/sonar/server/measure/ws/TimeMachineWs.java
index ef6b1e2d7c5..94f8f819a47 100644
--- a/sonar-server/src/main/java/org/sonar/server/measure/ws/TimeMachineWs.java
+++ b/sonar-server/src/main/java/org/sonar/server/measure/ws/TimeMachineWs.java
@@ -52,7 +52,7 @@ public class TimeMachineWs implements WebService {
action.createParam("metrics")
.setDescription("Comma-separated list of <a href=\"http://docs.codehaus.org/display/SONAR/Metric+definitions\">metric keys/ids</a>")
.setRequired(true)
- .setExampleValue("coverage,violations_density");
+ .setExampleValue("coverage,violations");
action.createParam("fromDateTime")
.setDescription("ISO-8601 datetime (inclusive)")
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/metric.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/metric.rb
index 7fa97598b4c..e437a2bd370 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/models/metric.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/models/metric.rb
@@ -240,10 +240,6 @@ class Metric < ActiveRecord::Base
Caches.clear(I18N_SHORT_NAME_CACHE_KEY)
end
- def self.default_time_machine_metrics
- [COMPLEXITY, COVERAGE, VIOLATIONS_DENSITY]
- end
-
def self.by_keys(keys)
result=[]
keys.each do |k|
@@ -355,14 +351,14 @@ class Metric < ActiveRecord::Base
UNCOVERED_CONDITIONS='uncovered_conditions'
VIOLATIONS = 'violations'
- VIOLATIONS_DENSITY = 'violations_density'
- WEIGHTED_VIOLATIONS = 'weighted_violations'
BLOCKER_VIOLATIONS='blocker_violations'
CRITICAL_VIOLATIONS='critical_violations'
MAJOR_VIOLATIONS='major_violations'
MINOR_VIOLATIONS='minor_violations'
INFO_VIOLATIONS='info_violations'
+ TECH_DEBT='sqale_index'
+
MAINTAINABILITY='maintainability'
EFFICIENCY='efficiency'
RELIABILITY='reliability'
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/sonar/components_configuration.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/sonar/components_configuration.rb
index e30aecf3951..ec752384f81 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/models/sonar/components_configuration.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/models/sonar/components_configuration.rb
@@ -173,7 +173,7 @@ class Sonar::ComponentsConfiguration
def default_text_columns
unless @@default_columns
@@default_columns = ""
- @@default_columns << Sonar::ColumnsView::TYPE_METRIC + COLUMN_SEPARATOR + Metric::VIOLATIONS_DENSITY + COLUMNS_SEPARATOR
+ @@default_columns << Sonar::ColumnsView::TYPE_METRIC + COLUMN_SEPARATOR + Metric::TECH_DEBT + COLUMNS_SEPARATOR
@@default_columns << Sonar::ColumnsView::TYPE_METRIC + COLUMN_SEPARATOR + Metric::COVERAGE + COLUMNS_SEPARATOR
@@default_columns << Sonar::ColumnsView::TYPE_BUILD_TIME + COLUMN_SEPARATOR + 'build_time' + COLUMNS_SEPARATOR
@@default_columns << Sonar::ColumnsView::TYPE_LINKS + COLUMN_SEPARATOR + "links"