mirror of
https://github.com/danog/psalm.git
synced 2025-01-22 05:41:20 +01:00
Add add info notification to progress
This commit is contained in:
parent
6eecb46b34
commit
ae8ccdbcd7
@ -245,9 +245,27 @@ class Analyzer
|
||||
|
||||
$this->progress->start(count($this->files_to_analyze));
|
||||
|
||||
$task_done_closure = function (array $issues): void {
|
||||
$this->progress->taskDone(count($issues) === 0);
|
||||
};
|
||||
$task_done_closure =
|
||||
/**
|
||||
* @param array<IssueData> $issues
|
||||
*/
|
||||
function (array $issues): void {
|
||||
$has_error = false;
|
||||
$has_info = false;
|
||||
|
||||
foreach ($issues as $issue) {
|
||||
if ($issue['severity'] === 'error') {
|
||||
$has_error = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if ($issue['severity'] === 'info') {
|
||||
$has_info = true;
|
||||
}
|
||||
}
|
||||
|
||||
$this->progress->taskDone($has_error ? 2 : ($has_info ? 1 : 0));
|
||||
};
|
||||
|
||||
if ($pool_size > 1 && count($this->files_to_analyze) > $pool_size) {
|
||||
$process_file_paths = [];
|
||||
@ -458,11 +476,17 @@ class Analyzer
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<IssueData>
|
||||
*/
|
||||
private function getFileIssues(string $file_path): array
|
||||
{
|
||||
return array_filter(IssueBuffer::getIssuesData(), function (array $issue) use ($file_path): bool {
|
||||
return $issue['file_path'] === $file_path;
|
||||
});
|
||||
return array_filter(
|
||||
IssueBuffer::getIssuesData(),
|
||||
function (array $issue) use ($file_path): bool {
|
||||
return $issue['file_path'] === $file_path;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -5,7 +5,7 @@ class DefaultProgress extends LongProgress
|
||||
{
|
||||
const TOO_MANY_FILES = 1500;
|
||||
|
||||
public function taskDone(bool $successful): void
|
||||
public function taskDone(int $level): void
|
||||
{
|
||||
if ($this->number_of_tasks > self::TOO_MANY_FILES) {
|
||||
++$this->progress;
|
||||
@ -17,7 +17,7 @@ class DefaultProgress extends LongProgress
|
||||
|
||||
$this->write($inner_progress . ' ' . $this->getOverview() . "\r");
|
||||
} else {
|
||||
parent::taskDone($successful);
|
||||
parent::taskDone($level);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,11 +12,15 @@ class LongProgress extends Progress
|
||||
protected $progress = 0;
|
||||
|
||||
/** @var bool */
|
||||
protected $print_failures = false;
|
||||
protected $print_errors = false;
|
||||
|
||||
public function __construct(bool $print_failures = true)
|
||||
/** @var bool */
|
||||
protected $print_infos = false;
|
||||
|
||||
public function __construct(bool $print_errors = true, bool $print_infos = true)
|
||||
{
|
||||
$this->print_failures = $print_failures;
|
||||
$this->print_errors = $print_errors;
|
||||
$this->print_infos = $print_infos;
|
||||
}
|
||||
|
||||
public function startScanningFiles(): void
|
||||
@ -45,12 +49,14 @@ class LongProgress extends Progress
|
||||
$this->progress = 0;
|
||||
}
|
||||
|
||||
public function taskDone(bool $successful): void
|
||||
public function taskDone(int $level): void
|
||||
{
|
||||
if ($successful || !$this->print_failures) {
|
||||
if ($level === 0 || ($level === 1 && !$this->print_infos) || !$this->print_errors) {
|
||||
$this->write(self::doesTerminalSupportUtf8() ? '░' : '_');
|
||||
} elseif ($level === 1) {
|
||||
$this->write('I');
|
||||
} else {
|
||||
$this->write('F');
|
||||
$this->write('E');
|
||||
}
|
||||
|
||||
++$this->progress;
|
||||
|
@ -32,7 +32,7 @@ abstract class Progress
|
||||
{
|
||||
}
|
||||
|
||||
public function taskDone(bool $successful): void
|
||||
public function taskDone(int $level): void
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -505,7 +505,7 @@ if (isset($_SERVER['TRAVIS'])
|
||||
$debug = array_key_exists('debug', $options) || array_key_exists('debug-by-line', $options);
|
||||
$progress = $debug
|
||||
? new DebugProgress()
|
||||
: (isset($options['no-progress']) ? new VoidProgress() : new DefaultProgress(!$config->error_baseline));
|
||||
: (isset($options['no-progress']) ? new VoidProgress() : new DefaultProgress(!$config->error_baseline, $show_info));
|
||||
|
||||
if (isset($options['no-cache'])) {
|
||||
$providers = new Provider\Providers(
|
||||
|
Loading…
x
Reference in New Issue
Block a user