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

Unable to set WP standards along side Drupal standards #1320

Closed
paulcanning opened this issue Mar 1, 2018 · 10 comments
Closed

Unable to set WP standards along side Drupal standards #1320

paulcanning opened this issue Mar 1, 2018 · 10 comments

Comments

@paulcanning
Copy link

I am struggling to install both WP standards and Drupals (extracted from the Coder module)

They live in two different folders, so I am doing the following:

phpcs --config-set installed_paths ~/A_Folder/wpcs,~/Another_Folder/coder/coder_sniffer

When I do phpcs -i I get:

PHP Fatal error: Uncaught UnexpectedValueException: DirectoryIterator::__construct(/Another_Folder/coder/coder_sniffer): failed to open dir: No such file or directory in /usr/local/Cellar/php71/7.1.8_20/lib/php/PHP/CodeSniffer.php:2250
Stack trace:
#0 /usr/local/Cellar/php71/7.1.8_20/lib/php/PHP/CodeSniffer.php(2250): DirectoryIterator->__construct('
/Another_Folder/code...')
#1 /usr/local/Cellar/php71/7.1.8_20/lib/php/PHP/CodeSniffer/CLI.php(1404): PHP_CodeSniffer::getInstalledStandards()
#2 /usr/local/Cellar/php71/7.1.8_20/lib/php/PHP/CodeSniffer/CLI.php(495): PHP_CodeSniffer_CLI->printInstalledStandards()
#3 /usr/local/Cellar/php71/7.1.8_20/lib/php/PHP/CodeSniffer/CLI.php(468): PHP_CodeSniffer_CLI->processShortArgument('i', 0)
#4 /usr/local/Cellar/php71/7.1.8_20/lib/php/PHP/CodeSniffer/CLI.php(403): PHP_CodeSniffer_CLI->setCommandLineValues(Array)
#5 /usr/local/Cellar/php71/7.1.8_20/lib/php/PHP/CodeSniffer/CLI.php(911): PHP_CodeSniffer_CLI->getCommandLineValues()
#6 /usr/local/Cellar/php71/7.1.8_20/lib/php/PHP/CodeSniffer/CLI.php(113 in /usr/local/Cellar/php71/7.1.8_20/lib/php/PHP/CodeSniffer.php on line 2250

I can set either individually, but not both!

I also can't seem ot set one, and then use phpcs --standard=path/to/standard path/to/file - it simply states the standard isn't installed.

@jrfnl
Copy link
Member

jrfnl commented Mar 1, 2018

That's a new one.

Ok, first off, before I can even begin to answer this, I need more information:

  • Am I correct in that you are using PHP 7.1.8 ?
  • What version of PHPCS are you using ?
  • What version of WPCS are you using ?
  • Where can I find a copy of the Drupal coding standard you are using to run some tests myself ?

@jrfnl
Copy link
Member

jrfnl commented Mar 1, 2018

Ok, so I've found the git repo for Coder, cloned it and added it to my installed_paths and phpcs -i works fine, both when using PHPCS 2.x as well as 3.x (both latest versions).
To run the Drupal standards, I switched PHPCS to 2.x as the Drupal standards are not compatible with PHPCS 3.x yet, ran both the Drupal standards against a random file and both work fine without any exceptions or fatal errors.

So... please provide detailed steps on how to reproduce the error you are getting, as otherwise, there nothing I can do to help.

@paulcanning
Copy link
Author

PHP 7.1.8, PHPCS 2.9.1, WPCS 0.13.1

@jrfnl
Copy link
Member

jrfnl commented Mar 2, 2018

Tried with that same combination, again working fine.

Without detailed steps to reproduce, there's nothing I can do.

@paulcanning
Copy link
Author

Can you show how you added the two standards?

@jrfnl
Copy link
Member

jrfnl commented Mar 2, 2018

I cheated - I just edited the CodeSniffer.conf file in the root of my PHPCS install. I got quite a large number of standards installed, so manually typing all the paths in on the command line gets tiresome ;-)

The effect is the same (--installed-paths writes to the CodeSniffer.conf file).

@jrfnl
Copy link
Member

jrfnl commented Mar 6, 2018

@paulcanning Just checking - did you get it working ? And if so, how ? (for other people who come across the issue)

@paulcanning
Copy link
Author

@jrfnl I have not looked at it since sorry, other things have taken priority. I might try going your route and editing the conf file. Could you provide an example of yours?

@jrfnl
Copy link
Member

jrfnl commented Mar 6, 2018

@paulcanning No worries, just checking.

This is what my CodeSniffer.conf file looks like (paths adjusted to protect the innocent - oh and based on Windows as you can see):

<?php
$phpCodeSnifferConfig = array (
  'installed_paths' => 'X:/path/to/PHPCS/WordPress,X:/path/to/PHPCS/PHPCompatibility,X:/path/to/PHPCS/QA-WP-Projects,X:/path/to/PHPCS/DrupalCoder/coder_sniffer',
  'report_width' => '90',
)
?>

@jrfnl
Copy link
Member

jrfnl commented Jun 9, 2018

@paulcanning Did you get this working ? Can the issue be closed ?

@jrfnl jrfnl closed this as completed Jun 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants