ikappas / vscode-phpcs

PHP CodeSniffer for Visual Studio Code
MIT License
128 stars 56 forks source link

when phpcs.standard is using custom CS, it should use global phpcs #80

Closed LC43 closed 5 years ago

LC43 commented 6 years ago

I usually work with a custom coding standard, GoodOmens.

    "phpcs.standard": "GoodOmens",

When working on a project is using a custom phpcs.xml for coding standard B, vscode-phpcs complains that it can't find it.

i suspect its because vscode-phpcs uses ./vendor/bin/phpcs

$./vendor/bin/phpcs -i
The installed coding standards are PSR2, PSR1, Zend, PEAR, MySource, PHPCS, Squiz, PHPCompatibility, WordPress-Extra, WordPress-VIP, WordPress-Core, WordPress-Docs and WordPress

if i enter the project directory and run phpcs, our CS is there.

$phpcs -i
The installed coding standards are MySource, PEAR, PHPCS, PSR1, PSR2, Squiz, Zend, WordPress-Extra, WordPress-VIP, WordPress-Core, WordPress-Docs, WordPress and GoodOmens

Other projects that either use a phpcs.xml with our CS, or have none, the vscode-phpcs works perfectly.

At least, i wouldn't mind having the warning once, but never repeatly show it on every save or new file open.

A solution would to have a flag, and in this line, check if the message has been displayed once already.

https://github.com/ikappas/vscode-phpcs/blob/f18e40713bae56316c768b2d1c44112f13350342/phpcs-server/src/linter.ts#L426

ikappas commented 6 years ago

@LC43 Thank you for your feedback. Is there a reason why you can't install the missing standard at the required level (system-wide/project-wide). Also now that vscode-phpcs 1.0.0 is out you can configure the phpcs.executablePath at user/workspace/folder settings.

LC43 commented 6 years ago

Hello @ikappas , thanks for looking into this!

well, I can't use our Coding Standard on other projects because they use their own, and sometimes they are contradictory.

For example:

I have to edit the vscode settings to set it to PSR2 just while i'm working on, so the Warning banner isn't always popping up.

I'll look into the new setting, to see if i can work around.

ikappas commented 6 years ago

@LC43 Also please note that per your description you may need to disable phpcs.autoConfigSearch to manually override the ruleset used.

ikappas commented 6 years ago

@LC43 Did you manage to resolve your issues?

LC43 commented 5 years ago

@ikappas , sorry missed the notification on this.

yes, with workspace settings i was able to work around it, thanks.