Skip to content

Commit

Permalink
Merge pull request #10688 from robchett/suppress_scanning_output_in_ci
Browse files Browse the repository at this point in the history
  • Loading branch information
weirdan committed Feb 10, 2024
2 parents c03a8a0 + 80f443c commit 6b27a6d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/Psalm/Internal/Cli/Psalm.php
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ public static function run(array $argv): void

$threads = self::detectThreads($options, $config, $in_ci);

$progress = self::initProgress($options, $config);
$progress = self::initProgress($options, $config, $in_ci);

self::restart($options, $threads, $progress);

Expand Down Expand Up @@ -583,7 +583,7 @@ private static function loadConfig(
return $config;
}

private static function initProgress(array $options, Config $config): Progress
private static function initProgress(array $options, Config $config, bool $in_ci): Progress
{
$debug = array_key_exists('debug', $options) || array_key_exists('debug-by-line', $options);

Expand All @@ -598,9 +598,9 @@ private static function initProgress(array $options, Config $config): Progress
} else {
$show_errors = !$config->error_baseline || isset($options['ignore-baseline']);
if (isset($options['long-progress'])) {
$progress = new LongProgress($show_errors, $show_info);
$progress = new LongProgress($show_errors, $show_info, $in_ci);
} else {
$progress = new DefaultProgress($show_errors, $show_info);
$progress = new DefaultProgress($show_errors, $show_info, $in_ci);
}
}
// output buffered warnings
Expand Down
12 changes: 9 additions & 3 deletions src/Psalm/Progress/LongProgress.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,17 @@ class LongProgress extends Progress

protected bool $fixed_size = false;

public function __construct(protected bool $print_errors = true, protected bool $print_infos = true)
{
public function __construct(
protected bool $print_errors = true,
protected bool $print_infos = true,
protected bool $in_ci = false,
) {
}

public function startScanningFiles(): void
{
$this->fixed_size = false;
$this->write("\n" . 'Scanning files...' . "\n\n");
$this->write("\n" . 'Scanning files...' . ($this->in_ci ? '' : "\n\n"));
}

public function startAnalyzingFiles(): void
Expand Down Expand Up @@ -70,6 +73,9 @@ public function taskDone(int $level): void
++$this->progress;

if (!$this->fixed_size) {
if ($this->in_ci) {
return;
}
if ($this->progress == 1 || $this->progress == $this->number_of_tasks || $this->progress % 10 == 0) {
$this->write(sprintf(
"\r%s / %s...",
Expand Down

0 comments on commit 6b27a6d

Please sign in to comment.