HOW-TO check your code before committing it so you look like the pro you are

One of the best practices for high performance web teams is to ensure quality by doing peer code reviews. You may already be aware of the Coder module, but have you tried the Coder Tough Love module and Drupal Code Sniffer project?

The  Coder module  includes two developer modules that assist with code review and code upgrade: Coder Review and Coder Upgrade. Each of the modules supports a plug-in extensible hook system so contributed modules can define additional review standards and upgrade routines.

Coder Review utilizes regular expressions to review source code files for code that 1) needs to change due to Drupal API changes and 2) does not satisfy Drupal coding standards. Beginning with the 5.x-2.x version, this module adds a new UI, core support, theme support, and a cache for faster display of unchanged files. It also supports rule #severity levels of "minor", "normal", and "critical."

If you really want to go the extra mile, try the Coder Tough Love module which  is a companion to the existing Coder module by Doug Green. Unlike Coder, which strives to follow the documented style guidelines of Drupal core, Coder Tough Love takes the tougher tactic of applying finely aged and obsessively anal wisdom from years of Drupal development and persnickety quality control.

Now if you're really hard core and want to rock Drupal like a champ, there's the Drupal Code Sniffer project provides a coding standard for PHP_CodeSniffer, based on the Drupal Coding Standards. Drupal Code Sniffer is not a Drupal module, it does not require Drupal to run and it is independent of Drupal core versions.

This is specially useful when you need to run a coding standards check without a full Drupal installation. For example when you're checking code validation on a standalone server without a drupal site, checking a single file from a code editor (Eclipse, Textmate, etc.), or for setting up pre-commit hooks to check the code on all files being committed.

Once you have run your code through theese and you fixed any issued that might have come to light you're ready to commit your code knowing that it is up to par with the best.

[UPDATE] If you are already using PHP_CodeSniffer to identify coding standards problems in your code, you know that fixing them by hand is tedious, especially on large projects. Well now, thanks to  Fabien Potencier, creator of the Symfony framework we don't have to fix those problems by hand. PHP Coding Standards Fixer is a tool that does the job for you

The PHP Coding Standards Fixer tool fixes most issues in your code when you want to follow the PHP coding standards as defined in the PSR-1 and PSR-2 documents.

Rob Montero

Rob Montero, Drupal Association Individual Member

Roberto Montero Ortiz is an individual member of the Drupal Association, which fosters and supports the Drupal software project, the community and its growth. He also has an active role in the Drupal Community in Costa Rica and regularly contributes to Drupal Camps held in Latin America.

Rob Montero, Acquia Certified Developer 2014   Rob Montero, Certified Developer Back End Specialist 2015Rob Montero, Acquia Certified Developer Front End Specialist

Rob is also an Acquia Certified Developer, awarded with the Grand Masters title after completing his third certification within a year. 

Zend also certifies Rob's knowledge of PHP OOP skills, but at this point this block is getting a bit presumptious. Suffice it to say, Rob is competitive and competent. He's also a nice guy all around.

Drupal Latin America

Rob Montero is a proud sponsor and mentor of young Drupal talent of the Costa Rican Drupal Users Group and entrepreneur at Drupal Latin America

CHECK THEM OUT

Get in touch

  • Rob Montero
    Ave Popocatepetl 435 B 504
    Sta Cruz Atoyac, Benito Juarez
    Ciudad de México, 03310 
  • (858) 952 0762
  • roberto@montero-ortiz.com
Signup to our newsletter: