Skip to content

Commit

Permalink
Use isVeryVerbose
Browse files Browse the repository at this point in the history
  • Loading branch information
janedbal committed Oct 2, 2024
1 parent 5f79dce commit 82f8844
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
24 changes: 12 additions & 12 deletions src/Analyser/ResultCache/ResultCacheManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,21 +92,21 @@ public function restore(array $allAnalysedFiles, bool $debug, bool $onlyFiles, ?
{
$startTime = microtime(true);
if ($debug) {
if ($output->isVerbose()) {
if ($output->isVeryVerbose()) {
$output->writeLineFormatted('Result cache not used because of debug mode.');
}
return new ResultCache($allAnalysedFiles, true, time(), $this->getMeta($allAnalysedFiles, $projectConfigArray), [], [], [], [], [], [], [], []);
}
if ($onlyFiles) {
if ($output->isVerbose()) {
if ($output->isVeryVerbose()) {
$output->writeLineFormatted('Result cache not used because only files were passed as analysed paths.');
}
return new ResultCache($allAnalysedFiles, true, time(), $this->getMeta($allAnalysedFiles, $projectConfigArray), [], [], [], [], [], [], [], []);
}

$cacheFilePath = $this->cacheFilePath;
if (!is_file($cacheFilePath)) {
if ($output->isVerbose()) {
if ($output->isVeryVerbose()) {
$output->writeLineFormatted('Result cache not used because the cache file does not exist.');
}
return new ResultCache($allAnalysedFiles, true, time(), $this->getMeta($allAnalysedFiles, $projectConfigArray), [], [], [], [], [], [], [], []);
Expand All @@ -115,7 +115,7 @@ public function restore(array $allAnalysedFiles, bool $debug, bool $onlyFiles, ?
try {
$data = require $cacheFilePath;
} catch (Throwable $e) {
if ($output->isVerbose()) {
if ($output->isVeryVerbose()) {
$output->writeLineFormatted(sprintf('Result cache not used because an error occurred while loading the cache file: %s', $e->getMessage()));
}

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

if (!is_array($data)) {
@unlink($cacheFilePath);
if ($output->isVerbose()) {
if ($output->isVeryVerbose()) {
$output->writeLineFormatted('Result cache not used because the cache file is corrupted.');
}

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

$meta = $this->getMeta($allAnalysedFiles, $projectConfigArray);
if ($this->isMetaDifferent($data['meta'], $meta)) {
if ($output->isVerbose()) {
if ($output->isVeryVerbose()) {
$diffs = $this->getMetaKeyDifferences($data['meta'], $meta);
$output->writeLineFormatted('Result cache not used because the metadata do not match: ' . implode(', ', $diffs));
}
return new ResultCache($allAnalysedFiles, true, time(), $meta, [], [], [], [], [], [], [], []);
}

if (time() - $data['lastFullAnalysisTime'] >= 60 * 60 * 24 * 7) {
if ($output->isVerbose()) {
if ($output->isVeryVerbose()) {
$output->writeLineFormatted('Result cache not used because it\'s more than 7 days since last full analysis.');
}
// run full analysis if the result cache is older than 7 days
Expand Down Expand Up @@ -412,20 +412,20 @@ public function process(AnalyserResult $analyserResult, ResultCache $resultCache
}
$doSave = function (array $errorsByFile, $locallyIgnoredErrorsByFile, $linesToIgnore, $unmatchedLineIgnores, $collectedDataByFile, ?array $dependencies, array $exportedNodes, array $projectExtensionFiles) use ($internalErrors, $resultCache, $output, $onlyFiles, $meta): bool {
if ($onlyFiles) {
if ($output->isVerbose()) {
if ($output->isVeryVerbose()) {
$output->writeLineFormatted('Result cache was not saved because only files were passed as analysed paths.');
}
return false;
}
if ($dependencies === null) {
if ($output->isVerbose()) {
if ($output->isVeryVerbose()) {
$output->writeLineFormatted('Result cache was not saved because of error in dependencies.');
}
return false;
}

if (count($internalErrors) > 0) {
if ($output->isVerbose()) {
if ($output->isVeryVerbose()) {
$output->writeLineFormatted('Result cache was not saved because of internal errors.');
}
return false;
Expand All @@ -447,7 +447,7 @@ public function process(AnalyserResult $analyserResult, ResultCache $resultCache

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

if ($output->isVerbose()) {
if ($output->isVeryVerbose()) {
$output->writeLineFormatted('Result cache is saved.');
}

Expand All @@ -463,7 +463,7 @@ public function process(AnalyserResult $analyserResult, ResultCache $resultCache
}
$saved = $doSave($freshErrorsByFile, $freshLocallyIgnoredErrorsByFile, $analyserResult->getLinesToIgnore(), $analyserResult->getUnmatchedLineIgnores(), $freshCollectedDataByFile, $analyserResult->getDependencies(), $analyserResult->getExportedNodes(), $projectExtensionFiles);
} else {
if ($output->isVerbose()) {
if ($output->isVeryVerbose()) {
$output->writeLineFormatted('Result cache was not saved because it was not requested.');
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Command/AnalyseApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function analyse(
$collectedData = [];
$savedResultCache = false;
$memoryUsageBytes = memory_get_peak_usage(true);
if ($errorOutput->isVerbose()) {
if ($errorOutput->isVeryVerbose()) {
$errorOutput->writeLineFormatted('Result cache was not saved because of ignoredErrorHelperResult errors.');
}
$changedProjectExtensionFilesOutsideOfAnalysedPaths = [];
Expand Down

0 comments on commit 82f8844

Please sign in to comment.