This is my thought stream. Well, part of it.
Comment and share, please!
Easy Drupal coding standards
Article: Easy Drupal coding standards
After some years using Drupal and writing custom themes and modules that are used only in the sites I develop, I'm interested in contributing code and patches back to the community. Since most of my work has been for my own sites, I haven't paid much attention to the coding standards so far.
Today, while fixing a few issues, I installed the Coder module, that allows you to find pieces of code that don't adhere to the Drupal coding standards. Reluctant to fix the thing line by line, I wrote a few simple Regular Expressions to fix some of them.
The list is by no means exhaustive (can there be one, anyway?), but might help someone. Otherwise, it'll serve me as a reminder. If you have corrections or other useful regexps, comment and I'll add them here.
Space after control statements
Fix
Search for: (if|foreach|while|switch+)([\(]{1})
Replace with: $1 $2
No trailing spaces
There should be no trailing spaces
Fix
Search for: [ ]+$
Replace with empty string.
Space in array assignment
Fix
Search for: ([a-zA-Z_][a-zA-Z0-9_]*)(=>)(\$)
Replace with: $1 $2 $3
Indent secondary line
Fix
Search for: ^\*
Replace with: *
(that is "space star")

Comments
Post new comment