WordPress / WordPress-Coding-Standards

PHP_CodeSniffer rules (sniffs) to enforce WordPress coding conventions
MIT License
2.55k stars 483 forks source link

Unable to add WordPress coding standard to PHPCS #224

Closed nixcms closed 10 years ago

nixcms commented 10 years ago

This repository was really helpful for me! But now I have an error connected with setting up WordPress coding standard! :bangbang: This code has worked before but not it is broken:

WordPress standard installation part

2014-08-21 11-52-21 travis ci - hosted continuous integration that just works - google chrome

WordPress standard usage part

2014-08-21 11-53-55 travis ci - hosted continuous integration that just works - google chrome

I think it could occur because of changes in your repository https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards

We couldn't add WordPress coding standard to PHPCS using this code:

- git clone git://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards.git $(pear config-get php_dir)/PHP/CodeSniffer/Standards/WordPress
- phpcs --config-set installed_paths $(pear config-get php_dir)/PHP/CodeSniffer/Standards/WordPress
- phpcs --config-set default_standard WordPress

We've tried this coding standard with these versions of the PHPCS:

## PHP_CodeSniffer
  - pear install PHP_CodeSniffer-2.0.0RC1
  - phpenv rehash

or

## PHP_CodeSniffer
  - pear install PHP_CodeSniffer
  - phpenv rehash

We've saved our previous WordPress standard as a temporary solution. It works for us now:

 # - git clone git://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards.git $(pear config-get php_dir)/PHP/CodeSniffer/Standards/WordPress
  - wget --no-check-certificate https://dl.dropboxusercontent.com/u/35151471/WordPressCodingStandards.zip
  - unzip WordPressCodingStandards.zip
  - mv WordPress $(pear config-get php_dir)/PHP/CodeSniffer/Standards/WordPress
  - rm -f WordPressCodingStandards.zip

  - phpcs --config-set installed_paths $(pear config-get php_dir)/PHP/CodeSniffer/Standards/WordPress
  - phpcs --config-set default_standard WordPress

  - phpenv rehash
  # PHPCS version
  - phpcs --version
  # Installed PHPCS coding standards
  - phpcs -i

Could anyone suggest what happened and how to fix it? I want use this repository regulary in order to get correct WordPress coding standards, but it is impossible now. Any help / advice is really appreciated! Thanx in advance!

Rarst commented 10 years ago

The reason is likely that structure now has multiple standards in subfolders.

Had you looked at updated how to use section? --config-set installed_paths is now (highly) recommended way to configure. It makes multiple standards play nicely and removes the need to put them inside PHPCS folder.

Impesud commented 10 years ago

Good Morning, I have the same problem too. I can not configure Wordpress Coding Standard in PHPCodeSniffer. Doing the commando 'phpcs -i' I can not see it.

I know that you have changed the folder structure, you give us a couple of practical examples to understand how it works now?

Thank you.

Rarst commented 10 years ago

Again, had you been through updated how to use section in readme? :)

PS I screwed up with link in comment above, oops, fixed

Impesud commented 10 years ago

'phpcs config-set installed_paths' in Windows is not working. screen

Rarst commented 10 years ago

Your screenshot shows you are trying to run it on pear, not phpcs?.. :)

Impesud commented 10 years ago

Sorry :D. The final solution in Windows is 'phpcs --config-set installed_paths ../wpcs'

Thanks you.

Rarst commented 10 years ago

Not sure if OP has it resolved as well?..

fulldecent commented 10 years ago

@nixcms Can you confirm this is working for you as well

GaryJones commented 10 years ago

My bad - didn't look closely enough at the names / icons.

Re-opening for confirmation.

nixcms commented 10 years ago

@fulldecent Yes, it works, @Rarst Thanks for the explanation.