]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-2238 Remove the metric "uncovered_complexity_by_tests"
authorsimonbrandhof <simon.brandhof@gmail.com>
Thu, 24 Feb 2011 23:20:30 +0000 (00:20 +0100)
committersimonbrandhof <simon.brandhof@gmail.com>
Fri, 25 Feb 2011 06:44:16 +0000 (07:44 +0100)
plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java
plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/UncoveredComplexityDecorator.java [deleted file]
plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/UncoveredComplexityDecoratorTest.java [deleted file]
sonar-plugin-api/src/main/java/org/sonar/api/measures/CoreMetrics.java
sonar-server/src/main/webapp/WEB-INF/app/models/metric.rb

index 18113235d1d7cff2cae0c7cebe73ae3d4dca7efd..4d6063a9d7149747fc0dea84ae00b0ed6f6365af 100644 (file)
@@ -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 (file)
index 153b4d6..0000000
+++ /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 (file)
index e585691..0000000
+++ /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()));
-  }
-}
index d7c94b4853b1ed7e450a197daa6a84c9830fccf8..2480b8ddb41142afcd76c5a82e486874ce07e0f0 100644 (file)
@@ -296,18 +296,6 @@ public final class CoreMetrics {
       .setDomain(DOMAIN_TESTS)
       .create();
 
-  /**
-   * @deprecated replaced since 1.11 by UNCOVERED_LINES and UNCOVERED_CONDITIONS
-   */
-  @Deprecated
-  public static final String UNCOVERED_COMPLEXITY_BY_TESTS_KEY = "uncovered_complexity_by_tests";
-  /**
-   * @deprecated replaced since 1.11 by UNCOVERED_LINES and UNCOVERED_CONDITIONS
-   */
-  @Deprecated
-  public static final Metric UNCOVERED_COMPLEXITY_BY_TESTS = new Metric(UNCOVERED_COMPLEXITY_BY_TESTS_KEY, "Uncovered complexity",
-      "Uncovered complexity", Metric.ValueType.INT, Metric.DIRECTION_WORST, false, DOMAIN_COMPLEXITY).setFormula(new SumChildValuesFormula(
-      false));
 
   public static final String DUPLICATED_LINES_KEY = "duplicated_lines";
   public static final Metric DUPLICATED_LINES = new Metric(DUPLICATED_LINES_KEY, "Duplicated lines", "Duplicated lines",
index dd22621af4f63b0390d9d82b299d3b7174399a6e..d4bb9b2f58ebaa795d79ef39d4431655510e5496 100644 (file)
@@ -244,7 +244,6 @@ class Metric < ActiveRecord::Base
   AVG_CMPX_BY_FILE = 'file_complexity'
   CLASSES_CMPX_DISTRIBUTION = 'class_complexity_distribution'
   FUNCTIONS_CMPX_DISTRIBUTION = 'function_complexity_distribution'
-  UNCOVERED_CMPX_BY_TESTS = 'uncovered_complexity_by_tests'
 
   DUPLICATED_FILES = 'duplicated_files'
   DUPLICATED_LINES = 'duplicated_lines'