aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-scanner-engine
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2016-10-17 16:31:39 +0200
committerJulien HENRY <julien.henry@sonarsource.com>2016-10-18 16:00:26 +0200
commitb0d4220a7e1b2c53dfd5b8da118a1829039ce44b (patch)
treefbdcc3cdfe974a260628011e8eb90ed2f363f2c5 /sonar-scanner-engine
parentf21abcbb8250053703ce6edc36bfea03bb3665e7 (diff)
downloadsonarqube-b0d4220a7e1b2c53dfd5b8da118a1829039ce44b.tar.gz
sonarqube-b0d4220a7e1b2c53dfd5b8da118a1829039ce44b.zip
SONAR-8284 Remove overall/IT coverage data from scanner report
Diffstat (limited to 'sonar-scanner-engine')
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/report/CoveragePublisher.java52
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/coverage/CoverageMediumTest.java22
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/report/CoveragePublisherTest.java8
3 files changed, 15 insertions, 67 deletions
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/CoveragePublisher.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/CoveragePublisher.java
index cf17785dab8..ba776070fa5 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/CoveragePublisher.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/CoveragePublisher.java
@@ -56,57 +56,11 @@ public class CoveragePublisher implements ReportPublisherStep {
int lineCount = ((InputFile) resource.inputComponent()).lines();
applyLineMeasure(resource.key(), lineCount, CoreMetrics.COVERAGE_LINE_HITS_DATA_KEY, coveragePerLine,
- new MeasureOperation() {
- @Override
- public void apply(String value, LineCoverage.Builder builder) {
- builder.setUtHits(Integer.parseInt(value) > 0);
- }
- });
- applyLineMeasure(resource.key(), lineCount, CoreMetrics.IT_COVERAGE_LINE_HITS_DATA_KEY, coveragePerLine,
- new MeasureOperation() {
- @Override
- public void apply(String value, LineCoverage.Builder builder) {
- builder.setItHits(Integer.parseInt(value) > 0);
- }
- });
- // Just in case we have only IT and no UT, we first take conditions from ITs, then from UTs (UTs will override ITs).
- // Note that it would be very strange (and unsupported in scanner report) to have ITs and UTs don't report the same number of
- // conditions. Not even talking about overall conditions...
- applyLineMeasure(resource.key(), lineCount, CoreMetrics.IT_CONDITIONS_BY_LINE_KEY, coveragePerLine,
- new MeasureOperation() {
- @Override
- public void apply(String value, LineCoverage.Builder builder) {
- builder.setConditions(Integer.parseInt(value));
- }
- });
+ (value, builder) -> builder.setHits(Integer.parseInt(value) > 0));
applyLineMeasure(resource.key(), lineCount, CoreMetrics.CONDITIONS_BY_LINE_KEY, coveragePerLine,
- new MeasureOperation() {
- @Override
- public void apply(String value, LineCoverage.Builder builder) {
- builder.setConditions(Integer.parseInt(value));
- }
- });
+ (value, builder) -> builder.setConditions(Integer.parseInt(value)));
applyLineMeasure(resource.key(), lineCount, CoreMetrics.COVERED_CONDITIONS_BY_LINE_KEY, coveragePerLine,
- new MeasureOperation() {
- @Override
- public void apply(String value, LineCoverage.Builder builder) {
- builder.setUtCoveredConditions(Integer.parseInt(value));
- }
- });
- applyLineMeasure(resource.key(), lineCount, CoreMetrics.IT_COVERED_CONDITIONS_BY_LINE_KEY, coveragePerLine,
- new MeasureOperation() {
- @Override
- public void apply(String value, LineCoverage.Builder builder) {
- builder.setItCoveredConditions(Integer.parseInt(value));
- }
- });
- applyLineMeasure(resource.key(), lineCount, CoreMetrics.OVERALL_COVERED_CONDITIONS_BY_LINE_KEY, coveragePerLine,
- new MeasureOperation() {
- @Override
- public void apply(String value, LineCoverage.Builder builder) {
- builder.setOverallCoveredConditions(Integer.parseInt(value));
- }
- });
+ (value, builder) -> builder.setCoveredConditions(Integer.parseInt(value)));
writer.writeComponentCoverage(resource.batchId(), Iterables.transform(coveragePerLine.values(), BuildCoverage.INSTANCE));
}
}
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/coverage/CoverageMediumTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/coverage/CoverageMediumTest.java
index ccc5440ae86..0f3c28a14f0 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/coverage/CoverageMediumTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/coverage/CoverageMediumTest.java
@@ -83,12 +83,9 @@ public class CoverageMediumTest {
.start();
InputFile file = result.inputFile("src/sample.xoo");
- assertThat(result.coverageFor(file, 2).getUtHits()).isTrue();
- assertThat(result.coverageFor(file, 2).getItHits()).isFalse();
+ assertThat(result.coverageFor(file, 2).getHits()).isTrue();
assertThat(result.coverageFor(file, 2).getConditions()).isEqualTo(2);
- assertThat(result.coverageFor(file, 2).getUtCoveredConditions()).isEqualTo(1);
- assertThat(result.coverageFor(file, 2).getItCoveredConditions()).isEqualTo(0);
- assertThat(result.coverageFor(file, 2).getOverallCoveredConditions()).isEqualTo(0);
+ assertThat(result.coverageFor(file, 2).getCoveredConditions()).isEqualTo(1);
Map<String, List<org.sonar.scanner.protocol.output.ScannerReport.Measure>> allMeasures = result.allMeasures();
assertThat(allMeasures.get("com.foo.project:src/sample.xoo")).extracting("metricKey", "intValue.value")
@@ -125,10 +122,10 @@ public class CoverageMediumTest {
.start();
InputFile file = result.inputFile("src/sample.xoo");
- assertThat(result.coverageFor(file, 2).getUtHits()).isTrue();
+ assertThat(result.coverageFor(file, 2).getHits()).isTrue();
assertThat(result.coverageFor(file, 2).getConditions()).isEqualTo(2);
- assertThat(result.coverageFor(file, 2).getUtCoveredConditions()).isEqualTo(2);
- assertThat(result.coverageFor(file, 3).getUtHits()).isTrue();
+ assertThat(result.coverageFor(file, 2).getCoveredConditions()).isEqualTo(2);
+ assertThat(result.coverageFor(file, 3).getHits()).isTrue();
Map<String, List<org.sonar.scanner.protocol.output.ScannerReport.Measure>> allMeasures = result.allMeasures();
assertThat(allMeasures.get("com.foo.project:src/sample.xoo")).extracting("metricKey", "intValue.value")
@@ -199,14 +196,11 @@ public class CoverageMediumTest {
InputFile file = result.inputFile("src/sample.xoo");
assertThat(result.coverageFor(file, 1)).isNull();
- assertThat(result.coverageFor(file, 2).getUtHits()).isFalse();
- assertThat(result.coverageFor(file, 2).getItHits()).isFalse();
+ assertThat(result.coverageFor(file, 2).getHits()).isFalse();
assertThat(result.coverageFor(file, 2).getConditions()).isEqualTo(0);
- assertThat(result.coverageFor(file, 2).getUtCoveredConditions()).isEqualTo(0);
- assertThat(result.coverageFor(file, 2).getItCoveredConditions()).isEqualTo(0);
- assertThat(result.coverageFor(file, 2).getOverallCoveredConditions()).isEqualTo(0);
+ assertThat(result.coverageFor(file, 2).getCoveredConditions()).isEqualTo(0);
- assertThat(result.coverageFor(file, 3).getUtHits()).isFalse();
+ assertThat(result.coverageFor(file, 3).getHits()).isFalse();
assertThat(result.coverageFor(file, 4)).isNull();
Map<String, List<org.sonar.scanner.protocol.output.ScannerReport.Measure>> allMeasures = result.allMeasures();
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/CoveragePublisherTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/CoveragePublisherTest.java
index 6ce6b181fc9..95757460e10 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/CoveragePublisherTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/CoveragePublisherTest.java
@@ -84,17 +84,17 @@ public class CoveragePublisherTest {
try (CloseableIterator<LineCoverage> it = new ScannerReportReader(outputDir).readComponentCoverage(2)) {
assertThat(it.next()).isEqualTo(LineCoverage.newBuilder()
.setLine(2)
- .setUtHits(true)
+ .setHits(true)
.build());
assertThat(it.next()).isEqualTo(LineCoverage.newBuilder()
.setLine(3)
- .setUtHits(true)
+ .setHits(true)
.setConditions(4)
- .setUtCoveredConditions(2)
+ .setCoveredConditions(2)
.build());
assertThat(it.next()).isEqualTo(LineCoverage.newBuilder()
.setLine(5)
- .setUtHits(false)
+ .setHits(false)
.build());
}