diff options
author | Julien Lancelot <julien.lancelot@gmail.com> | 2013-04-26 13:00:53 +0200 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@gmail.com> | 2013-04-26 13:00:53 +0200 |
commit | d56bd3f6b8675e76b6de0a94d0f77729d3505a7e (patch) | |
tree | d3de4d61ce8931e4586a58d994829d956b7da0ec /sonar-plugin-api | |
parent | 23e5afe016a96cf71bc531057cfdc768428ec01e (diff) | |
download | sonarqube-d56bd3f6b8675e76b6de0a94d0f77729d3505a7e.tar.gz sonarqube-d56bd3f6b8675e76b6de0a94d0f77729d3505a7e.zip |
SONAR-3900 dependsUponMetrics should also return fallbackMetric
Diffstat (limited to 'sonar-plugin-api')
-rw-r--r-- | sonar-plugin-api/src/main/java/org/sonar/api/measures/AverageFormula.java | 2 | ||||
-rw-r--r-- | sonar-plugin-api/src/test/java/org/sonar/api/measures/AverageFormulaTest.java | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/AverageFormula.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/AverageFormula.java index 59869be6eac..3e8ff97a3a6 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/AverageFormula.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/AverageFormula.java @@ -71,7 +71,7 @@ public class AverageFormula implements Formula { * {@inheritDoc} */ public List<Metric> dependsUponMetrics() { - return Arrays.asList(mainMetric, byMetric); + return Arrays.asList(mainMetric, fallbackMetric, byMetric); } /** diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/measures/AverageFormulaTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/measures/AverageFormulaTest.java index 8cabe3cf741..6ecc868d33e 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/measures/AverageFormulaTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/measures/AverageFormulaTest.java @@ -52,6 +52,12 @@ public class AverageFormulaTest { } @Test + public void test_depends_upon_falback_metric() throws Exception { + AverageFormula formula = AverageFormula.create(CoreMetrics.COMPLEXITY_IN_FUNCTIONS, CoreMetrics.FUNCTIONS).setFallbackForMainMetric(CoreMetrics.COMPLEXITY); + assertThat(formula.dependsUponMetrics(), hasItems(CoreMetrics.COMPLEXITY_IN_FUNCTIONS, CoreMetrics.COMPLEXITY, CoreMetrics.FUNCTIONS)); + } + + @Test public void test_average_calculation() { List<FormulaData> childrenData = newArrayList(); FormulaData data1 = mock(FormulaData.class); |