Contact Krimson

Call us: +32 (0) 3 298 69 98

Email us: info@krimson.be

May the coder module be with you

This morning I went to the A Developer's Assistant - Using Coder for Module Developers and Maintainers session by Doug Green. The coder module is a handy piece of code that should be in every module developer's toolbox. It's just a normal module (download it, install it, use it) that offers a pretty wide range of code analysis:

  • Code style review: space usage, indentation, string concatenation, placement of curly braces, etc. This helps with making your code line up with the Drupal code style standards.
  • Comment review: things like is there a CVS $Id$ keyword present, what's the "doxygenity" of the comments (usage of those "@foo" API definition thingies)
  • SQL review that for example checks if SQL keywords are properly capitalized and if tables are in curly braces to make table prefixing possible.
  • Upgrade review. This is a really killer feature IMHO: it helps you upgrading your modules to a new version of core and points you to all those kinky API changes (like the form API, the menu API, the schema API, etc for the upgrade to Drupal 6).
  • Security and performance review like checking for SQL injections. This sort of review is however a bit limited because it's more difficult to do (without writing advanced parser and interpreter stuff).

This is a very nice feature set that makes my live as module maintainer a lot easier (especially when updating to new core version) and I would recommend any developer to use it.

An interesting experiment that Doug did was to run Coder's style review against "all of Drupal":
Coder Style Review of all of Drupal
which brought up a list of most common code style errors:
Most common Drupal coding style errors

A nice feature I didn't check out yet is that the coder module also hooks into Drush (a command line Drupal tool), which probably can streamline coder usage if you're into command line geekyness.

Another interesting thing brought during the Q&A part was that the idea of combining Coder and SimpleTest. That would be very handy to automate Coder's review and maybe even produce some kind of quality metric (which is a hot topic now in the drupal.org redesign efforts).