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!
Posted by mariano.barcia on July 16, 2014 at 10:20pm
Last updated by mariano.barcia on Tue, 2015年06月23日 23:52

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.gz 1.77 KB
Drupal coding standards for Eclipse Luna.xml_.gz 1.83 KB

Comments

Some issues

Posted by mjkovacevich on June 23, 2015 at 11:00pm

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

Posted by mariano.barcia on June 23, 2015 at 11:48pm

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:

AltStyle によって変換されたページ (->オリジナル) /