aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-server
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 /server/sonar-server
parentf21abcbb8250053703ce6edc36bfea03bb3665e7 (diff)
downloadsonarqube-b0d4220a7e1b2c53dfd5b8da118a1829039ce44b.tar.gz
sonarqube-b0d4220a7e1b2c53dfd5b8da118a1829039ce44b.zip
SONAR-8284 Remove overall/IT coverage data from scanner report
Diffstat (limited to 'server/sonar-server')
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/source/CoverageLineReader.java34
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/source/CoverageLineReaderTest.java75
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/PersistFileSourcesStepTest.java15
3 files changed, 31 insertions, 93 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/source/CoverageLineReader.java b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/source/CoverageLineReader.java
index a54a20f6e8a..1f3fdedbf5f 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/source/CoverageLineReader.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/source/CoverageLineReader.java
@@ -23,11 +23,8 @@ import java.util.Iterator;
import javax.annotation.CheckForNull;
import org.sonar.db.protobuf.DbFileSources;
import org.sonar.scanner.protocol.output.ScannerReport;
-import org.sonar.scanner.protocol.output.ScannerReport.LineCoverage.HasItCoveredConditionsCase;
-import org.sonar.scanner.protocol.output.ScannerReport.LineCoverage.HasItHitsCase;
-import org.sonar.scanner.protocol.output.ScannerReport.LineCoverage.HasOverallCoveredConditionsCase;
-import org.sonar.scanner.protocol.output.ScannerReport.LineCoverage.HasUtCoveredConditionsCase;
-import org.sonar.scanner.protocol.output.ScannerReport.LineCoverage.HasUtHitsCase;
+import org.sonar.scanner.protocol.output.ScannerReport.LineCoverage.HasCoveredConditionsCase;
+import org.sonar.scanner.protocol.output.ScannerReport.LineCoverage.HasHitsCase;
public class CoverageLineReader implements LineReader {
@@ -43,39 +40,28 @@ public class CoverageLineReader implements LineReader {
ScannerReport.LineCoverage reportCoverage = getNextLineCoverageIfMatchLine(lineBuilder.getLine());
if (reportCoverage != null) {
processUnitTest(lineBuilder, reportCoverage);
- processIntegrationTest(lineBuilder, reportCoverage);
processOverallTest(lineBuilder, reportCoverage);
coverage = null;
}
}
private static void processUnitTest(DbFileSources.Line.Builder lineBuilder, ScannerReport.LineCoverage reportCoverage) {
- if (reportCoverage.getHasUtHitsCase() == HasUtHitsCase.UT_HITS) {
- lineBuilder.setUtLineHits(reportCoverage.getUtHits() ? 1 : 0);
+ if (reportCoverage.getHasHitsCase() == HasHitsCase.HITS) {
+ lineBuilder.setUtLineHits(reportCoverage.getHits() ? 1 : 0);
}
- if (reportCoverage.getHasUtCoveredConditionsCase() == HasUtCoveredConditionsCase.UT_COVERED_CONDITIONS) {
+ if (reportCoverage.getHasCoveredConditionsCase() == HasCoveredConditionsCase.COVERED_CONDITIONS) {
lineBuilder.setUtConditions(reportCoverage.getConditions());
- lineBuilder.setUtCoveredConditions(reportCoverage.getUtCoveredConditions());
- }
- }
-
- private static void processIntegrationTest(DbFileSources.Line.Builder lineBuilder, ScannerReport.LineCoverage reportCoverage) {
- if (reportCoverage.getHasItHitsCase() == HasItHitsCase.IT_HITS) {
- lineBuilder.setItLineHits(reportCoverage.getItHits() ? 1 : 0);
- }
- if (reportCoverage.getHasItCoveredConditionsCase() == HasItCoveredConditionsCase.IT_COVERED_CONDITIONS) {
- lineBuilder.setItConditions(reportCoverage.getConditions());
- lineBuilder.setItCoveredConditions(reportCoverage.getItCoveredConditions());
+ lineBuilder.setUtCoveredConditions(reportCoverage.getCoveredConditions());
}
}
private static void processOverallTest(DbFileSources.Line.Builder lineBuilder, ScannerReport.LineCoverage reportCoverage) {
- if (reportCoverage.getHasUtHitsCase() == HasUtHitsCase.UT_HITS || reportCoverage.getHasItHitsCase() == HasItHitsCase.IT_HITS) {
- lineBuilder.setOverallLineHits((reportCoverage.getUtHits() || reportCoverage.getItHits()) ? 1 : 0);
+ if (reportCoverage.getHasHitsCase() == HasHitsCase.HITS) {
+ lineBuilder.setOverallLineHits(reportCoverage.getHits() ? 1 : 0);
}
- if (reportCoverage.getHasOverallCoveredConditionsCase() == HasOverallCoveredConditionsCase.OVERALL_COVERED_CONDITIONS) {
+ if (reportCoverage.getHasCoveredConditionsCase() == HasCoveredConditionsCase.COVERED_CONDITIONS) {
lineBuilder.setOverallConditions(reportCoverage.getConditions());
- lineBuilder.setOverallCoveredConditions(reportCoverage.getOverallCoveredConditions());
+ lineBuilder.setOverallCoveredConditions(reportCoverage.getCoveredConditions());
}
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/source/CoverageLineReaderTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/source/CoverageLineReaderTest.java
index dede32111a5..7a756748e8d 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/source/CoverageLineReaderTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/source/CoverageLineReaderTest.java
@@ -34,11 +34,8 @@ public class CoverageLineReaderTest {
CoverageLineReader computeCoverageLine = new CoverageLineReader(newArrayList(ScannerReport.LineCoverage.newBuilder()
.setLine(1)
.setConditions(10)
- .setUtHits(true)
- .setUtCoveredConditions(2)
- .setItHits(true)
- .setItCoveredConditions(3)
- .setOverallCoveredConditions(4)
+ .setHits(true)
+ .setCoveredConditions(2)
.build()).iterator());
DbFileSources.Line.Builder lineBuilder = DbFileSources.Data.newBuilder().addLinesBuilder().setLine(1);
@@ -46,11 +43,6 @@ public class CoverageLineReaderTest {
assertThat(lineBuilder.getUtLineHits()).isEqualTo(1);
assertThat(lineBuilder.getUtConditions()).isEqualTo(10);
- assertThat(lineBuilder.getItLineHits()).isEqualTo(1);
- assertThat(lineBuilder.getItConditions()).isEqualTo(10);
- assertThat(lineBuilder.getItCoveredConditions()).isEqualTo(3);
- assertThat(lineBuilder.getOverallLineHits()).isEqualTo(1);
- assertThat(lineBuilder.getOverallConditions()).isEqualTo(10);
}
// Some tools are only able to report condition coverage
@@ -59,8 +51,7 @@ public class CoverageLineReaderTest {
CoverageLineReader computeCoverageLine = new CoverageLineReader(newArrayList(ScannerReport.LineCoverage.newBuilder()
.setLine(1)
.setConditions(10)
- .setUtCoveredConditions(2)
- .setItCoveredConditions(3)
+ .setCoveredConditions(2)
.build()).iterator());
DbFileSources.Line.Builder lineBuilder = DbFileSources.Data.newBuilder().addLinesBuilder().setLine(1);
@@ -69,10 +60,9 @@ public class CoverageLineReaderTest {
assertThat(lineBuilder.hasUtLineHits()).isFalse();
assertThat(lineBuilder.getUtConditions()).isEqualTo(10);
assertThat(lineBuilder.hasItLineHits()).isFalse();
- assertThat(lineBuilder.getItConditions()).isEqualTo(10);
- assertThat(lineBuilder.getItCoveredConditions()).isEqualTo(3);
assertThat(lineBuilder.hasOverallLineHits()).isFalse();
- assertThat(lineBuilder.hasOverallConditions()).isFalse();
+ assertThat(lineBuilder.hasOverallConditions()).isTrue();
+ assertThat(lineBuilder.getOverallConditions()).isEqualTo(10);
}
@Test
@@ -80,8 +70,8 @@ public class CoverageLineReaderTest {
CoverageLineReader computeCoverageLine = new CoverageLineReader(newArrayList(ScannerReport.LineCoverage.newBuilder()
.setLine(1)
.setConditions(10)
- .setUtHits(true)
- .setUtCoveredConditions(2)
+ .setHits(true)
+ .setCoveredConditions(2)
.build()).iterator());
DbFileSources.Line.Builder lineBuilder = DbFileSources.Data.newBuilder().addLinesBuilder().setLine(1);
@@ -89,40 +79,20 @@ public class CoverageLineReaderTest {
assertThat(lineBuilder.getUtLineHits()).isEqualTo(1);
assertThat(lineBuilder.getUtConditions()).isEqualTo(10);
+ assertThat(lineBuilder.getUtCoveredConditions()).isEqualTo(2);
assertThat(lineBuilder.hasItLineHits()).isFalse();
assertThat(lineBuilder.hasItConditions()).isFalse();
assertThat(lineBuilder.hasItCoveredConditions()).isFalse();
assertThat(lineBuilder.getOverallLineHits()).isEqualTo(1);
- assertThat(lineBuilder.hasOverallCoveredConditions()).isFalse();
- }
-
- @Test
- public void set_coverage_only_it() {
- CoverageLineReader computeCoverageLine = new CoverageLineReader(newArrayList(ScannerReport.LineCoverage.newBuilder()
- .setLine(1)
- .setConditions(10)
- .setItHits(true)
- .setItCoveredConditions(3)
- .build()).iterator());
-
- DbFileSources.Line.Builder lineBuilder = DbFileSources.Data.newBuilder().addLinesBuilder().setLine(1);
- computeCoverageLine.read(lineBuilder);
-
- assertThat(lineBuilder.hasUtLineHits()).isFalse();
- assertThat(lineBuilder.hasUtConditions()).isFalse();
- assertThat(lineBuilder.getItLineHits()).isEqualTo(1);
- assertThat(lineBuilder.getItConditions()).isEqualTo(10);
- assertThat(lineBuilder.getItCoveredConditions()).isEqualTo(3);
- assertThat(lineBuilder.getOverallLineHits()).isEqualTo(1);
- assertThat(lineBuilder.hasOverallConditions()).isFalse();
+ assertThat(lineBuilder.hasOverallCoveredConditions()).isTrue();
+ assertThat(lineBuilder.getOverallCoveredConditions()).isEqualTo(2);
}
@Test
public void set_coverage_on_uncovered_lines() {
CoverageLineReader computeCoverageLine = new CoverageLineReader(newArrayList(ScannerReport.LineCoverage.newBuilder()
.setLine(1)
- .setUtHits(false)
- .setItHits(false)
+ .setHits(false)
.build()).iterator());
DbFileSources.Line.Builder lineBuilder = DbFileSources.Data.newBuilder().addLinesBuilder().setLine(1);
@@ -130,8 +100,6 @@ public class CoverageLineReaderTest {
assertThat(lineBuilder.hasUtLineHits()).isTrue();
assertThat(lineBuilder.getUtLineHits()).isEqualTo(0);
- assertThat(lineBuilder.hasItLineHits()).isTrue();
- assertThat(lineBuilder.getItLineHits()).isEqualTo(0);
assertThat(lineBuilder.hasOverallLineHits()).isTrue();
assertThat(lineBuilder.getOverallLineHits()).isEqualTo(0);
}
@@ -140,7 +108,7 @@ public class CoverageLineReaderTest {
public void set_overall_line_hits_with_only_ut() {
CoverageLineReader computeCoverageLine = new CoverageLineReader(newArrayList(ScannerReport.LineCoverage.newBuilder()
.setLine(1)
- .setUtHits(true)
+ .setHits(true)
.build()).iterator());
DbFileSources.Line.Builder lineBuilder = DbFileSources.Data.newBuilder().addLinesBuilder().setLine(1);
@@ -153,7 +121,7 @@ public class CoverageLineReaderTest {
public void set_overall_line_hits_with_only_it() {
CoverageLineReader computeCoverageLine = new CoverageLineReader(newArrayList(ScannerReport.LineCoverage.newBuilder()
.setLine(1)
- .setItHits(true)
+ .setHits(true)
.build()).iterator());
DbFileSources.Line.Builder lineBuilder = DbFileSources.Data.newBuilder().addLinesBuilder().setLine(1);
@@ -166,8 +134,7 @@ public class CoverageLineReaderTest {
public void set_overall_line_hits_with_ut_and_it() {
CoverageLineReader computeCoverageLine = new CoverageLineReader(newArrayList(ScannerReport.LineCoverage.newBuilder()
.setLine(1)
- .setUtHits(true)
- .setItHits(true)
+ .setHits(true)
.build()).iterator());
DbFileSources.Line.Builder lineBuilder = DbFileSources.Data.newBuilder().addLinesBuilder().setLine(1);
@@ -198,11 +165,8 @@ public class CoverageLineReaderTest {
ScannerReport.LineCoverage.newBuilder()
.setLine(1)
.setConditions(10)
- .setUtHits(true)
- .setUtCoveredConditions(2)
- .setItHits(true)
- .setItCoveredConditions(3)
- .setOverallCoveredConditions(4)
+ .setHits(true)
+ .setCoveredConditions(2)
.build()
// No coverage info on line 2
).iterator());
@@ -225,11 +189,8 @@ public class CoverageLineReaderTest {
ScannerReport.LineCoverage.newBuilder()
.setLine(1)
.setConditions(10)
- .setUtHits(true)
- .setUtCoveredConditions(2)
- .setItHits(true)
- .setItCoveredConditions(3)
- .setOverallCoveredConditions(4)
+ .setHits(true)
+ .setCoveredConditions(2)
.build()
// No coverage info on line 2
).iterator());
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/PersistFileSourcesStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/PersistFileSourcesStepTest.java
index a203c3ea411..387241fce2f 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/PersistFileSourcesStepTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/PersistFileSourcesStepTest.java
@@ -35,9 +35,9 @@ import org.sonar.scanner.protocol.output.ScannerReport;
import org.sonar.scanner.protocol.output.ScannerReport.Component.ComponentType;
import org.sonar.scanner.protocol.output.ScannerReport.SyntaxHighlightingRule.HighlightingType;
import org.sonar.server.computation.task.projectanalysis.batch.BatchReportReaderRule;
-import org.sonar.server.computation.task.projectanalysis.component.TreeRootHolderRule;
import org.sonar.server.computation.task.projectanalysis.component.Component;
import org.sonar.server.computation.task.projectanalysis.component.ReportComponent;
+import org.sonar.server.computation.task.projectanalysis.component.TreeRootHolderRule;
import org.sonar.server.computation.task.projectanalysis.duplication.Duplicate;
import org.sonar.server.computation.task.projectanalysis.duplication.Duplication;
import org.sonar.server.computation.task.projectanalysis.duplication.DuplicationRepositoryRule;
@@ -138,11 +138,8 @@ public class PersistFileSourcesStepTest extends BaseStepTest {
reportReader.putCoverage(FILE_REF, newArrayList(ScannerReport.LineCoverage.newBuilder()
.setLine(1)
.setConditions(10)
- .setUtHits(true)
- .setUtCoveredConditions(2)
- .setItHits(true)
- .setItCoveredConditions(3)
- .setOverallCoveredConditions(4)
+ .setHits(true)
+ .setCoveredConditions(2)
.build()));
underTest.execute();
@@ -156,12 +153,6 @@ public class PersistFileSourcesStepTest extends BaseStepTest {
assertThat(data.getLines(0).getUtLineHits()).isEqualTo(1);
assertThat(data.getLines(0).getUtConditions()).isEqualTo(10);
assertThat(data.getLines(0).getUtCoveredConditions()).isEqualTo(2);
- assertThat(data.getLines(0).hasItLineHits()).isTrue();
- assertThat(data.getLines(0).getItConditions()).isEqualTo(10);
- assertThat(data.getLines(0).getItCoveredConditions()).isEqualTo(3);
- assertThat(data.getLines(0).getOverallLineHits()).isEqualTo(1);
- assertThat(data.getLines(0).getOverallConditions()).isEqualTo(10);
- assertThat(data.getLines(0).getOverallCoveredConditions()).isEqualTo(4);
}
@Test