aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-ce-task-projectanalysis/src
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2022-06-20 14:54:01 -0500
committersonartech <sonartech@sonarsource.com>2022-06-21 20:02:45 +0000
commit4c674a26a6c422348f7a3f3fbfb8712abf001bbd (patch)
treeac554d55c710c2fbbe154a3f93a87da1f7ae86ac /server/sonar-ce-task-projectanalysis/src
parent2cb3e53879262017a32c3e394ac30669e573c42c (diff)
downloadsonarqube-4c674a26a6c422348f7a3f3fbfb8712abf001bbd.tar.gz
sonarqube-4c674a26a6c422348f7a3f3fbfb8712abf001bbd.zip
SONAR-16521 'Line Coverage' inconsistent with 'Lines to cover' and 'uncovered lines'
Diffstat (limited to 'server/sonar-ce-task-projectanalysis/src')
-rw-r--r--server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/CoverageMeasuresStep.java3
-rw-r--r--server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/NewCoverageMeasuresStep.java2
2 files changed, 4 insertions, 1 deletions
diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/CoverageMeasuresStep.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/CoverageMeasuresStep.java
index 2db3a2d6e13..fd9c5ceb783 100644
--- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/CoverageMeasuresStep.java
+++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/CoverageMeasuresStep.java
@@ -112,6 +112,9 @@ public class CoverageMeasuresStep implements ComputationStep {
@Override
public void visitFile(Component file) {
+ if (file.getFileAttributes().isUnitTest()) {
+ return;
+ }
try (CloseableIterator<ScannerReport.LineCoverage> lineCoverage = reportReader.readComponentCoverage(file.getReportAttributes().getRef())) {
int linesToCover = 0;
int coveredLines = 0;
diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/NewCoverageMeasuresStep.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/NewCoverageMeasuresStep.java
index 206dfc91ed8..ae5eb75170c 100644
--- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/NewCoverageMeasuresStep.java
+++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/NewCoverageMeasuresStep.java
@@ -199,7 +199,7 @@ public class NewCoverageMeasuresStep implements ComputationStep {
@Override
public void initialize(CounterInitializationContext context) {
Component component = context.getLeaf();
- if (component.getType() != Component.Type.FILE) {
+ if (component.getType() != Component.Type.FILE || component.getFileAttributes().isUnitTest()) {
return;
}
Optional<Set<Integer>> newLinesSet = newLinesRepository.getNewLines(component);