psalm / psalm-vscode-plugin

VS Code plugin for Psalm
MIT License
44 stars 14 forks source link

Baseline getting ignored? #221

Closed mindriven closed 1 year ago

mindriven commented 1 year ago

First of all thank you for the plugin and psalm at large, really nice! I am trying to introduce it to a legacy code base in one of my teams that is using VScode. I have generated a baseline and when I am using psalm CLI it's obviously working - no errors anywhere. But VSCode still shows a lot of "problems". This makes me assume that baseline file is getting ignored. How can I ignore the VSCode "problems" that already captured in the baseline? image

tm1000 commented 1 year ago

Are they underlined in yellow?

kamil-posiadala-idnow commented 1 year ago

Are they underlined in yellow?

Some are warnings, some errors if that's what you're asking. And severity and count seems to be changing with changing level in settings file.

Edit: I'm the author of the issue, just now on mobile with another account.

tm1000 commented 1 year ago

The reason I ask is because most issues should be reported to the main repo. All this repo does is track the plug-in which really doesn't do much.

If you have a reproducible example and can go report it on the main repo then please do that. You can reference me there and they will assign it to me

mindriven commented 1 year ago

so I thought, thanks, to avoid confusion can you point me out to the right repo, then? Thanks in advance!

tm1000 commented 1 year ago

https://github.com/vimeo/psalm

tm1000 commented 1 year ago

Also are you 100% sure these are coming from psalm. Many of the other php extensions also report errors

mindriven commented 1 year ago

:-) sure as it gets, I have filtered using "psalm" as phrase. I will attempt so create a simple example repo to illustrate the problem... or find solution attempting to do so...

weirdan commented 1 year ago

Baseline does not hide issues completely, their severity is just lowered to INFO. And INFO issues are not shown by default by Psalm's cli tool (you can still display them by passing --show-info=true flag).

From what I see here those issues are reported to LSP client: https://github.com/vimeo/psalm/blob/bfce3a41e458efd92422a107c8d45f6b65707172/src/Psalm/Internal/LanguageServer/LanguageServer.php#L376-L384

@tm1000 is there an option to hide warnings from certain language servers, either in the extension or VSCode itself?

mindriven commented 1 year ago

My investigation suggests that @weirdan's suspicion is correct. I created this simple repository https://github.com/mindriven/vscode-psalm-testing

in VSCode it looks like this:

image

When executing vendor/bin/psalm I get:

Warning: "findUnusedBaselineEntry" will be defaulted to "true" in Psalm 6. You should explicitly enable or disable this setting.
Warning: "findUnusedCode" will be defaulted to "true" in Psalm 6. You should explicitly enable or disable this setting.
Target PHP version: 8.1 (inferred from current PHP version) Enabled extensions: .
Scanning files...
Analyzing files...

------------------------------

       No errors found!       

------------------------------
3 other issues found.
You can display them with --show-info=true
------------------------------

Checks took 0.00 seconds and used 4.563MB of memory
No files analyzed
Psalm was able to infer types for 0.0000% of the codebase

When I add --show-info=true I get:

Warning: "findUnusedBaselineEntry" will be defaulted to "true" in Psalm 6. You should explicitly enable or disable this setting.
Warning: "findUnusedCode" will be defaulted to "true" in Psalm 6. You should explicitly enable or disable this setting.
Target PHP version: 8.1 (inferred from current PHP version) Enabled extensions: .
Scanning files...
Analyzing files...

INFO: MixedAssignment - src/fileWithErrors.php:2:1 - Unable to determine the type that $a is being assigned to (see https://psalm.dev/032)
$a

INFO: UnusedVariable - src/fileWithErrors.php:2:1 - $a is never referenced or the value is not used (see https://psalm.dev/077)
$a

INFO: UndefinedGlobalVariable - src/fileWithErrors.php:2:6 - Cannot find referenced variable $something_that_does_not_exist in global scope (see https://psalm.dev/127)
$a = $something_that_does_not_exist

------------------------------

       No errors found!       

------------------------------
3 other issues found.
------------------------------

Checks took 0.01 seconds and used 4.564MB of memory
No files analyzed
Psalm was able to infer types for 0.0000% of the codebase

@tm1000 in this case, I would expect that "errors" should become "infos" image or if not possible to not be shown at all. This would make adoption in "challenging" codebase easier. What do you think?

mindriven commented 1 year ago

After reading a bit I understood that the link from @weirdan was actually pointing to the right place where this would need to be changed. I will open an issue there,

tm1000 commented 1 year ago

@weirdan The option is in my Wip pr

However this seems two-fold. I also need to implement finish instead of clear is that correct?

tm1000 commented 1 year ago

Closing as the work was done in: https://github.com/vimeo/psalm/pull/8960

Ref: https://github.com/vimeo/psalm/issues/9180