aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2015-07-20 23:46:08 +0200
committerSimon Brandhof <simon.brandhof@sonarsource.com>2015-07-20 23:53:02 +0200
commit670a6f9def17dca3ab131a1930fc2dcec5dc438f (patch)
tree606a599fc9c9bb00f5276a158d44090ef462a1a5 /server
parent399f6c100092eff8eef6f99b7bfb8051af2d4f68 (diff)
downloadsonarqube-670a6f9def17dca3ab131a1930fc2dcec5dc438f.tar.gz
sonarqube-670a6f9def17dca3ab131a1930fc2dcec5dc438f.zip
SONAR-6703 fix coverage rules
Diffstat (limited to 'server')
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/issue/commonrule/AbstractCoverageRule.java4
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/issue/commonrule/CoverageRuleTest.java5
2 files changed, 4 insertions, 5 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/issue/commonrule/AbstractCoverageRule.java b/server/sonar-server/src/main/java/org/sonar/server/computation/issue/commonrule/AbstractCoverageRule.java
index 01063ebd3c3..7e7b9e6e1de 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/issue/commonrule/AbstractCoverageRule.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/issue/commonrule/AbstractCoverageRule.java
@@ -62,8 +62,8 @@ public abstract class AbstractCoverageRule extends CommonRule {
private CommonRuleIssue generateIssue(Component file, double minimumCoverage) {
Optional<Measure> uncoveredMeasure = measureRepository.getRawMeasure(file, uncoveredMetric);
Optional<Measure> toCoverMeasure = measureRepository.getRawMeasure(file, toCoverMetric);
- double uncovered = uncoveredMeasure.isPresent() ? uncoveredMeasure.get().getDoubleValue() : 0.0;
- double toCover = toCoverMeasure.isPresent() ? toCoverMeasure.get().getDoubleValue() : 0.0;
+ double uncovered = uncoveredMeasure.isPresent() ? uncoveredMeasure.get().getIntValue() : 0.0;
+ double toCover = toCoverMeasure.isPresent() ? toCoverMeasure.get().getIntValue() : 0.0;
// effort to fix is the number of lines/conditions to cover for reaching threshold
int effortToFix = (int) Math.ceil((toCover * minimumCoverage / 100) - (toCover - uncovered));
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/issue/commonrule/CoverageRuleTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/issue/commonrule/CoverageRuleTest.java
index 0323cdf5393..e3d71cd039e 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/issue/commonrule/CoverageRuleTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/issue/commonrule/CoverageRuleTest.java
@@ -20,7 +20,6 @@
package org.sonar.server.computation.issue.commonrule;
import com.google.common.collect.ImmutableMap;
-import java.util.Collections;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -98,8 +97,8 @@ public abstract class CoverageRuleTest {
public void issue_if_coverage_is_too_low() {
activeRuleHolder.put(new ActiveRule(getRuleKey(), Severity.CRITICAL, ImmutableMap.of(getMinPropertyKey(), "65")));
measureRepository.addRawMeasure(FILE.getRef(), getCoverageMetricKey(), Measure.newMeasureBuilder().create(20.0));
- measureRepository.addRawMeasure(FILE.getRef(), getUncoveredMetricKey(), Measure.newMeasureBuilder().create(40.0));
- measureRepository.addRawMeasure(FILE.getRef(), getToCoverMetricKey(), Measure.newMeasureBuilder().create(50.0));
+ measureRepository.addRawMeasure(FILE.getRef(), getUncoveredMetricKey(), Measure.newMeasureBuilder().create(40));
+ measureRepository.addRawMeasure(FILE.getRef(), getToCoverMetricKey(), Measure.newMeasureBuilder().create(50));
DefaultIssue issue = underTest.processFile(FILE, "java");