Eclipse formatter for Drupal Code Quality

Events happening in the community are now at Drupal community events on www.drupal.org.
You are viewing a wiki page. You are welcome to join the group and then edit it. Be bold!

Attached you will find a code formatter for Eclipse Luna 4.4, compatible with the Drupal coding standards.

Install

You can import this formatter by uncompressing the XML file, and going to
Preferences -> PHP -> Code style -> Formatters -> Import

Usage

Say you are editing a Drupal .module. You can now right-click, Source->Format (Ctrl-Alt-F) and Eclipse will format your source code automatically to comply with Drupal Code Quality checks.

Also, you will find a code formatter for Eclipse PDT 3.8 (or Zend Studio 6.3).

AttachmentSize
Drupal coding standards.xml.gz1.77 KB
Drupal coding standards for Eclipse Luna.xml_.gz1.83 KB

Comments

Some issues

mjkovacevich's picture

Hi Mariano, great work on the Eclipse formatter. I have found some problems though:

  1. Arrays are not correctly formatted i.e. the comma from the last item gets removed and the ); gets pulled up.

Correct:

$test = array(
  'one' => 'jedan',
  'two' => 'dva',
  'three' => 'tri',
);

Becomes:

$test = array(
  'one' => 'jedan',
  'two' => 'dva',
  'three' => 'tri');
  1. Also string splits like below are not handled correctly:
$test = t('This is a split string'
  . ' to make things look'
  . ' nicer in the code.'
);

Becomes:

$test = t('This is a split string' . ' to make things look' . ' nicer in the code.');

Hi, I use an improved version

mariano.barcia's picture

Hi,

I use an improved version now, for Eclipse Luna.

The first case is fixed, however the last comma always gets removed, breaking a rule in PHPCS.

Attached the newer version, HTH.

Drupal IDE

Group organizers

Group categories

Drupal IDE Tags

Dev Software

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

Hot content this week