I've just uploaded the a new PHP_CodeSniffer release. RC2 is a bug-fix only release, although it does contain one tiny change to the test suite so it can be integrated more easily run by external testing scripts.
Please download and review. There are currently no bugs in the PHP_CodeSniffer bug tracker, so this will become the stable 1.2.0 unless any show-stoppers are found.
For those reporting problems with the SVN pre-commit hook on this blog, I've tested everything (including adding directories) and it is all working fine. If you have any problems, please report a bug using the PEAR bug tracker (no bug reports in comments please).
You can view the full changelog and download the release on the package download page.
Monday, 25 May 2009
PHP_CodeSniffer 1.2.0RC2 released
Posted by
Greg Sherwood
at
3:30 pm
Tags: PHP_CodeSniffer, svn
Thursday, 7 May 2009
Missing/Back in action
It's been about 2 months since my last post. A lot has been happening and I've been really busy. If I had posted over the last couple of months, the posts would have covered:
MySource Mini, MySource Mini and more MySource Mini. I've been so busy getting this product ready for launch that I've been almost completely consumed by it. It's a terrific product though and I'm very proud of we we've achieved. We had the launch last week (a great review here), had a great team dinner at Sydney Tower on the weekend to celebrate and are now busily preparing units for delivery. Along with that, I'm also working hard on the MySource Mini product website (running on a Mini of course) and getting the news out via Twitter.
Sadly, I've neglected PHP_CodeSniffer over the last few months as a result. The bug reports started piling up but I'm happy to report I'm getting on top of them now. I think there is currently one outstanding at the moment, which isn't too bad. Downloads of PHP_CodeSniffer have been through the roof over the last two months so I'll be putting out an RC2 soon for people to try out before the next stable release.
I'll start posting again soon. In the meantime, follow me on Twitter.
Posted by
Greg Sherwood
at
7:08 pm
Tags: MySource Mini, PHP_CodeSniffer, Twitter
Monday, 9 March 2009
PHP_CodeSniffer 1.2.0RC1 released
I was just looking at the download stats for PHP_CodeSniffer version 1.2.0alpha1. Normally, my alpha releases get a very small number of downloads due to most users not allowing alpha state packages to be installed via PEAR (fair enough). But the 1.2.0 alpha got over 300 downloads. That's a great figure and a few bugs were fixed from that testing, but there is a very good reason why there were so many downloads - I released it nearly 4 months ago.
To be honest, besides fixing the odd bug, I haven't been working on PHP_CodeSniffer lately. I'm very busy working on the MySource Mini and our coding standard seems to be nearing completion, so there is less work to be done there as well. But 1.2.0 is a good release with some great reporting improvements, so it's about time I released a beta version.
This release candidate is essentially a bug-fix only release, but please test it if you can so I can push it stable as soon as possible and start working on new features again.
You can view the full changelog and download the release on the package download page.
Posted by
Greg Sherwood
at
2:45 pm
Tags: PHP_CodeSniffer
Sunday, 4 January 2009
Seven Things - Tagged by Sebastian and Manuel
I've been tagged for this meme by Sebastian Bergmann and Manuel Pichler, so I can hardly ignore it now!
Seven things you may not know about me:
- I didn't even know how to code a table in HTML when I started as a web developer at Squiz.
- I didn't pick the name PHP_CodeSniffer. It was suggested by Pierre-Alain Joye (http://blog.thepimp.net) when I submitted "Snoopy" to PEAR.
- I'm slightly addicted to WoW, but I swear it's not my fault and my wife is addicted too, so it's not that bad.
- I've never been to a PHP conference or user group. I just can't ever seem to find the time, especially now with a 1 year old.
- I'm the main cook in the house, and I love it!
- I love cats and dogs and have had 5 dogs and 4 cats as pets so far.
- I don't have a Facebook account even though several people have tried to sign me up. One less thing to be addicted to.
And the seven lucky people I have picked to do this next are:
- Till Klampaeckel for being a PHP_CodeSniffer early adopter
- Pierre-Alain Joye for helping me get into the wonder that is PEAR
- Laurent Laville for helping me get PHP_CodeSniffer working on Windows
- Scott Kim because he codes PHP all day long and needs something to add to his blog
- Richard Hulse for convincing me Git is a great VCS, even if I haven't done anything about it
- Nathan de Vries because he's a smart guy with and without PHP
- Nic Hubbard for making his first contribution to a PHP open source project just recently
And here are the rules of the game:
- Link your original tagger(s), and list these rules on your blog.
- Share seven facts about yourself in the post - some random, some wierd.
- Tag seven people at the end of your post by leaving their names and the links to their blogs.
- Let them know they've been tagged by leaving a comment on their blogs and/or Twitter.
Posted by
Greg Sherwood
at
8:14 am
Tags: PEAR, PHP, PHP_CodeSniffer
Wednesday, 17 December 2008
PHPUnit training at Squiz
Sebastian Bergmann was in Sydney last week and I took the opportunity to have him come in and do a day of PHPUnit training for the developers at Squiz. We also went through continuous integration software like phpUnderControl and Bamboo.
It was great to finally meet Sebastian and learn a lot about the tools we will be using in MySource4 to ensure the quality of our product.
If you are thinking of some in-house PHP training, Sebastian is great tutor on all things testing and comes pre-loaded with some funny and informative stories about his travels and PHP development in general.
Posted by
Greg Sherwood
at
4:12 pm
Tags: MySource4, PHPUnit, Sebastian Bergmann
PHP_CodeSniffer reporting improvements
Spurred on by some feature requests and at least one annoying colleague (you know who you are), I've made some fairly good improvements to the way PHP_CodeSniffer reports the errors and warnings it finds. I've added support for the concept of error sources, allowing you to see which sniff generated an error and also filter out the messages for that sniff.
The XML, CSV and CheckStyle report formats all now include a source attribute in their output. This will allow continuous integration platforms to call PHP_CodeSniffer and produce a report of the most common errors rather than just display a list of all errors or the number of errors for each file.
You can also expose this information in the full and summary reports, although it is off by default to avoid clutter. Use the new command line argument -s to show sources in these reports. Instead of something like this:
FILE: /home/squiz/PHP_CodeSniffer/temp.phpYou get this:
--------------------------------------------------------------------------------
FOUND 6 ERROR(S) AND 0 WARNING(S) AFFECTING 5 LINE(S)
--------------------------------------------------------------------------------
2 | ERROR | Missing file doc comment
3 | ERROR | Object operator not indented correctly; expected 4 spaces but
| | found 0
3 | ERROR | Object operator must be at the start of the line, not the end
4 | ERROR | TRUE, FALSE and NULL must be lowercase; expected "true" but found
| | "TRUE"
6 | ERROR | Object operator not indented correctly; expected 4 spaces but
| | found 1
9 | ERROR | TRUE, FALSE and NULL must be lowercase; expected "false" but found
| | "FALSE"
--------------------------------------------------------------------------------
FILE: /home/squiz/PHP_CodeSniffer/temp.php
--------------------------------------------------------------------------------
FOUND 6 ERROR(S) AND 0 WARNING(S) AFFECTING 5 LINE(S)
--------------------------------------------------------------------------------
2 | ERROR | Missing file doc comment (PEAR.Commenting.FileComment)
3 | ERROR | Object operator not indented correctly; expected 4 spaces but
| | found 0 (PEAR.WhiteSpace.ObjectOperatorIndent)
3 | ERROR | Object operator must be at the start of the line, not the end
| | (PEAR.WhiteSpace.ObjectOperatorIndent)
4 | ERROR | TRUE, FALSE and NULL must be lowercase; expected "true" but found
| | "TRUE" (Generic.PHP.LowerCaseConstant)
6 | ERROR | Object operator not indented correctly; expected 4 spaces but
| | found 1 (PEAR.WhiteSpace.ObjectOperatorIndent)
9 | ERROR | TRUE, FALSE and NULL must be lowercase; expected "false" but found
| | "FALSE" (Generic.PHP.LowerCaseConstant)
--------------------------------------------------------------------------------
There is also a totally new report format that shows a summary of your error sources. You use the command line argument --report=source to print a report like this:
PHP CODE SNIFFER VIOLATION SOURCE SUMMARYYou can also get it to use official source names using the -s command line argument:
------------------------------------------------------------
STANDARD CATEGORY SNIFF COUNT
------------------------------------------------------------
PEAR White space Object operator indent 3
Generic PHP Lower case constant 2
PEAR Commenting File comment 1
------------------------------------------------------------
A TOTAL OF 6 SNIFF VIOLATION(S) WERE FOUND IN 3 SOURCE(S)
------------------------------------------------------------
PHP CODE SNIFFER VIOLATION SOURCE SUMMARY
------------------------------------------------------------
SOURCE COUNT
------------------------------------------------------------
PEAR.WhiteSpace.ObjectOperatorIndent 3
Generic.PHP.LowerCaseConstant 2
PEAR.Commenting.FileComment 1
------------------------------------------------------------
A TOTAL OF 6 SNIFF VIOLATION(S) WERE FOUND IN 3 SOURCE(S)
------------------------------------------------------------
The idea with these source IDs is that you can then use them to filter your (potentially) long list of error messages and target a particular rule that you want to fix all in one go. So in this report, we have 3 errors generated from PEAR.WhiteSpace.ObjectOperatorIndent. To find out what they are, add the command line argument --sniffs=PEAR.WhiteSpace.ObjectOperatorIndent to get this:
FILE: /home/squiz/PHP_CodeSniffer/temp.php
--------------------------------------------------------------------------------
FOUND 3 ERROR(S) AND 0 WARNING(S) AFFECTING 2 LINE(S)
--------------------------------------------------------------------------------
3 | ERROR | Object operator not indented correctly; expected 4 spaces but
| | found 0
3 | ERROR | Object operator must be at the start of the line, not the end
6 | ERROR | Object operator not indented correctly; expected 4 spaces but
| | found 1
--------------------------------------------------------------------------------
Another related feature that was added is the ability to write the report output to a file in addition to writing it to the screen. This solves the problem where PHP_CodeSniffer comes across some code it cannot parse and throws PHP notices before XML output, creating invalid XML. Writing to a file is easy; just use the --report-file=filename command line argument.
All these features are currently in CVS and will be released in 1.2.0a1 very soon.
Posted by
Greg Sherwood
at
3:25 pm
Wednesday, 12 November 2008
PHP_CodeSniffer and JSLint
PHP_CodeSniffer has had integration with JavaScript Lint for a while, but I recently found out that the excellent online JavaScript verifier, JSLint, can be run from the command line using Rhino.
I've just committed the JSLint sniff into the Squiz standard under the Debug category. The sniff requires you to have jslint.js on your server and rhino installed on the same machine as PHP_CodeSniffer and you need to tell PHP_CodeSniffer where to find it.
$ phpcs --config-set jslint_path /path/to/jslint.jsLike JavaScript Lint, not all errors and warnings need fixing, so all messages reported by jslint.js are warnings within PHP_CodeSniffer and can be hidden easily.
$ phpcs --config-set rhino_path /path/to/rhino
$ phpcs --standard=squiz /path/to/file.js
Posted by
Greg Sherwood
at
4:14 pm
Tags: jslint, PHP_CodeSniffer
