]> source.dussan.org Git - sonarqube.git/commitdiff
Remove code in CoreMetrics/Metric deprecated in 2.x
authorSimon Brandhof <simon.brandhof@gmail.com>
Wed, 19 Jun 2013 21:14:01 +0000 (23:14 +0200)
committerSimon Brandhof <simon.brandhof@gmail.com>
Wed, 19 Jun 2013 21:15:48 +0000 (23:15 +0200)
sonar-plugin-api/src/main/java/org/sonar/api/measures/CoreMetrics.java
sonar-plugin-api/src/main/java/org/sonar/api/measures/Metric.java
sonar-plugin-api/src/test/java/org/sonar/api/resources/CoreMetricsTest.java

index 68967655016f893f0ff2ffdf82a1bb4cb599f4d2..b471208660ee879a6a669fdfc8cb1b597fcac5bb 100644 (file)
@@ -52,13 +52,6 @@ public final class CoreMetrics {
   @Deprecated
   public static String DOMAIN_REVIEWS = "Reviews";
   public static String DOMAIN_ISSUES = "Issues";
-
-  /**
-   * @deprecated since 2.5 See SONAR-2007
-   */
-  @Deprecated
-  public static final String DOMAIN_RULE_CATEGORIES = "Rule categories";
-
   public static String DOMAIN_GENERAL = "General";
   public static String DOMAIN_DUPLICATION = "Duplication";
   public static String DOMAIN_DESIGN = "Design";
@@ -1328,77 +1321,6 @@ public final class CoreMetrics {
   //
   // --------------------------------------------------------------------------------------------------------------------
 
-  /**
-   * @deprecated since 2.5 See SONAR-2007
-   */
-  @Deprecated
-  public static final String USABILITY_KEY = "usability";
-
-  /**
-   * @deprecated since 2.5 See SONAR-2007
-   */
-  @Deprecated
-  public static final Metric USABILITY = new Metric(USABILITY_KEY, "Usability", "Usability", Metric.ValueType.PERCENT,
-    Metric.DIRECTION_BETTER, true, DOMAIN_RULE_CATEGORIES).setBestValue(100.0).setOptimizedBestValue(true);
-
-  /**
-   * @deprecated since 2.5 See SONAR-2007
-   */
-  @Deprecated
-  public static final String RELIABILITY_KEY = "reliability";
-
-  /**
-   * @deprecated since 2.5 See SONAR-2007
-   */
-  @Deprecated
-  public static final Metric RELIABILITY = new Metric(RELIABILITY_KEY, "Reliability", "Reliability", Metric.ValueType.PERCENT,
-    Metric.DIRECTION_BETTER, true, DOMAIN_RULE_CATEGORIES).setBestValue(100.0).setOptimizedBestValue(true);
-
-  /**
-   * @deprecated since 2.5 See SONAR-2007
-   */
-  @Deprecated
-  public static final String EFFICIENCY_KEY = "efficiency";
-
-  /**
-   * @deprecated since 2.5 See SONAR-2007
-   */
-  @Deprecated
-  public static final Metric EFFICIENCY = new Metric(EFFICIENCY_KEY, "Efficiency", "Efficiency", Metric.ValueType.PERCENT,
-    Metric.DIRECTION_BETTER, true, DOMAIN_RULE_CATEGORIES).setBestValue(100.0).setOptimizedBestValue(true);
-
-  /**
-   * @deprecated since 2.5 See SONAR-2007
-   */
-  @Deprecated
-  public static final String PORTABILITY_KEY = "portability";
-
-  /**
-   * @deprecated since 2.5 See SONAR-2007
-   */
-  @Deprecated
-  public static final Metric PORTABILITY = new Metric(PORTABILITY_KEY, "Portability", "Portability", Metric.ValueType.PERCENT,
-    Metric.DIRECTION_BETTER, true, DOMAIN_RULE_CATEGORIES).setBestValue(100.0).setOptimizedBestValue(true);
-
-  /**
-   * @deprecated since 2.5 See SONAR-2007
-   */
-  @Deprecated
-  public static final String MAINTAINABILITY_KEY = "maintainability";
-
-  /**
-   * @deprecated since 2.5 See SONAR-2007
-   */
-  @Deprecated
-  public static final Metric MAINTAINABILITY = new Metric.Builder(MAINTAINABILITY_KEY, "Maintainability", Metric.ValueType.PERCENT)
-    .setDescription("Maintainability")
-    .setDirection(Metric.DIRECTION_BETTER)
-    .setQualitative(true)
-    .setDomain(DOMAIN_RULE_CATEGORIES)
-    .setBestValue(100.0)
-    .setOptimizedBestValue(true)
-    .create();
-
   public static final String WEIGHTED_VIOLATIONS_KEY = "weighted_violations";
   public static final Metric WEIGHTED_VIOLATIONS = new Metric.Builder(WEIGHTED_VIOLATIONS_KEY, "Weighted issues", Metric.ValueType.INT)
     .setDescription("Weighted Issues")
@@ -2116,9 +2038,7 @@ public final class CoreMetrics {
       if (Metric.class.isAssignableFrom(field.getType())) {
         try {
           Metric metric = (Metric) field.get(null);
-          if (!StringUtils.equals(metric.getDomain(), DOMAIN_RULE_CATEGORIES)) {
-            METRICS.add(metric);
-          }
+          METRICS.add(metric);
         } catch (IllegalAccessException e) {
           throw new SonarException("can not introspect " + CoreMetrics.class + " to get metrics", e);
         }
index 440d816b15c596a36ab3182bc5df7077b4e06e94..b6e845b5fba07a43cbff499c075547aede0db982 100644 (file)
@@ -154,7 +154,7 @@ public class Metric implements ServerExtension, BatchExtension {
   }
 
   /**
-   * Creates an empty metric
+   * Creates an empty metric. Required for Hibernate.
    *
    * @deprecated in 1.12. Use the {@link Builder} factory.
    */
@@ -190,7 +190,7 @@ public class Metric implements ServerExtension, BatchExtension {
    * @deprecated since 2.7 use the {@link Builder} factory.
    */
   @Deprecated
-  public Metric(String key, String name, String description, ValueType type, Integer direction, Boolean qualitative, String domain) {
+  private Metric(String key, String name, String description, ValueType type, Integer direction, Boolean qualitative, String domain) {
     this(key, name, description, type, direction, qualitative, domain, false);
   }
 
@@ -211,7 +211,7 @@ public class Metric implements ServerExtension, BatchExtension {
    * @deprecated since 2.7 use the {@link Builder} factory.
    */
   @Deprecated
-  public Metric(String key, String name, String description, ValueType type, Integer direction, Boolean qualitative, String domain,
+  private Metric(String key, String name, String description, ValueType type, Integer direction, Boolean qualitative, String domain,
       boolean userManaged) {
     this.key = key;
     this.description = description;
@@ -246,7 +246,7 @@ public class Metric implements ServerExtension, BatchExtension {
    * @deprecated since 2.7 use the {@link Builder} factory.
    */
   @Deprecated
-  public Metric(String key, String name, ValueType type, Integer direction, Boolean qualitative, String domain, Formula formula) {
+  private Metric(String key, String name, ValueType type, Integer direction, Boolean qualitative, String domain, Formula formula) {
     this.key = key;
     this.name = name;
     this.type = type;
index 88ae3dd2b06bad5ce72c0cc3596b9852f5bdf3b4..4f6e1a9e6184b8b2f1ab241f26584156718ff69e 100644 (file)
@@ -25,25 +25,13 @@ import org.sonar.api.measures.Metric;
 
 import java.util.List;
 
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.fest.assertions.Assertions.assertThat;
 
 public class CoreMetricsTest {
   @Test
   public void shouldReadMetricsFromClassReflection() {
     List<Metric> metrics = CoreMetrics.getMetrics();
-    assertTrue(metrics.size() > 10);
-    assertTrue(metrics.contains(CoreMetrics.NCLOC));
-    assertTrue(metrics.contains(CoreMetrics.DIRECTORIES));
-  }
-
-  @Test
-  public void shouldExcludeDeprecatedIsoMetrics() {
-    List<Metric> metrics = CoreMetrics.getMetrics();
-    assertFalse(metrics.contains(CoreMetrics.USABILITY));
-    assertFalse(metrics.contains(CoreMetrics.EFFICIENCY));
-    assertFalse(metrics.contains(CoreMetrics.RELIABILITY));
-    assertFalse(metrics.contains(CoreMetrics.PORTABILITY));
-    assertFalse(metrics.contains(CoreMetrics.MAINTAINABILITY));
+    assertThat(metrics).hasSize(148);
+    assertThat(metrics).contains(CoreMetrics.NCLOC, CoreMetrics.DIRECTORIES);
   }
 }