Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added documentation for baseline files #7429

Merged
merged 3 commits into from Jan 19, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 27 additions & 1 deletion docs/running_psalm/dealing_with_code_issues.md
Expand Up @@ -99,14 +99,40 @@ If you have a bunch of errors and you don't want to fix them all at once, Psalm
vendor/bin/psalm --set-baseline=your-baseline.xml
```

will generate a file containing the current errors. You can commit that generated file so that Psalm running in other places (e.g. CI) won't complain about those errors either, and you can update that baseline file (to remove references to things that have been fixed) with
will generate a file containing the current errors. You should commit that generated file so that Psalm can use it when running in other places (e.g. CI). It won't complain about those errors either.

You have two options to use the generated baseline when running psalm:

```
vendor/bin/psalm --use-baseline=your-baseline.xml
```

or using the configuration:

```xml
<?xml version="1.0"?>
<psalm
...
errorBaseline="./path/to/your-baseline.xml"
>
...
</psalm>
```

To update that baseline file (to remove references to things that have been fixed), use
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be great to explain here that --update-baseline won't add new errors in the baseline. For that, --set-baseline=... should be used


```
vendor/bin/psalm --update-baseline
```

Baseline files are a great way to gradually improve a codebase.

In case you want to run psalm without the baseline, run

```
vendor/bin/psalm --ignore-baseline
```

## Using a plugin

If you want something more custom, like suppressing a certain type of error on classes that implement a particular interface, you can use a plugin that implements `AfterClassLikeVisitInterface`
Expand Down