Drupal Code Style Review Git Commit Hooks

A nice feature for protecting a repository from badly formatted code that violates Drupal coding standards is to install Coder at the global drush level (not in a specific website) and then use Drupal Code Quality (dcq) to run that code review as a git commit hook that runs as you attempt to commit your code.

Installation instructions are here.

I found that when my commit hooks fired, I was getting the following error:

ERROR: the "Drupal" coding standard is not installed. The installed coding standards are Squiz, PSR1, PSR2, Zend, PHPCS, PEAR and MySource

 For some reason version installed via the composer method lacked the Drupal specific coding standard.  The fix is to symlink them to the drush installed version

The paths for the standards on ubuntu 13.10 looked like:

Drush: ~/.drush/coder/coder_sniffer
composer: ~/.composer/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards

So it is just a matter of the following command to symlink the composer based standard to the Drupal standard. That way your versions of the test whether run by commit hook or run by drush will be the same.

ln -s ~/.drush/coder/coder_sniffer/Drupal ~/.composer/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Drupal