Skip to content

Commit

Permalink
First commit based on John's earlier work
Browse files Browse the repository at this point in the history
  • Loading branch information
mrchrisadams committed May 2, 2011
0 parents commit 04fd547
Show file tree
Hide file tree
Showing 15 changed files with 2,215 additions and 0 deletions.
51 changes: 51 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
### Wordpress Coding Standards for Codesniffer 1.3.0

This is an version of the Coding Standards available at [Urban Giraffe][], which were missing a `ruleset.xml` file, that stopped them being detected when I downloaded them and tried passing some Wordpress core code through them.

I know very little about Codesniffer beyond what I picked up in the last hour or two of reading the docs but I'm aiming to find a happy medium between letting developers stay productive, but stopping really shocking code being committed on projects, and me stumbling through this CodeSniffer tutorial here on [pear.php.net][]

### How to use this

Once you've installed PEAR, install Codesniffer:

pear install --alldeps PHP_CodeSniffer

Then install Wordpress standards

pear install pear install http://github.com/mrchrisadams/PATH_TO_TARFILE.tar.gz

Then run the PHP code sniffer commandline tool on a given file, for
example `wp-cron.php`

phpcs --standard=Wordpress -s wp-cron.php

You can use this to sniff individual files, or use different flags to recursively scan all the directories in a project. This command will show you each file it's scanning, and how many errors it's finding:

phpcs -p -s -v --standard=Wordpress .

Output will like this:

Registering sniffs in Wordpress standard... DONE (11 sniffs registered)
Creating file list... DONE (705 files in queue)
Processing index.php [47 tokens in 31 lines]... DONE in < 1 second (2 errors, 0 warnings)
Processing wp-activate.php [750 tokens in 102 lines]... DONE in < 1 second (47 errors, 2 warnings)
Processing admin-ajax.php [14523 tokens in 1475 lines]... DONE in 2 seconds (449 errors, 44 warnings)
Processing admin-footer.php [183 tokens in 43 lines]... DONE in < 1 second (19 errors, 0 warnings)
Processing admin-functions.php [43 tokens in 16 lines]... DONE in < 1 second (2 errors, 0 warnings)
Processing admin-header.php [1619 tokens in 196 lines]... DONE in < 1 second (110 errors, 1 warnings)
Processing admin-post.php [144 tokens in 33 lines]... DONE in < 1 second (8 errors, 0 warnings)
Processing admin.php [1906 tokens in 238 lines]... DONE in 1 second (128 errors, 1 warnings)
Processing async-upload.php [623 tokens in 70 lines]... DONE in < 1 second (41 errors, 0 warnings)
Processing comment.php [2241 tokens in 289 lines]... DONE in < 1 second (110 errors, 3 warnings)
Processing colors-classic-rtl.css [517 tokens in 1 lines]... DONE in < 1 second (0 errors, 0 warnings)
Processing colors-classic-rtl.dev.css [661 tokens in 79 lines]... DONE in < 1 second (0 errors, 0 warnings)
Processing colors-classic.css ^C

... and so on...

### Caveats

Right now, this standard is so pedantic it's almost useless. Over the coming weeks, I'm hoping to work out how to make it more reasonable, so can serve a useful purpose on future coding projects.

[pear.php.net]: http://pear.php.net/manual/en/package.php.php-codesniffer.coding-standard-tutorial.php
[Urban Giraffe]: http://urbangiraffe.com/articles/wordpress-codesniffer-standard/
Loading

0 comments on commit 04fd547

Please sign in to comment.