aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2015-07-02 17:30:50 +0200
committerJulien Lancelot <julien.lancelot@sonarsource.com>2015-07-02 17:43:27 +0200
commit7757e395dd73233d752f15a039c580da0a52c3a0 (patch)
tree8ccfe725d6bcbe573d9f08efdf8d245f4365bc4c /sonar-plugin-api
parent3285730cb7271b31c0d557830b7096808b3a47ec (diff)
downloadsonarqube-7757e395dd73233d752f15a039c580da0a52c3a0.tar.gz
sonarqube-7757e395dd73233d752f15a039c580da0a52c3a0.zip
Revert "SONAR-6605 Replace some batch formulas by compute formulas"
This reverts commit 2f948758eebec934beb54701792cf2d558319251.
Diffstat (limited to 'sonar-plugin-api')
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/measures/CoreMetrics.java26
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/measures/Metric.java4
2 files changed, 22 insertions, 8 deletions
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 a7f590c7e64..874c873ae25 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
@@ -22,14 +22,16 @@ package org.sonar.api.measures;
import com.google.common.annotations.Beta;
import com.google.common.base.Predicate;
import com.google.common.collect.Iterables;
+import org.sonar.api.resources.Scopes;
+import org.sonar.api.test.MutableTestPlan;
+import org.sonar.api.utils.SonarException;
+
+import javax.annotation.Nullable;
+
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.LinkedList;
import java.util.List;
-import javax.annotation.Nullable;
-import org.sonar.api.resources.Scopes;
-import org.sonar.api.test.MutableTestPlan;
-import org.sonar.api.utils.SonarException;
/**
* @since 1.10
@@ -75,6 +77,7 @@ public final class CoreMetrics {
.setDomain(DOMAIN_SIZE)
.setBestValue(0.0)
.setOptimizedBestValue(true)
+ .setFormula(new SumChildValuesFormula(false))
.create();
public static final String NCLOC_KEY = "ncloc";
@@ -109,6 +112,7 @@ public final class CoreMetrics {
.setDomain(DOMAIN_SIZE)
.setBestValue(0.0)
.setOptimizedBestValue(true)
+ .setFormula(new SumChildValuesFormula(false))
.create();
public static final String CLASSES_KEY = "classes";
@@ -117,6 +121,7 @@ public final class CoreMetrics {
.setDirection(Metric.DIRECTION_WORST)
.setQualitative(false)
.setDomain(DOMAIN_SIZE)
+ .setFormula(new SumChildValuesFormula(false))
.create();
public static final String FILES_KEY = "files";
@@ -159,6 +164,7 @@ public final class CoreMetrics {
.setDirection(Metric.DIRECTION_WORST)
.setQualitative(false)
.setDomain(DOMAIN_SIZE)
+ .setFormula(new SumChildValuesFormula(false))
.create();
/**
@@ -188,6 +194,7 @@ public final class CoreMetrics {
.setDirection(Metric.DIRECTION_WORST)
.setQualitative(false)
.setDomain(DOMAIN_SIZE)
+ .setFormula(new SumChildValuesFormula(false))
.create();
public static final String PUBLIC_API_KEY = "public_api";
@@ -196,6 +203,7 @@ public final class CoreMetrics {
.setDirection(Metric.DIRECTION_WORST)
.setQualitative(false)
.setDomain(DOMAIN_SIZE)
+ .setFormula(new SumChildValuesFormula(false))
.create();
/**
@@ -225,6 +233,7 @@ public final class CoreMetrics {
.setDirection(Metric.DIRECTION_BETTER)
.setQualitative(false)
.setDomain(DOMAIN_DOCUMENTATION)
+ .setFormula(new SumChildValuesFormula(false))
.create();
public static final String COMMENT_LINES_DENSITY_KEY = "comment_lines_density";
@@ -255,6 +264,7 @@ public final class CoreMetrics {
.setBestValue(0.0)
.setDirection(Metric.DIRECTION_WORST)
.setOptimizedBestValue(true)
+ .setFormula(new SumChildValuesFormula(false))
.create();
/**
@@ -290,6 +300,7 @@ public final class CoreMetrics {
.setDirection(Metric.DIRECTION_WORST)
.setQualitative(false)
.setDomain(DOMAIN_COMPLEXITY)
+ .setFormula(new SumChildValuesFormula(false))
.create();
public static final String FILE_COMPLEXITY_KEY = "file_complexity";
@@ -298,6 +309,7 @@ public final class CoreMetrics {
.setDirection(Metric.DIRECTION_WORST)
.setQualitative(true)
.setDomain(DOMAIN_COMPLEXITY)
+ .setFormula(AverageFormula.create(CoreMetrics.COMPLEXITY, CoreMetrics.FILES))
.create();
/**
@@ -314,6 +326,7 @@ public final class CoreMetrics {
.setDirection(Metric.DIRECTION_WORST)
.setQualitative(false)
.setDomain(DOMAIN_COMPLEXITY)
+ .setFormula(new SumChildValuesFormula(false))
.setDeleteHistoricalData(true)
.create();
@@ -328,6 +341,7 @@ public final class CoreMetrics {
.setDirection(Metric.DIRECTION_WORST)
.setQualitative(true)
.setDomain(DOMAIN_COMPLEXITY)
+ .setFormula(AverageFormula.create(CoreMetrics.COMPLEXITY_IN_CLASSES, CoreMetrics.CLASSES).setFallbackForMainMetric(CoreMetrics.COMPLEXITY))
.create();
/**
@@ -344,6 +358,7 @@ public final class CoreMetrics {
.setDirection(Metric.DIRECTION_WORST)
.setQualitative(false)
.setDomain(DOMAIN_COMPLEXITY)
+ .setFormula(new SumChildValuesFormula(false))
.setDeleteHistoricalData(true)
.create();
@@ -358,6 +373,7 @@ public final class CoreMetrics {
.setDirection(Metric.DIRECTION_WORST)
.setQualitative(true)
.setDomain(DOMAIN_COMPLEXITY)
+ .setFormula(AverageFormula.create(CoreMetrics.COMPLEXITY_IN_FUNCTIONS, CoreMetrics.FUNCTIONS).setFallbackForMainMetric(CoreMetrics.COMPLEXITY))
.create();
/**
@@ -387,6 +403,7 @@ public final class CoreMetrics {
.setDirection(Metric.DIRECTION_NONE)
.setQualitative(true)
.setDomain(DOMAIN_COMPLEXITY)
+ .setFormula(new SumChildDistributionFormula().setMinimumScopeToPersist(Scopes.DIRECTORY))
.create();
public static final String FILE_COMPLEXITY_DISTRIBUTION_KEY = "file_complexity_distribution";
@@ -395,6 +412,7 @@ public final class CoreMetrics {
.setDirection(Metric.DIRECTION_NONE)
.setQualitative(true)
.setDomain(DOMAIN_COMPLEXITY)
+ .setFormula(new SumChildDistributionFormula().setMinimumScopeToPersist(Scopes.DIRECTORY))
.create();
// --------------------------------------------------------------------------------------------------------------------
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/Metric.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/Metric.java
index be259b66de9..57f3fec83a2 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/Metric.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/Metric.java
@@ -699,11 +699,7 @@ public class Metric<G extends Serializable> implements Serializable, org.sonar.a
*
* @param f the formula
* @return the builder
- *
- * @deprecated since 5.2, it's no more possible to define a formula on a metric
- * TODO add a link to the new API to declare formulas
*/
- @Deprecated
public Builder setFormula(Formula f) {
this.formula = f;
return this;