DrupalPractice has been merged into Coder, please use that instead.

Uses PHP_CodeSniffer to find common errors that new Drupal developers make in their modules. Note that this will likely throw false positives and you should never change your code without verifying the reported problem. Everything that does not really fit into Coder Sniffer and pure coding standards will be included in this project.

Development

DrupalPractice is developed on Github, please use pull requests and report issues on Github.

Features

Detects the following bad practices:

  • Unused and undefined PHP variables
  • @author tags in doc blocks
  • form_set_error() being used without t()
  • 'access administration pages' permission is used in hook_menu()
  • Un-namespaced classes and interfaces are not prefixed with the module name
  • $form_state['input'] is used instead of $form_state['values']
  • $field['und'] is used instead of $field[LANGUAGE_NONE]
  • Form API #options values are not translated with t()
  • variable_get() calls where variables are not prefixed with the module name

Installation

Same as Coder Sniffer, except that this sniffer should be linked as DrupalPractice into PHP_CodeSniffer.

sudo ln -sv /path/to/drupalpractice/DrupalPractice $(pear config-get php_dir)/PHP/CodeSniffer/Standards/DrupalPractice

Project information

Releases