*/
package org.sonar.server.computation.task.projectanalysis.step;
-import static org.sonar.api.measures.CoreMetrics.ACCESSORS_KEY;
-import static org.sonar.api.measures.CoreMetrics.CLASSES_KEY;
-import static org.sonar.api.measures.CoreMetrics.DIRECTORIES_KEY;
-import static org.sonar.api.measures.CoreMetrics.FILES_KEY;
-import static org.sonar.api.measures.CoreMetrics.FUNCTIONS_KEY;
-import static org.sonar.api.measures.CoreMetrics.GENERATED_LINES_KEY;
-import static org.sonar.api.measures.CoreMetrics.GENERATED_NCLOC_KEY;
-import static org.sonar.api.measures.CoreMetrics.LINES_KEY;
-import static org.sonar.api.measures.CoreMetrics.NCLOC_KEY;
-import static org.sonar.api.measures.CoreMetrics.STATEMENTS_KEY;
-import static org.sonar.server.computation.task.projectanalysis.component.ComponentVisitor.Order.POST_ORDER;
-import static org.sonar.server.computation.task.projectanalysis.formula.SumFormula.createIntSumFormula;
-import static org.sonar.server.computation.task.projectanalysis.measure.Measure.newMeasureBuilder;
-
+import com.google.common.base.Optional;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
-
import org.sonar.server.computation.task.projectanalysis.component.Component;
import org.sonar.server.computation.task.projectanalysis.component.CrawlerDepthLimit;
import org.sonar.server.computation.task.projectanalysis.component.PathAwareCrawler;
import org.sonar.server.computation.task.projectanalysis.metric.MetricRepository;
import org.sonar.server.computation.task.step.ComputationStep;
-import com.google.common.base.Optional;
+import static org.sonar.api.measures.CoreMetrics.CLASSES_KEY;
+import static org.sonar.api.measures.CoreMetrics.DIRECTORIES_KEY;
+import static org.sonar.api.measures.CoreMetrics.FILES_KEY;
+import static org.sonar.api.measures.CoreMetrics.FUNCTIONS_KEY;
+import static org.sonar.api.measures.CoreMetrics.GENERATED_LINES_KEY;
+import static org.sonar.api.measures.CoreMetrics.GENERATED_NCLOC_KEY;
+import static org.sonar.api.measures.CoreMetrics.LINES_KEY;
+import static org.sonar.api.measures.CoreMetrics.NCLOC_KEY;
+import static org.sonar.api.measures.CoreMetrics.STATEMENTS_KEY;
+import static org.sonar.server.computation.task.projectanalysis.component.ComponentVisitor.Order.POST_ORDER;
+import static org.sonar.server.computation.task.projectanalysis.formula.SumFormula.createIntSumFormula;
+import static org.sonar.server.computation.task.projectanalysis.measure.Measure.newMeasureBuilder;
/**
* Compute size measures
createIntSumFormula(GENERATED_NCLOC_KEY),
createIntSumFormula(FUNCTIONS_KEY),
createIntSumFormula(STATEMENTS_KEY),
- createIntSumFormula(CLASSES_KEY),
- createIntSumFormula(ACCESSORS_KEY)));
+ createIntSumFormula(CLASSES_KEY)));
private final TreeRootHolder treeRootHolder;
private final MetricRepository metricRepository;
+++ /dev/null
-{
- "timestamp": 0,
- "metrics": [
- {
- "id": 11,
- "key": "accessors",
- "valueType": "INT",
- "description": "Accessors",
- "direction": -1,
- "name": "accessors",
- "qualitative": false,
- "userManaged": false,
- "optimizedBestValue": false
- },
- {
- "id": 93,
- "key": "blocker_violations",
- "valueType": "INT",
- "description": "Blocker issues",
- "direction": -1,
- "name": "blocker_violations",
- "qualitative": true,
- "userManaged": false,
- "bestValue": 0.0,
- "optimizedBestValue": true
- },
- {
- "id": 45,
- "key": "conditions_to_cover",
- "valueType": "INT",
- "description": "Branches to cover",
- "direction": 0,
- "name": "conditions_to_cover",
- "qualitative": false,
- "userManaged": false,
- "optimizedBestValue": false
- },
- {
- "id": 63,
- "key": "new_it_conditions_to_cover",
- "valueType": "INT",
- "description": "Branches to cover by Integration Tests on new code",
- "direction": 0,
- "name": "new_it_conditions_to_cover",
- "qualitative": false,
- "userManaged": false,
- "optimizedBestValue": false
- },
- {
- "id": 46,
- "key": "new_conditions_to_cover",
- "valueType": "INT",
- "description": "Branches to cover on new code",
- "direction": 0,
- "name": "new_conditions_to_cover",
- "qualitative": false,
- "userManaged": false,
- "optimizedBestValue": false
- },
- {
- "id": 122,
- "key": "burned_budget",
- "valueType": "FLOAT",
- "direction": 0,
- "name": "burned_budget",
- "qualitative": false,
- "userManaged": true,
- "optimizedBestValue": false
- },
- {
- "id": 123,
- "key": "business_value",
- "valueType": "FLOAT",
- "direction": 1,
- "name": "business_value",
- "qualitative": true,
- "userManaged": true,
- "optimizedBestValue": false
- },
- {
- "id": 6,
- "key": "classes",
- "valueType": "INT",
- "description": "Classes",
- "direction": -1,
- "name": "classes",
- "qualitative": false,
- "userManaged": false,
- "optimizedBestValue": false
- },
- {
- "id": 23,
- "key": "class_complexity",
- "valueType": "FLOAT",
- "description": "Complexity average by class",
- "direction": -1,
- "name": "class_complexity",
- "qualitative": true,
- "userManaged": false,
- "optimizedBestValue": false
- }
- ],
- "globalSettings": {
- "sonar.permission.template.default": "default_template",
- "sonar.core.startTime": "2015-11-02T09:22:09+0100",
- "sonar.core.id": "20151102092209",
- "sonar.core.version": "5.3-SNAPSHOT",
- "sonar.qualitygate": "1"
- }
-}
.add(CoreMetrics.GENERATED_NCLOC)
.add(CoreMetrics.FUNCTIONS)
.add(CoreMetrics.STATEMENTS)
- .add(CoreMetrics.CLASSES)
- .add(CoreMetrics.ACCESSORS);
+ .add(CoreMetrics.CLASSES);
@Rule
public MeasureRepositoryRule measureRepository = MeasureRepositoryRule.create(treeRootHolder, metricRepository);
import static com.google.common.collect.Iterables.concat;
import static java.util.Arrays.asList;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.sonar.api.measures.CoreMetrics.ACCESSORS;
import static org.sonar.api.measures.CoreMetrics.CLASSES;
import static org.sonar.api.measures.CoreMetrics.CLASSES_KEY;
import static org.sonar.api.measures.CoreMetrics.DIRECTORIES;
.add(GENERATED_NCLOC)
.add(FUNCTIONS)
.add(STATEMENTS)
- .add(CLASSES)
- .add(ACCESSORS);
+ .add(CLASSES);
@Rule
public MeasureRepositoryRule measureRepository = MeasureRepositoryRule.create(treeRootHolder, metricRepository)
.addRawMeasure(PROJECTVIEW_1_REF, LINES_KEY, newMeasureBuilder().create(1))
import org.sonar.api.measures.Metric;
import org.sonar.api.measures.Metrics;
-import static org.sonar.api.measures.CoreMetrics.ACCESSORS;
import static org.sonar.api.measures.CoreMetrics.CLASSES;
import static org.sonar.api.measures.CoreMetrics.COGNITIVE_COMPLEXITY;
import static org.sonar.api.measures.CoreMetrics.COMMENT_LINES;
CLASSES,
FUNCTIONS,
STATEMENTS,
- ACCESSORS,
COMPLEXITY,
COMPLEXITY_IN_CLASSES,
private static final List<Metric> SENSOR_METRICS_WITHOUT_METRIC_PLUGIN = metrics();
@Test
- public void check_number_of_allowed_core_metrics() throws Exception {
- assertThat(SENSOR_METRICS_WITHOUT_METRIC_PLUGIN).hasSize(34);
+ public void check_number_of_allowed_core_metrics() {
+ assertThat(SENSOR_METRICS_WITHOUT_METRIC_PLUGIN).hasSize(33);
}
@Test
- public void check_metrics_from_plugin() throws Exception {
+ public void check_metrics_from_plugin() {
List<Metric> metrics = metrics(new FakeMetrics());
metrics.removeAll(SENSOR_METRICS_WITHOUT_METRIC_PLUGIN);
assertThat(metrics).hasSize(2);
.setDomain(DOMAIN_SIZE)
.create();
- /**
- * @deprecated since 5.0.
- * @see <a href="https://jira.sonarsource.com/browse/SONAR-5224">SONAR-5224</a>
- */
- @Deprecated
- public static final String ACCESSORS_KEY = "accessors";
-
- /**
- * @deprecated since 5.0.
- * @see <a href="https://jira.sonarsource.com/browse/SONAR-5224">SONAR-5224</a>
- */
- @Deprecated
- public static final Metric<Integer> ACCESSORS = new Metric.Builder(ACCESSORS_KEY, "Accessors", Metric.ValueType.INT)
- .setDescription("Accessors")
- .setDirection(Metric.DIRECTION_WORST)
- .setQualitative(false)
- .setDomain(DOMAIN_SIZE)
- .setHidden(true)
- .create();
-
public static final String STATEMENTS_KEY = "statements";
public static final Metric<Integer> STATEMENTS = new Metric.Builder(STATEMENTS_KEY, "Statements", Metric.ValueType.INT)
.setDescription("Number of statements")
}
@Test
- public void get_metric_by_key() throws Exception {
+ public void get_metric_by_key() {
Metric metric = getMetric("ncloc");
assertThat(metric.getKey()).isEqualTo("ncloc");
}
@Test
- public void fail_get_unknown_metric_by_key() throws Exception {
+ public void fail_get_unknown_metric_by_key() {
expectedException.expect(NoSuchElementException.class);
getMetric("unknown");
}