@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";
//
// --------------------------------------------------------------------------------------------------------------------
- /**
- * @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")
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);
}
}
/**
- * Creates an empty metric
+ * Creates an empty metric. Required for Hibernate.
*
* @deprecated in 1.12. Use the {@link Builder} factory.
*/
* @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);
}
* @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;
* @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;
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);
}
}