diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2015-07-20 23:46:08 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2015-07-20 23:53:02 +0200 |
commit | 670a6f9def17dca3ab131a1930fc2dcec5dc438f (patch) | |
tree | 606a599fc9c9bb00f5276a158d44090ef462a1a5 /server | |
parent | 399f6c100092eff8eef6f99b7bfb8051af2d4f68 (diff) | |
download | sonarqube-670a6f9def17dca3ab131a1930fc2dcec5dc438f.tar.gz sonarqube-670a6f9def17dca3ab131a1930fc2dcec5dc438f.zip |
SONAR-6703 fix coverage rules
Diffstat (limited to 'server')
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"); |