Skip to content

Commit 04fd547

Browse files
committed
First commit based on John's earlier work
0 parents  commit 04fd547

15 files changed

+2215
-0
lines changed

README.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
### Wordpress Coding Standards for Codesniffer 1.3.0
2+
3+
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.
4+
5+
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][]
6+
7+
### How to use this
8+
9+
Once you've installed PEAR, install Codesniffer:
10+
11+
pear install --alldeps PHP_CodeSniffer
12+
13+
Then install Wordpress standards
14+
15+
pear install pear install http://github.com/mrchrisadams/PATH_TO_TARFILE.tar.gz
16+
17+
Then run the PHP code sniffer commandline tool on a given file, for
18+
example `wp-cron.php`
19+
20+
phpcs --standard=Wordpress -s wp-cron.php
21+
22+
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:
23+
24+
phpcs -p -s -v --standard=Wordpress .
25+
26+
Output will like this:
27+
28+
Registering sniffs in Wordpress standard... DONE (11 sniffs registered)
29+
Creating file list... DONE (705 files in queue)
30+
Processing index.php [47 tokens in 31 lines]... DONE in < 1 second (2 errors, 0 warnings)
31+
Processing wp-activate.php [750 tokens in 102 lines]... DONE in < 1 second (47 errors, 2 warnings)
32+
Processing admin-ajax.php [14523 tokens in 1475 lines]... DONE in 2 seconds (449 errors, 44 warnings)
33+
Processing admin-footer.php [183 tokens in 43 lines]... DONE in < 1 second (19 errors, 0 warnings)
34+
Processing admin-functions.php [43 tokens in 16 lines]... DONE in < 1 second (2 errors, 0 warnings)
35+
Processing admin-header.php [1619 tokens in 196 lines]... DONE in < 1 second (110 errors, 1 warnings)
36+
Processing admin-post.php [144 tokens in 33 lines]... DONE in < 1 second (8 errors, 0 warnings)
37+
Processing admin.php [1906 tokens in 238 lines]... DONE in 1 second (128 errors, 1 warnings)
38+
Processing async-upload.php [623 tokens in 70 lines]... DONE in < 1 second (41 errors, 0 warnings)
39+
Processing comment.php [2241 tokens in 289 lines]... DONE in < 1 second (110 errors, 3 warnings)
40+
Processing colors-classic-rtl.css [517 tokens in 1 lines]... DONE in < 1 second (0 errors, 0 warnings)
41+
Processing colors-classic-rtl.dev.css [661 tokens in 79 lines]... DONE in < 1 second (0 errors, 0 warnings)
42+
Processing colors-classic.css ^C
43+
44+
... and so on...
45+
46+
### Caveats
47+
48+
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.
49+
50+
[pear.php.net]: http://pear.php.net/manual/en/package.php.php-codesniffer.coding-standard-tutorial.php
51+
[Urban Giraffe]: http://urbangiraffe.com/articles/wordpress-codesniffer-standard/

0 commit comments

Comments
 (0)