Last updated 24 February 2015. Created on 2 December 2013.
Edited by HongPong, dman. Log in to edit this page.

Coder.module comes with a couple of drush plugins that let you repair things directly from the commandline - a great thing to try before committing new code!

  • First install coder and its required libraries onto your system
  • It's still not possible to run drush:coder commands stand-alone, so you should also install coder.module directly on your target site and enable it (this can be temporary).
    cd path/to/your/site/folder
    drush dl coder
    drush en -y coder
    
  • It's a good start to RTFM.
    drush help | grep coder
    
     coder-format          Re-format and rewrite code according Drupal coding standards.                             
     coder-review (coder,  Run code reviews   
    
  • Before letting an automated tool lose on your code the first time, you may like to back up or (better) commit the current version of your code to source control before proceeding!
  • Run it and see what happens
    drush coder-format sites/all/modules/custom/{$modulename}
    

    ... It should have just done it for you. Your code is magically better!

  • If you had source control, you can now check out what it did.
     cd ../all/modules/custom/{$modulename}
    git diff
    

    It's usually just whitespace, but to a visual review each time.

Bravo, your code is now up-to-standard.

For Drupal 8.x see the new Drupal Console for some similar functions.

Looking for support? Visit the Drupal.org forums, or join #drupal-support in IRC.

Comments

AlexBorsody’s picture

I had run the automated tool to fix the outstanding issues and it seems to have left many issues which could be easily fixed such as whitespace and capitalized letters, why is this not built into the tool? It takes hours of tedious work to fix these issues and really does not effect the functionality at all, it is barriers like this that causes many good modules from never getting promoted on Drupal.org.

CatsFromStonehenge’s picture

drush en -y coder gets me into an infinite loop in the Terminal on OSX 10.6. I can't CTRL-C, escape or press 'n' to escape from this. I had to kill the terminal!

This seems to be totally broken.

The following projects provide some or all of the extensions not found:                        [ok]
coder
Would you like to download them? (y/n): y
^Ccoder was not found.                                                                           [warning]
The following projects provide some or all of the extensions not found:                        [ok]
coder
Would you like to download them? (y/n): y
^Ccoder was not found.                                                                           [warning]
The following projects provide some or all of the extensions not found:                        [ok]
coder
Would you like to download them? (y/n): y
^Ccoder was not found.                                                                           [warning]
The following projects provide some or all of the extensions not found:                        [ok]
coder