Skip to content

Commit c79b69a

Browse files
authored
Move result cache output from debug to very verbose mode
1 parent 98e2b6e commit c79b69a

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

Diff for: src/Analyser/ResultCache/ResultCacheManager.php

+16-16
Original file line numberDiff line numberDiff line change
@@ -92,21 +92,21 @@ public function restore(array $allAnalysedFiles, bool $debug, bool $onlyFiles, ?
9292
{
9393
$startTime = microtime(true);
9494
if ($debug) {
95-
if ($output->isDebug()) {
95+
if ($output->isVeryVerbose()) {
9696
$output->writeLineFormatted('Result cache not used because of debug mode.');
9797
}
9898
return new ResultCache($allAnalysedFiles, true, time(), $this->getMeta($allAnalysedFiles, $projectConfigArray), [], [], [], [], [], [], [], []);
9999
}
100100
if ($onlyFiles) {
101-
if ($output->isDebug()) {
101+
if ($output->isVeryVerbose()) {
102102
$output->writeLineFormatted('Result cache not used because only files were passed as analysed paths.');
103103
}
104104
return new ResultCache($allAnalysedFiles, true, time(), $this->getMeta($allAnalysedFiles, $projectConfigArray), [], [], [], [], [], [], [], []);
105105
}
106106

107107
$cacheFilePath = $this->cacheFilePath;
108108
if (!is_file($cacheFilePath)) {
109-
if ($output->isDebug()) {
109+
if ($output->isVeryVerbose()) {
110110
$output->writeLineFormatted('Result cache not used because the cache file does not exist.');
111111
}
112112
return new ResultCache($allAnalysedFiles, true, time(), $this->getMeta($allAnalysedFiles, $projectConfigArray), [], [], [], [], [], [], [], []);
@@ -115,7 +115,7 @@ public function restore(array $allAnalysedFiles, bool $debug, bool $onlyFiles, ?
115115
try {
116116
$data = require $cacheFilePath;
117117
} catch (Throwable $e) {
118-
if ($output->isDebug()) {
118+
if ($output->isVeryVerbose()) {
119119
$output->writeLineFormatted(sprintf('Result cache not used because an error occurred while loading the cache file: %s', $e->getMessage()));
120120
}
121121

@@ -126,7 +126,7 @@ public function restore(array $allAnalysedFiles, bool $debug, bool $onlyFiles, ?
126126

127127
if (!is_array($data)) {
128128
@unlink($cacheFilePath);
129-
if ($output->isDebug()) {
129+
if ($output->isVeryVerbose()) {
130130
$output->writeLineFormatted('Result cache not used because the cache file is corrupted.');
131131
}
132132

@@ -135,15 +135,15 @@ public function restore(array $allAnalysedFiles, bool $debug, bool $onlyFiles, ?
135135

136136
$meta = $this->getMeta($allAnalysedFiles, $projectConfigArray);
137137
if ($this->isMetaDifferent($data['meta'], $meta)) {
138-
if ($output->isDebug()) {
138+
if ($output->isVeryVerbose()) {
139139
$diffs = $this->getMetaKeyDifferences($data['meta'], $meta);
140140
$output->writeLineFormatted('Result cache not used because the metadata do not match: ' . implode(', ', $diffs));
141141
}
142142
return new ResultCache($allAnalysedFiles, true, time(), $meta, [], [], [], [], [], [], [], []);
143143
}
144144

145145
if (time() - $data['lastFullAnalysisTime'] >= 60 * 60 * 24 * 7) {
146-
if ($output->isDebug()) {
146+
if ($output->isVeryVerbose()) {
147147
$output->writeLineFormatted('Result cache not used because it\'s more than 7 days since last full analysis.');
148148
}
149149
// run full analysis if the result cache is older than 7 days
@@ -159,7 +159,7 @@ public function restore(array $allAnalysedFiles, bool $debug, bool $onlyFiles, ?
159159
continue;
160160
}
161161
if (!is_file($extensionFile)) {
162-
if ($output->isDebug()) {
162+
if ($output->isVeryVerbose()) {
163163
$output->writeLineFormatted(sprintf('Result cache not used because extension file %s was not found.', $extensionFile));
164164
}
165165
return new ResultCache($allAnalysedFiles, true, time(), $meta, [], [], [], [], [], [], [], []);
@@ -169,7 +169,7 @@ public function restore(array $allAnalysedFiles, bool $debug, bool $onlyFiles, ?
169169
continue;
170170
}
171171

172-
if ($output->isDebug()) {
172+
if ($output->isVeryVerbose()) {
173173
$output->writeLineFormatted(sprintf('Result cache not used because extension file %s hash does not match.', $extensionFile));
174174
}
175175

@@ -287,7 +287,7 @@ public function restore(array $allAnalysedFiles, bool $debug, bool $onlyFiles, ?
287287
$filesToAnalyse = array_unique($filesToAnalyse);
288288
$filesToAnalyseCount = count($filesToAnalyse);
289289

290-
if ($output->isDebug()) {
290+
if ($output->isVeryVerbose()) {
291291
$elapsed = microtime(true) - $startTime;
292292
$elapsedString = $elapsed > 5
293293
? sprintf(' in %f seconds', round($elapsed, 1))
@@ -412,20 +412,20 @@ public function process(AnalyserResult $analyserResult, ResultCache $resultCache
412412
}
413413
$doSave = function (array $errorsByFile, $locallyIgnoredErrorsByFile, $linesToIgnore, $unmatchedLineIgnores, $collectedDataByFile, ?array $dependencies, array $exportedNodes, array $projectExtensionFiles) use ($internalErrors, $resultCache, $output, $onlyFiles, $meta): bool {
414414
if ($onlyFiles) {
415-
if ($output->isDebug()) {
415+
if ($output->isVeryVerbose()) {
416416
$output->writeLineFormatted('Result cache was not saved because only files were passed as analysed paths.');
417417
}
418418
return false;
419419
}
420420
if ($dependencies === null) {
421-
if ($output->isDebug()) {
421+
if ($output->isVeryVerbose()) {
422422
$output->writeLineFormatted('Result cache was not saved because of error in dependencies.');
423423
}
424424
return false;
425425
}
426426

427427
if (count($internalErrors) > 0) {
428-
if ($output->isDebug()) {
428+
if ($output->isVeryVerbose()) {
429429
$output->writeLineFormatted('Result cache was not saved because of internal errors.');
430430
}
431431
return false;
@@ -437,7 +437,7 @@ public function process(AnalyserResult $analyserResult, ResultCache $resultCache
437437
continue;
438438
}
439439

440-
if ($output->isDebug()) {
440+
if ($output->isVeryVerbose()) {
441441
$output->writeLineFormatted(sprintf('Result cache was not saved because of non-ignorable exception: %s', $error->getMessage()));
442442
}
443443

@@ -447,7 +447,7 @@ public function process(AnalyserResult $analyserResult, ResultCache $resultCache
447447

448448
$this->save($resultCache->getLastFullAnalysisTime(), $errorsByFile, $locallyIgnoredErrorsByFile, $linesToIgnore, $unmatchedLineIgnores, $collectedDataByFile, $dependencies, $exportedNodes, $projectExtensionFiles, $meta);
449449

450-
if ($output->isDebug()) {
450+
if ($output->isVeryVerbose()) {
451451
$output->writeLineFormatted('Result cache is saved.');
452452
}
453453

@@ -463,7 +463,7 @@ public function process(AnalyserResult $analyserResult, ResultCache $resultCache
463463
}
464464
$saved = $doSave($freshErrorsByFile, $freshLocallyIgnoredErrorsByFile, $analyserResult->getLinesToIgnore(), $analyserResult->getUnmatchedLineIgnores(), $freshCollectedDataByFile, $analyserResult->getDependencies(), $analyserResult->getExportedNodes(), $projectExtensionFiles);
465465
} else {
466-
if ($output->isDebug()) {
466+
if ($output->isVeryVerbose()) {
467467
$output->writeLineFormatted('Result cache was not saved because it was not requested.');
468468
}
469469
}

Diff for: src/Command/AnalyseApplication.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function analyse(
6060
$collectedData = [];
6161
$savedResultCache = false;
6262
$memoryUsageBytes = memory_get_peak_usage(true);
63-
if ($errorOutput->isDebug()) {
63+
if ($errorOutput->isVeryVerbose()) {
6464
$errorOutput->writeLineFormatted('Result cache was not saved because of ignoredErrorHelperResult errors.');
6565
}
6666
$changedProjectExtensionFilesOutsideOfAnalysedPaths = [];

0 commit comments

Comments
 (0)