Skip to content

Commit 798fcfa

Browse files
author
Rob Caiger
committed
Re-introduction of processUncoveredFilesFromWhitelist alongside performance tweaks
1 parent 75111c6 commit 798fcfa

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

src/CodeCoverage.php

+13-12
Original file line numberDiff line numberDiff line change
@@ -841,6 +841,9 @@ private function processUncoveredLines($raw = false)
841841
$filesToProcess = array_keys($this->data);
842842
}
843843

844+
$coverageData = $this->data;
845+
$this->data = [];
846+
844847
foreach ($filesToProcess as $file) {
845848

846849
if (!file_exists($file)) {
@@ -855,32 +858,30 @@ private function processUncoveredLines($raw = false)
855858
$this->driver->start();
856859
include_once($file);
857860
$data = $this->driver->stop();
861+
858862
} else {
859863
$lines = count(file($file));
860864

861865
for ($i = 1; $i <= $lines; $i++) {
862-
$data[$file][$i] = [];
866+
$data[$file][$i] = PHP_CodeCoverage_Driver::LINE_NOT_EXECUTED;
863867
}
864868
}
865869

866-
if (empty($data[$file])) {
867-
continue;
868-
}
870+
$this->initializeFilesThatAreSeenTheFirstTime($data);
869871

870872
if (!$isCoveredFile) {
871873
// If it is an uncovered file, just append the data
872874
$this->append($data, 'UNCOVERED_FILES_FROM_WHITELIST');
873-
} else {
874-
875-
// Otherwise, we need to merge the uncovered/dead code with the coverage data
875+
}
876+
}
876877

877-
foreach ($data[$file] as $k => $v) {
878-
if (!isset($this->data[$file][$k])) {
879-
$this->data[$file][$k] = $v == -2 ? null : [];
880-
}
881-
}
878+
foreach ($coverageData as $file => $lines) {
879+
foreach ($lines as $k => $v) {
880+
$this->data[$file][$k] = $v;
882881
}
882+
}
883883

884+
foreach ($this->data as $file => $lines) {
884885
foreach ($this->getLinesToBeIgnored($file) as $line) {
885886
unset($this->data[$file][$line]);
886887
}

0 commit comments

Comments
 (0)