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

@psalm-suppress with misspelled/non-existing issue #6120

Open
caugner opened this issue Jul 16, 2021 · 5 comments
Open

@psalm-suppress with misspelled/non-existing issue #6120

caugner opened this issue Jul 16, 2021 · 5 comments

Comments

@caugner
Copy link
Contributor

caugner commented Jul 16, 2021

I would expect that the following causes an error:

/**
 * @psalm-suppress NonExistingIssue
 */

https://psalm.dev/r/621dbf177f

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/621dbf177f
<?php

/**
 * @psalm-suppress NonExistingIssue
 */
Psalm output (using commit f015c30):

No issues!

@bdsl
Copy link
Contributor

bdsl commented Jul 16, 2021

@caugner I'm not sure. Doesn't allowing @psalm-suppress NonExistingIssue provide a useful upgrade path, for upgrading Psalm to a new version that can detect NonExistingIssue in a large codebase.

If you don't want to use baselining and you can't fix all the NonExistingIssues at once you'd need to suppress them. If there are many and you're doing trunk based development and wanting to do small commits you might want to first test out the new version of Psalm to find the issues locally, and then suppress the issues in batches, pushing to CI at each step, and only commit the Psalm upgrade later.

@caugner
Copy link
Contributor Author

caugner commented Jul 16, 2021

In a large codebase, you will definitely want to use a baseline, or at least suppress issues globally or per directory. I would recommend to create a branch, update psalm there, and add all the required @psalm-suppress until CI passes, while continuously rebasing on your "trunk". For that scenario, you will more likely want a psalm --alter command that just adds all those @psalm-suppress annotations automatically. But baselining is still way better, because it doesn't pollute the VCS history for all those affected files. For a very large codebase, you will likely want different configs per module/package.

Note that Psalm config has a findUnusedPsalmSuppress option, and even if that is enabled, Psalm doesn't find @psalm-suppress annotations with invalid issue names.

@weirdan
Copy link
Collaborator

weirdan commented Jul 16, 2021

I don't think this can be done currently as those unknown issues may refer to descendants of PluginIssue, provided by plugins. Currently Psalm doesn't have full list of issues that could be emitted. Fixing that would require plugins to register all custom issues, so it can only be done in a major version.

@bdsl
Copy link
Contributor

bdsl commented Jul 16, 2021

I don't have a strong feeling about this - it's hard to imagine a scenario where a new psalm version introduces so many new issues that it would be really uncomfortable to keep a branch open long enough to add all the suppress tags, even if doing trunk based. And I agree adding them to the baseline is potentially better than adding @suppress tags - even more so if #5831 is implemented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants