ObliviousHarmony / vscode-php-codesniffer

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

ERROR: You must supply at least one file or directory to process #53

Closed CubeRanch closed 1 year ago

CubeRanch commented 2 years ago

Description

Using PHP_CodeSniffer on Windows.

phpcs is installed globally by Composer in: C:\Users\User\AppData\Roaming\Composer\vendor\bin\phpcs

The C:\Users\User\AppData\Roaming\Composer\vendor\bin directory is in my PATH.

Running phpcs --version in VS Code's terminal returns: PHP_CodeSniffer version 3.7.1 (stable) by Squiz (http://www.squiz.net)

That path, with the .bat extension added to phpcs, is in the GUI Settings field: PHP Code Sniffer: Executable PHP Code Sniffer: Lint Action is set to "Change".

Making a change in a PHP document, or calling Format Document outputs this: "[2022-8-3 22:3624]: ERROR: You must supply at least one file or directory to process.

Run "phpcs --help" for usage information"

Also, a PHP_CodeSniffer message pops up: "The PHPCS worker encountered an error."

Reproduction Steps

  1. Go to any PHP file
  2. Make a change or attempt to format the document
  3. See the errors in the Output tab

Expected Behavior

The file linted and formatted.

Any idea what's going on?

Regards

ObliviousHarmony commented 2 years ago

Interesting @CubeRanch.

My guess would be that something is going wrong with the passing of input to PHPCS on Windows. I don't really have a convenient way to replicate this. I use WSL2 whenever I'm developing on Windows.

This issue highlights to me a need for integration tests that run PHPCS against dummy files and validates the parsed reports. We can then use a GitHub Workflow to run them against Windows, macOS, and Ubuntu. That would make issues here very obvious and let us deepens platform support.

I'm sorry that I can't be more help! I'll try to write these tests within the next few weeks and then hopefully solve this issue. We are going to be welcoming our second child this weekend and I'll be a little busy 🙂

CubeRanch commented 2 years ago

No worries.

Priorities, man. Congratulations.

If there's anything I can test for you, let me know.

ObliviousHarmony commented 2 years ago

Thanks @CubeRanch, I don't think there is! I poked a bit at the Node documentation and it looks like using spawn on batch file has interesting complications. There's a good chance the solution will be spawning the worker a little differently on Windows.

Feel free to submit a PR if you want to take a swing at writing some integration tests or trying to solve it. This is an open source project after all :)

ObliviousHarmony commented 1 year ago

Hi @CubeRanch,

I just wanted to let you know that I've released a new version resolving bugs with running PHPCS natively in Windows. You should no longer experience any problems.