aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2018-03-26 15:20:11 +0200
committerSonarTech <sonartech@sonarsource.com>2018-03-28 20:20:59 +0200
commitbf11b24d2bcff61792c97001de85966b714c5d85 (patch)
treea00b5c58d9652eaf75be5e36ccab3f22deaf5401
parentd9a11f3443c8d9a464f6f605630c12c9562dad3b (diff)
downloadsonarqube-bf11b24d2bcff61792c97001de85966b714c5d85.tar.gz
sonarqube-bf11b24d2bcff61792c97001de85966b714c5d85.zip
SONAR-5812 Remove the "accessors" metric
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/step/SizeMeasuresStep.java32
-rw-r--r--server/sonar-server/src/main/resources/org/sonar/server/batch/global-example.json110
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/ReportSizeMeasuresStepTest.java3
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/ViewsSizeMeasuresStepTest.java4
-rw-r--r--sonar-core/src/main/java/org/sonar/core/metric/ScannerMetrics.java2
-rw-r--r--sonar-core/src/test/java/org/sonar/core/metric/ScannerMetricsTest.java6
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/measures/CoreMetrics.java20
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/resources/CoreMetricsTest.java4
8 files changed, 21 insertions, 160 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/step/SizeMeasuresStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/step/SizeMeasuresStep.java
index 3fbba51cf3e..4ed2db87a67 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/step/SizeMeasuresStep.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/step/SizeMeasuresStep.java
@@ -19,24 +19,10 @@
*/
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;
@@ -50,7 +36,18 @@ import org.sonar.server.computation.task.projectanalysis.metric.Metric;
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
@@ -63,8 +60,7 @@ public class SizeMeasuresStep implements ComputationStep {
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;
diff --git a/server/sonar-server/src/main/resources/org/sonar/server/batch/global-example.json b/server/sonar-server/src/main/resources/org/sonar/server/batch/global-example.json
deleted file mode 100644
index 457df48af9e..00000000000
--- a/server/sonar-server/src/main/resources/org/sonar/server/batch/global-example.json
+++ /dev/null
@@ -1,110 +0,0 @@
-{
- "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"
- }
-}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/ReportSizeMeasuresStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/ReportSizeMeasuresStepTest.java
index 8e1cefe977f..af45b32c4a4 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/ReportSizeMeasuresStepTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/ReportSizeMeasuresStepTest.java
@@ -102,8 +102,7 @@ public class ReportSizeMeasuresStepTest {
.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);
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/ViewsSizeMeasuresStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/ViewsSizeMeasuresStepTest.java
index e7e35bebdfe..dc705c38978 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/ViewsSizeMeasuresStepTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/ViewsSizeMeasuresStepTest.java
@@ -32,7 +32,6 @@ import static com.google.common.collect.FluentIterable.from;
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;
@@ -105,8 +104,7 @@ public class ViewsSizeMeasuresStepTest {
.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))
diff --git a/sonar-core/src/main/java/org/sonar/core/metric/ScannerMetrics.java b/sonar-core/src/main/java/org/sonar/core/metric/ScannerMetrics.java
index 40d120ca97f..9da45b54375 100644
--- a/sonar-core/src/main/java/org/sonar/core/metric/ScannerMetrics.java
+++ b/sonar-core/src/main/java/org/sonar/core/metric/ScannerMetrics.java
@@ -33,7 +33,6 @@ import org.sonar.api.ce.ComputeEngineSide;
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;
@@ -96,7 +95,6 @@ public class ScannerMetrics {
CLASSES,
FUNCTIONS,
STATEMENTS,
- ACCESSORS,
COMPLEXITY,
COMPLEXITY_IN_CLASSES,
diff --git a/sonar-core/src/test/java/org/sonar/core/metric/ScannerMetricsTest.java b/sonar-core/src/test/java/org/sonar/core/metric/ScannerMetricsTest.java
index 13b28cd3280..602341a74d5 100644
--- a/sonar-core/src/test/java/org/sonar/core/metric/ScannerMetricsTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/metric/ScannerMetricsTest.java
@@ -34,12 +34,12 @@ public class ScannerMetricsTest {
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);
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoreMetrics.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoreMetrics.java
index 2c1545efbd1..1bf18339e21 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoreMetrics.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoreMetrics.java
@@ -209,26 +209,6 @@ public final class CoreMetrics {
.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")
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/resources/CoreMetricsTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/resources/CoreMetricsTest.java
index bc63f7c7c7b..298d12fa25a 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/resources/CoreMetricsTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/resources/CoreMetricsTest.java
@@ -45,13 +45,13 @@ public class CoreMetricsTest {
}
@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");
}