Code style checker for Dojo
Posted by Shane O'Sullivan on May 23, 2009
I’ve added a code style tool to the Dojo Util project that developers can use to ensure that their code is following the syle guidelines published here -http://www.dojotoolkit.org/developer/StyleGuide .
You can see the current report, as of May 23rd 2009 at http://skynet.ie/~sos/misc/dojoCheckstyle/util/checkstyle/checkstyleReport.html
It can be very difficult to police your own code for tabs and spaces, and developers have much better things to be doing with their time than visually scanning over their code making sure that it is formatted correctly.
This tool identifies style guide violations, and gives developers a HTML file that displays them, and automatically fixes many of the common mistakes for you. (This works best in Firefox right now, so you that if you have it)
The style checker is primarily aimed at Dojo contributors, but can also be used by normal users of the toolkit. To override the standard folders that are examined, you can simply set the ‘dir‘ parameter relative to the Dojo base folder, and a checkstyle report will be generated for you custom code.
To see how to use the tool, get the latest vode from svn, the go to util/checkstyle and type
checkstyle.bat help
To run the checkstyle tool on the entire Dojo tree, simply type
checkstyle.bat
then open the checkstyleReport.html file, which you can see below.
If you want to be able to save files from the web interface, you’ll have to renamve the file checkstyle.php.rename.html to checkstyle.php, then click the Save or Save All buttons in the UI.
There is a ticket to track all checkstyle fixes at http://bugs.dojotoolkit.org/ticket/7390 , so can developers please reference this when checking in style fixes?


Nathan Toone said
When I try to run it from the latest svn, I get:
js: Couldn’t open file “checkstyle.js”.
Any ideas?
Nathan Toone said
I got it fixed – nevermind.
Shane O'Sullivan said
cool, thanks for that.
Meh, this is Eh. » Blog Archive » How Can I Get The Php Code From An Online Php File? said
[...] Code style checker for Dojo « SOS [...]
Nathan Toone said
Just a question – what is the reasoning for requiring the renaming of the php file to save back? Why not just check the php file in directly?
Shane O'Sullivan said
It’s a security measure. Given that the PHP file writes directly onto the file system, if people accidentally stuck the util project up on the web, anyone would be able to write files to their system.
Not the most secure thing in the world.
By forcing people to rename the file, they are aware of it, and what it does.