diff options
author | simonbrandhof <simon.brandhof@gmail.com> | 2011-02-25 00:20:30 +0100 |
---|---|---|
committer | simonbrandhof <simon.brandhof@gmail.com> | 2011-02-25 07:44:16 +0100 |
commit | df06580805552cf4575031818a83d9f0f3520744 (patch) | |
tree | 1fac1699da0745b9cdfb69d20e163d70740630cc /plugins | |
parent | d4beaec49895945d23d509d1502790794b008d56 (diff) | |
download | sonarqube-df06580805552cf4575031818a83d9f0f3520744.tar.gz sonarqube-df06580805552cf4575031818a83d9f0f3520744.zip |
SONAR-2238 Remove the metric "uncovered_complexity_by_tests"
Diffstat (limited to 'plugins')
3 files changed, 0 insertions, 138 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 18113235d1d..4d6063a9d71 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 @@ -224,7 +224,6 @@ public class CorePlugin implements Plugin { extensions.add(LineCoverageDecorator.class); extensions.add(CoverageDecorator.class); extensions.add(BranchCoverageDecorator.class); - extensions.add(UncoveredComplexityDecorator.class); extensions.add(ApplyProjectRolesDecorator.class); extensions.add(ExcludedResourceFilter.class); extensions.add(CommentDensityDecorator.class); diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/UncoveredComplexityDecorator.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/UncoveredComplexityDecorator.java deleted file mode 100644 index 153b4d66a3d..00000000000 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/UncoveredComplexityDecorator.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar 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. - * - * Sonar 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 Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.plugins.core.sensors; - -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.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.utils.KeyValueFormat; - -import java.util.Arrays; -import java.util.List; - -/** - * @deprecated the metric <code>CoreMetrics.UNCOVERED_COMPLEXITY_BY_TESTS</code> is deprecated since v.1.11. - * It's replaced by uncovered_line and uncovered_conditions - */ -@Deprecated -public class UncoveredComplexityDecorator implements Decorator { - - @DependsUpon - public List<Metric> dependsUponMetrics() { - return Arrays.asList(CoreMetrics.COVERAGE, CoreMetrics.COMPLEXITY); - } - - @DependedUpon - public Metric generatesMetric() { - return CoreMetrics.UNCOVERED_COMPLEXITY_BY_TESTS; - } - - public boolean shouldExecuteOnProject(Project project) { - return true; - } - - public void decorate(Resource resource, DecoratorContext context) { - Measure coverage = context.getMeasure(CoreMetrics.COVERAGE); - Measure complexity = context.getMeasure(CoreMetrics.COMPLEXITY); - - if (MeasureUtils.haveValues(coverage, complexity)) { - double value = complexity.getValue() - (complexity.getValue() * (coverage.getValue() / 100.0)); - String data = KeyValueFormat.format("CMP", complexity.getValue().intValue(), "COV", coverage.getValue()); - context.saveMeasure(new Measure(CoreMetrics.UNCOVERED_COMPLEXITY_BY_TESTS, value, data)); - } - } - - @Override - public String toString() { - return getClass().getSimpleName(); - } -} - diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/UncoveredComplexityDecoratorTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/UncoveredComplexityDecoratorTest.java deleted file mode 100644 index e585691f730..00000000000 --- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/UncoveredComplexityDecoratorTest.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar 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. - * - * Sonar 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 Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.plugins.core.sensors; - -import static org.hamcrest.core.IsNot.not; -import static org.hamcrest.number.OrderingComparisons.greaterThan; -import static org.junit.Assert.assertThat; -import org.junit.Test; -import static org.mockito.Matchers.anyObject; -import static org.mockito.Mockito.*; -import org.sonar.api.batch.DecoratorContext; -import org.sonar.api.measures.CoreMetrics; -import org.sonar.api.measures.Measure; -import org.sonar.api.test.IsMeasure; - -public class UncoveredComplexityDecoratorTest { - - @Test - public void nothingWhenNoMeasures() { - DecoratorContext context = mock(DecoratorContext.class); - UncoveredComplexityDecorator decorator = new UncoveredComplexityDecorator(); - decorator.decorate(null, context); - - verify(context, never()).saveMeasure((Measure) anyObject()); - } - - @Test - public void quotientWhenMeasures() { - DecoratorContext context = mock(DecoratorContext.class); - when(context.getMeasure(CoreMetrics.COMPLEXITY)).thenReturn(new Measure(CoreMetrics.COMPLEXITY, 1048.0)); - when(context.getMeasure(CoreMetrics.COVERAGE)).thenReturn(new Measure(CoreMetrics.COVERAGE, 32.5)); - - UncoveredComplexityDecorator decorator = new UncoveredComplexityDecorator(); - decorator.decorate(null, context); - - verify(context).saveMeasure(argThat(new IsMeasure(CoreMetrics.UNCOVERED_COMPLEXITY_BY_TESTS, 707.4))); - verify(context).saveMeasure(argThat(new IsMeasure(CoreMetrics.UNCOVERED_COMPLEXITY_BY_TESTS, "CMP=1048;COV=32.5"))); - } - - @Test - public void declareDependencies() { - UncoveredComplexityDecorator decorator = new UncoveredComplexityDecorator(); - assertThat(decorator.dependsUponMetrics().size(), greaterThan(0)); - assertThat(decorator.generatesMetric(), not(isNull())); - } -} |