Coder

by Gisle Hannemyr

The Coder module reviews your Drupal code against coding standards and other best practices. It can also upgrade code from one version of Drupal to another.

Table of contents

Drupal modules discussed in this chapter: Coder.

Introduction

Installing and enabling the module

Please node that the Grammar Parser (short name grammar_parser, ver. >= 1.2, < 2.0) goes into Libraries, while Grammar Parser Library (short name grammar_parser_lib, ver. 7.x-1.1) goes into modules. Libraries must be ver. 7.x-2.0 or newer.

[I am unable to get the make files supplied with the project work.]

Use drush to install CodeSniffer. It ends up below /opt/rh.

drush install-php-code-sniffer

The page Converting 6.x modules to 7.x lists all the Drupal api changes and tracks their latest status in coder.

Using coder

The UI is located at Administration » Configuration » Development » Coder. There are two tabs, "Review" and "Upgrade".

Coder review

Coder Review implements a list of rules for detecting what you need to do to upgrade a module to Drupal 7. Unfortunately, a full list of rules has yet to be completed. However, running it through your module can be useful to detect the code that is incompatible with Drupal 7.

Coder upgrade

This Coder upgrade sub-module will convert your code automatically by simply placing the existing Drupal 6 module in a specific directory, selecting it's files in the coder upgrade UI and pressing a button. Like magic, you'll receive a set of files that include the patch file applied to your module, and (hopefully) a Drupal 7 compatible version. Don't forget to follow the module's instructions and run Coder Review afterward to highlight the areas that need manual intervention. After that, it should be a simple case of installing the Drupal 7 version of your module and testing it.

There's also a site that allows you to run Coder Upgrade remotely.

Final word

[TBA]


Last update: 2014-04-26 for D7 [gh].