aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-scanner-engine/src/main/java/org
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2018-08-21 17:45:17 +0200
committersonartech <sonartech@sonarsource.com>2018-09-19 10:51:40 +0200
commit47571cbb5b56357f4f7be610f2a04b6688e7d8ba (patch)
treee833d32361d9db4eb5e180492021681381eb840a /sonar-scanner-engine/src/main/java/org
parent790d026a6731ca53cf9580f9cb1ce48b44d40d2b (diff)
downloadsonarqube-47571cbb5b56357f4f7be610f2a04b6688e7d8ba.tar.gz
sonarqube-47571cbb5b56357f4f7be610f2a04b6688e7d8ba.zip
SONAR-11139 Store changed lines information received in scanner report
Diffstat (limited to 'sonar-scanner-engine/src/main/java/org')
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ChangedLinesPublisher.java15
1 files changed, 9 insertions, 6 deletions
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ChangedLinesPublisher.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ChangedLinesPublisher.java
index d15fa2d0961..1413a7a6bfa 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ChangedLinesPublisher.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ChangedLinesPublisher.java
@@ -20,6 +20,7 @@
package org.sonar.scanner.report;
import java.nio.file.Path;
+import java.util.Collections;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
@@ -78,17 +79,19 @@ public class ChangedLinesPublisher implements ReportPublisherStep {
int count = 0;
if (pathSetMap == null) {
+ // no information returned by the SCM, we write nothing in the report and
+ // the compute engine will use SCM dates to estimate which lines are new
return count;
}
for (Map.Entry<Path, DefaultInputFile> e : allPublishedFiles.entrySet()) {
- Set<Integer> changedLines = pathSetMap.get(e.getKey());
- // if the file got no information returned by the SCM, we write nothing in the report and
- // the compute engine will use SCM dates to estimate which lines are new
- if (changedLines != null && !changedLines.isEmpty()) {
- count++;
- writeChangedLines(writer, e.getValue().batchId(), changedLines);
+ Set<Integer> changedLines = pathSetMap.getOrDefault(e.getKey(), Collections.emptySet());
+
+ if (changedLines.isEmpty()) {
+ LOG.warn("File '{}' was detected as changed but without having changed lines", e.getKey().toAbsolutePath());
}
+ count++;
+ writeChangedLines(writer, e.getValue().batchId(), changedLines);
}
return count;
}