1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-26 20:34:47 +01:00
* Enable --diff mode by default

* Bump required version
This commit is contained in:
Matthew Brown 2020-10-18 23:28:05 -04:00 committed by Daniil Gentili
parent 481cf84b94
commit e11be08f89
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
5 changed files with 53 additions and 58 deletions

View File

@ -19,7 +19,7 @@ Psalm also has a few features to make it perform as well as possible on large co
Wherever possible Psalm will run its analysis in parallel to save time. Useful for large codebases, it has a massive impact on performance.
- **Incremental checks**<br />
When using the `--diff` command line option, Psalm will only analyse files that have changed *and* files that reference them.
By default Psalm only analyses files that have changed and files that reference those changed files.
## Example output

View File

@ -30,10 +30,11 @@ Psalm has a couple of command-line options that will result in faster builds:
- `--threads=[n]` to run Psalms analysis in a number of threads
- `--diff` which only checks files youve updated since the last run (and their dependents).
- `--diff-methods` which only checks methods youve updated since the last run (and their dependents).
In Psalm 4 `--diff` is turned on by default (you can disable it with `--no-diff`).
Data from the last run is stored in the *cache directory*, which may be set in [configuration](./configuration.md).
If you are running Psalm on a build server, you may want to configure the server to ensure that the cache directory
is preserved between runs.
Running them together (e.g. `--threads=8 --diff --diff-methods`) will result in the fastest possible Psalm run.
Running them together (e.g. `--threads=8 --diff`) will result in the fastest possible Psalm run.

View File

@ -1,6 +1,6 @@
# Installation
The latest version of Psalm requires PHP >= 7.1 and [Composer](https://getcomposer.org/).
The latest version of Psalm requires PHP >= 7.3 and [Composer](https://getcomposer.org/).
```bash
composer require --dev vimeo/psalm

View File

@ -317,8 +317,8 @@ Basic configuration:
--threads=INT
If greater than one, Psalm will run analysis on multiple threads, speeding things up.
--diff
Runs Psalm in diff mode, only checking files that have changed since last run (and their dependents)
--no-diff
Turns off Psalms diff mode, checks all files regardless of whether they've changed
--diff-methods
Only checks methods that have changed since last run (and their dependents)

View File

@ -83,7 +83,6 @@ $valid_long_options = [
'debug-performance',
'debug-emitted-issues',
'diff',
'diff-methods',
'disable-extension:',
'find-dead-code::',
'find-unused-code::',
@ -94,6 +93,7 @@ $valid_long_options = [
'init',
'memory-limit:',
'monochrome',
'no-diff',
'no-cache',
'no-reflection-cache',
'no-file-cache',
@ -483,7 +483,9 @@ $show_info = isset($options['show-info'])
? $options['show-info'] === 'true' || $options['show-info'] === '1'
: false;
$is_diff = isset($options['diff']);
$is_diff = !isset($options['no-diff'])
&& !isset($options['set-baseline'])
&& !isset($options['update-baseline']);
/** @var false|'always'|'auto' $find_unused_code */
$find_unused_code = false;
@ -680,9 +682,6 @@ if ($find_references_to) {
}
if (isset($options['set-baseline']) && is_string($options['set-baseline'])) {
if ($is_diff) {
fwrite(STDERR, 'Cannot set baseline in --diff mode' . PHP_EOL);
} else {
fwrite(STDERR, 'Writing error baseline to file...' . PHP_EOL);
ErrorBaseline::create(
@ -702,14 +701,10 @@ if (isset($options['set-baseline']) && is_string($options['set-baseline'])) {
fwrite(STDERR, PHP_EOL);
}
}
$issue_baseline = [];
if (isset($options['update-baseline'])) {
if ($is_diff) {
fwrite(STDERR, 'Cannot update baseline in --diff mode' . PHP_EOL);
} else {
$baselineFile = Config::getInstance()->error_baseline;
if (empty($baselineFile)) {
@ -742,7 +737,6 @@ if (isset($options['update-baseline'])) {
exit(1);
}
}
}
if (isset($options['use-baseline'])) {
if (!is_string($options['use-baseline'])) {