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
Allow suppressing UnusedPsalmSuppress, remove unused suppressions. #7133
Conversation
It looks like the CI workflow doesn't run psalm on itself on Windows 🙁 |
Here's the report when running psalm on your branch on windows:
|
Well that's interesting, I'll have to look into why that didn't show up anywhere else. |
Yeah, pretty weird in fact. This is my personal machine I always use when working on Psalm and I never saw this error before, so it's likely something to do with your changes |
It looks like it's because psalm infers it to |
This one is also weird:
Do some of these show up when running on master as well? Maybe it would be worthwhile to add a psalm run on Windows to the CI workflow. |
I added back the suppressions that seem related to this issue, I think the other issues from the Windows run are all preexisting. |
As I said, I run psalm on itself on windows very often. I just ran it on master and there is no errors. This is very likely something do do with your changes. That may have triggered a bug somewhere? |
Just ran it again with your changes I only have a single error left:
I guess fixing/suppressing errors fixed the weird cases we saw |
That's very odd. Do you normally clear the psalm cache before running it? That's caught me a few times, although I'm not sure how that could cause these issues I think the cache has some bugs hidden in it, but I've never taken the time to put together a simple reproducer. |
I always run psalm with --no-cache. Changing psalm itself leads to weird bug with cache indeed. Also, I just cloned the repo so I don't think cache could have been reused from my main Psalm repo. Nice catch about composer. I guess our lock file is out of date... |
@@ -186,8 +187,12 @@ public function analyze( | |||
$project_analyzer = $this->getProjectAnalyzer(); | |||
|
|||
if ($codebase->track_unused_suppressions && !isset($storage->suppressed_issues[0])) { | |||
foreach ($storage->suppressed_issues as $offset => $issue_name) { | |||
IssueBuffer::addUnusedSuppression($this->getFilePath(), $offset, $issue_name); | |||
if (count($storage->suppressed_issues) === 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mind explaining what this condition does?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's there so /** @psalm-suppress UnusedPsalmSuppress */
still shows up as an unused suppression. I could have done array_values($storage->suppressed_issues) === ["UnusedPsalmSuppress"]
but I figured this is both faster, shorter, and allows other cases to early out as well. Should I add a comment there so it's a bit more obvious?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh! Yes please, it wasn't immediately obvious to me and I had the context :p
But yeah, I see what this does now, thanks!
Thanks! |
No description provided.