Skip to content

Commit

Permalink
Alter order of precedence and upated docs to match
Browse files Browse the repository at this point in the history
  • Loading branch information
M1ke committed Jan 20, 2022
1 parent 06aafa7 commit 6107148
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 15 deletions.
3 changes: 1 addition & 2 deletions docs/running_psalm/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -402,8 +402,7 @@ Allows you to hard-code a serializer for Psalm to use when caching data. By defa
threads="[int]"
>
```
Allows you to hard-code the number of threads Psalm will use (similar to `--threads` on the command line). This value will only be applied if it is lower than the number of threads Psalm would natively use (i.e. you cannot override other settings that force threads=1 or utilise more threads than detected on the machine)

Allows you to hard-code the number of threads Psalm will use (similar to `--threads` on the command line). This value will be used in place of detecting threads from the host machine, but will be overridden by using `--threads` or `--debug` (which sets threads to 1) on the command line

## Project settings

Expand Down
17 changes: 4 additions & 13 deletions src/Psalm/Internal/Cli/Psalm.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ public static function run(array $argv): void
$options['long-progress'] = true;
}

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

self::emitMacPcreWarning($options, $threads);

Expand Down Expand Up @@ -913,12 +913,14 @@ private static function restart(array $options, Config $config, int $threads): v
}
}

private static function detectThreads(array $options, bool $in_ci): int
private static function detectThreads(array $options, Config $config, bool $in_ci): int
{
if (isset($options['threads'])) {
$threads = (int)$options['threads'];
} elseif (isset($options['debug']) || $in_ci) {
$threads = 1;
} elseif ($config->threads) {
$threads = $config->threads;
} else {
$threads = max(1, ProjectAnalyzer::getCpuCount() - 1);
}
Expand Down Expand Up @@ -1337,15 +1339,4 @@ private static function getHelpText(): string
HELP;
}

private static function useThreads(array $options, bool $in_ci, Config $config): int
{
$threads = self::detectThreads($options, $in_ci);

if ($config->threads && $config->threads<$threads) {
$threads = $config->threads;
}

return $threads;
}
}

0 comments on commit 6107148

Please sign in to comment.