mirror of
https://github.com/danog/psalm.git
synced 2024-11-26 20:34:47 +01:00
Merge pull request #10115 from edsrzf/file-find-unused-baseline
This commit is contained in:
commit
c34d5132b5
@ -401,7 +401,7 @@ final class Psalm
|
||||
!$paths_to_check,
|
||||
$start_time,
|
||||
isset($options['stats']),
|
||||
self::initBaseline($options, $config, $current_dir, $path_to_config),
|
||||
self::initBaseline($options, $config, $current_dir, $path_to_config, $paths_to_check),
|
||||
);
|
||||
} else {
|
||||
self::autoGenerateConfig($project_analyzer, $current_dir, $init_source_dir, $vendor_dir);
|
||||
@ -1036,17 +1036,23 @@ final class Psalm
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ?list<string> $paths_to_check
|
||||
* @return array<string,array<string,array{o:int, s: list<string>}>>
|
||||
*/
|
||||
private static function initBaseline(
|
||||
array $options,
|
||||
Config $config,
|
||||
string $current_dir,
|
||||
?string $path_to_config
|
||||
?string $path_to_config,
|
||||
?array $paths_to_check
|
||||
): array {
|
||||
$issue_baseline = [];
|
||||
|
||||
if (isset($options['set-baseline']) && is_string($options['set-baseline'])) {
|
||||
if ($paths_to_check !== null) {
|
||||
fwrite(STDERR, PHP_EOL . 'Cannot generate baseline when checking specific files' . PHP_EOL);
|
||||
exit(1);
|
||||
}
|
||||
$issue_baseline = self::generateBaseline($options, $config, $current_dir, $path_to_config);
|
||||
}
|
||||
|
||||
@ -1063,6 +1069,10 @@ final class Psalm
|
||||
}
|
||||
|
||||
if (isset($options['update-baseline'])) {
|
||||
if ($paths_to_check !== null) {
|
||||
fwrite(STDERR, PHP_EOL . 'Cannot update baseline when checking specific files' . PHP_EOL);
|
||||
exit(1);
|
||||
}
|
||||
$issue_baseline = self::updateBaseline($options, $config);
|
||||
}
|
||||
|
||||
@ -1078,6 +1088,17 @@ final class Psalm
|
||||
}
|
||||
}
|
||||
|
||||
if ($paths_to_check !== null) {
|
||||
$filtered_issue_baseline = [];
|
||||
foreach ($paths_to_check as $path_to_check) {
|
||||
$path_to_check = substr($path_to_check, strlen($config->base_dir));
|
||||
if (isset($issue_baseline[$path_to_check])) {
|
||||
$filtered_issue_baseline[$path_to_check] = $issue_baseline[$path_to_check];
|
||||
}
|
||||
}
|
||||
$issue_baseline = $filtered_issue_baseline;
|
||||
}
|
||||
|
||||
return $issue_baseline;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user