Skip to content
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

Can't get it to work installed globally #2

Closed
leewillis77 opened this issue Dec 9, 2016 · 6 comments
Closed

Can't get it to work installed globally #2

leewillis77 opened this issue Dec 9, 2016 · 6 comments
Labels

Comments

@leewillis77
Copy link

I have WordPress-VIP installed globally, and PHPCS can find it just fine:

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

If I then install this repo globally, e.g.

$ composer global require humanmade/coding-standards
[snipped]
$ phpcs --config-set installed_paths /Users/leewillis/.composer/vendor/wp-coding-standards/wpcs/,/Users/leewillis/.composer/vendor/humanmade/coding-standards/
Config value "installed_paths" added successfully

HM shows up as an available standard:

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

However - it's unusable:

$ phpcs --standard=HM foo.php 

Fatal error: Uncaught PHP_CodeSniffer_Exception: Referenced sniff "WordPress-VIP" does not exist in /Users/leewillis/.composer/vendor/squizlabs/php_codesniffer/CodeSniffer.php:1167
Stack trace:
#0 /Users/leewillis/.composer/vendor/squizlabs/php_codesniffer/CodeSniffer.php(780): PHP_CodeSniffer->_expandRulesetReference(Object(SimpleXMLElement), '/Users/leewilli...', 0)
#1 /Users/leewillis/.composer/vendor/squizlabs/php_codesniffer/CodeSniffer.php(578): PHP_CodeSniffer->processRuleset('/Users/leewilli...')
#2 /Users/leewillis/.composer/vendor/squizlabs/php_codesniffer/CodeSniffer/CLI.php(956): PHP_CodeSniffer->initStandard(Array, Array, Array)
#3 /Users/leewillis/.composer/vendor/squizlabs/php_codesniffer/CodeSniffer/CLI.php(113): PHP_CodeSniffer_CLI->process()
#4 /Users/leewillis/.composer/vendor/squizlabs/php_codesniffer/scripts/phpcs(25): PHP_CodeSniffer_CLI->runphpcs()
#5 {main}
  thrown in /Users/leewillis/.composer/vendor/squizlabs/php_codesniffer/CodeSniffer.php on line 1167

I think because of the clobbering of install paths done in HM/ruleset.xml, but not sure what the fix would be.

@rmccue
Copy link
Member

rmccue commented Dec 10, 2016

Right now, it's not usable as a globally-installed standard (and I believe @roborourke was running into the same). Need to put some work into this.

@aprea
Copy link

aprea commented Oct 4, 2017

Had the same issue as @leewillis77. I found that if I comment out:

<config name="installed_paths" value="vendor/wp-coding-standards/wpcs,vendor/fig-r/psr2r-sniffer" />

in HM/ruleset.xml everything worked perfectly.

I think because of the clobbering of install paths done in HM/ruleset.xml, but not sure what the fix would be.

☝️ looks like that was correct.

@joehoyle
Copy link
Member

joehoyle commented Sep 4, 2018

It seems both installed_paths and rule are relative to CWD, which is not what we want. I don't think phpcs allows you to specify arguments that are relative to the ruleset DIR

@ntwb
Copy link
Member

ntwb commented Sep 5, 2018

Possibly https://github.com/DealerDirect/phpcodesniffer-composer-installer might work to dynamically register the installed_paths based on the install location

@rmccue
Copy link
Member

rmccue commented Sep 5, 2018

Yeah, at the time I wrote that code, the manual installed_paths was the best practice, but I think phpcodesniffer-composer-installer is better these days. Just need to make sure it's compatible with WPCS too.

@rmccue
Copy link
Member

rmccue commented Mar 13, 2020

This should now be sorted as of #100.

@rmccue rmccue closed this as completed Mar 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants