Shane O'Sullivan's technical blog… really ties the room together

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 – .

You can see the current report, as of May 23rd 2009 at

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


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 , so can developers please reference this when checking in style fixes?

Checkstyle UI


6 Responses to “Code style checker for Dojo”

  1. Nathan Toone said

    When I try to run it from the latest svn, I get:

    js: Couldn’t open file “checkstyle.js”.

    Any ideas?

  2. Nathan Toone said

    I got it fixed – nevermind.

  3. cool, thanks for that.

  4. […] Code style checker for Dojo « SOS […]

  5. 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?

  6. 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.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: