ObliviousHarmony / vscode-php-codesniffer

A VS Code extension for integrating PHP_CodeSniffer.
https://marketplace.visualstudio.com/items?itemName=obliviousharmony.vscode-php-codesniffer
Other
40 stars 2 forks source link

Stubs File Linting Errors #98

Open ObliviousHarmony opened 2 months ago

ObliviousHarmony commented 2 months ago

Description

Despite being excluded via **/node_modules/**, this error appears:

Failed to locate a PHPCS configuration file for "/Users/obliviousharmony/.vscode/extensions/bmewburn.vscode-intelephense-client-1.12.4/node_modules/intelephense/lib/stub/standard/standard_9.php".

Reproduction Steps

  1. Use Intelephense
  2. Navigate to source, in my case, using CMD + Left Click on a function like array_intersect().

Expected Behavior

There should be no error. This might indicate a deeper problem with config file resolution for excluded files but that's just a theory.

ObliviousHarmony commented 1 month ago

I spent a little bit of time on this and it seems that Configuration::traverseWorkspaceFolders() indicates that it'll only traverse to the workspace folder. This doesn't work for files outside of the workspace and it'll traverse to the filesystem root. As a consequence, it'll give some errors.

I'd like to say it's just a matter of excluding files from outside of the workspace but I'm pretty sure that'll break the extension when opening it on single files with a global configuration. I'll need to look into how VS Code handles files outside of the workspace (does it create a new workspace for that file or is it not part of a workspace?)

Aside from that, the errors that the extension throws are really obtrusive. It sometimes hijacks the editor to focus on the terminal output and spams little prompts that the extension encountered an error. We should probably only be erroring if the user should have rightfully expected linting to work and it didn't. For instance, provide a diagnostic error for the whole document indicating that it wasn't able to lint it?

This can be handled using ignore patterns for now so I'll leave it be for now.