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

[Feature proposal] Running Psalm with an error baseline #1042

Closed
ErikBooijCB opened this issue Oct 29, 2018 · 4 comments

Comments

Projects
None yet
2 participants
@ErikBooijCB
Copy link
Contributor

commented Oct 29, 2018

Hi! I have an idea for a feature that would help us a lot in implementing Psalm in our large, legacy codebase. The problem we currently face, is that running Psalm on the settings we would like, yields roughly ~4,000 errors (don't ask). Too much to fix at once and therefore a huge road block for making Psalm a blocking step in our CI.

The idea I have is to be able to initialize a baseline with existing errors and ignore those in processing the results. It would look something like this:

$ ./vendor/bin/psalm --set-baseline <filename>

It would generate and XML file (I'd prefer JSON, but to keep it in line with the configuration file) with the current errors. Running Psalm with the baseline would be:

$ ./vendor/bin/psalm --with-baseline <filename>

This would allow us to make Psalm blocking right away, while allowing us to work on these existing issues as time permits.

To be clear, I'm not asking you to build this, I would be putting in that effort, I just want to gauge if you'd be open to the feature, when the PR comes and if so, if you have any suggestions/tips I should keep in mind.

@muglug

This comment has been minimized.

Copy link
Member

commented Oct 29, 2018

First, this is a brilliant, amazing idea.

I foresee a file like

baseline.xml:

<files>
    <file name="src/A/B.php">
        <PossiblyUndefinedVariable />
    </file>
    <file name="src/A/C.php">
        <UndefinedThisPropertyFetch />
    </file>
</files>

All these issues show up as info when you run Psalm - you still see them, they don't go away, and if you use an LSP plugin you'll be able to see them in your editor.

Additionally when you run with --with-baseline Psalm will update the baseline file automatically when you remove issues in the files it covers. That allows for seamless code improvement.

@muglug

This comment has been minimized.

Copy link
Member

commented Oct 29, 2018

yields roughly ~4,000 errors (don't ask)

This is a shame-free zone! Also, when running on Vimeo's codebase:

------------------------------
1 errors found
------------------------------
19679 other issues found.
@ErikBooijCB

This comment has been minimized.

Copy link
Contributor Author

commented Oct 30, 2018

Awesome, thanks! Will be taking a look at it shortly and I'll either post issues I run into here, or if all is smooth, open a PR 👍

@ErikBooijCB

This comment has been minimized.

Copy link
Contributor Author

commented Nov 1, 2018

Merged in #1049

@ErikBooijCB ErikBooijCB closed this Nov 1, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.