Task description
One of the things that has an great impact on Drupal's success is the widely adopted agreement on clean, sophisticated, and well-documented code. In an abstract view, we are not only using a language (PHP), but also using a dialect to articulate what we are doing. This means that core developers and most contrib module maintainers try to ensure that everyone else in the community understands all parts of the application and is able to fix or improve the code without language barriers. Without this solid ground, no one would be able to participate and contribute in the way the Drupal community members are doing. Many patches against Drupal core are holden back or even rejected because of unsuitable code.
To support developers in using the proper syntax, formatting, naming, and adhering to all other development guidelines for Drupal, the Code Review module has been developed, which outputs notices for all code that is considered wrong in terms of Drupal Coding Standards. While Coder does only a code review and leaves you with the results, there is also the coder_format script shipped with the Coder module, that strives to clean and re-format a whole file to adhere to Drupal's Coding Standards.
Cleaning the coding-style of a contributed module with coder_format is usually a 5-minute job. However, due to its current beta-state, there are situations where coder_format applies wrong formattings to some lines or all lines that follow some lines of complex syntax in a file.
  • The goal of this GHOP task is to fix and improve the coder_format script, so that it can be applied recursively on Drupal 6 core without introducing wrong formattings (and fixing existing wrong formattings throughout Drupal core, of course).
  • The result of this GHOP task must be a single patch file against coder_format.inc that is ready to be committed. To clarify in advance: not a patch against Drupal core -- Patch files against Drupal core are only needed to communicate the current results/errors of coder_format in this issue.
  • To work on this task, you should have a local development environment, be able to run a PHP script from the command line, know how to access a CVS server, and how to checkout and create patches against a CVS module. You should have a (better good) visual diff tool to compare a resulting file with the original.
  • You will have to deal with rather complex regular expressions, Drupal Coding Standards, reviewing of Drupal core (with and without Coder module), creating and applying patches, writing helpful inline documentation, and identifying wrong formattings.
  • Coder_format can be run recursively on all files in a directory by invoking it with the --batch-replace argument. See inline documentation in coder_format.php for further information.
Resources
Primary contact
Daniel F. Kudwien (sun)
I'm pretty sure that fellow Drupallers like Doug, Stella, Core developers, subscribers of the Coding Standards Group and also developers in the #drupal and #drupal-ghop IRC channels will help out on any questions related to missing information about Drupal Coding Standards.

For the sake of completeness I'm adding a patch file against Drupal 6 core that is the result of coder_format. It's about 1,5 MB, so I needed to zip it. You will discover the first formatting error in drupal_urlencode() which leads to wrong indents in all following lines. Furthermore, the patch would be dramatically smaller, if there was a post-processor that removed any white-space from all lines containing only white-space (this is one of the needed improvements).

CommentFileSizeAuthor
drupal-6.zip357.04 KBsun

Comments

aclight’s picture

Status: Active » Postponed (maintainer needs more info)

The description of the task is clear and specific. My only concern is whether this is possible to do on 1 week (keeping in mind that students have class, homework, etc.) I'm not familiar with the coder_format module, so it's hard for me to judge how much work would be required for this to work. If you are pretty confident that a student can get this done in time then go ahead and create an official task for this.

webchick’s picture

Sound exciting. I second aclight's comment.

Also, we should probably mention http://cvs.drupal.org/viewvc.py/drupal/contributions/CODING_STANDARDS.ht... which is far more up to date than the handbook page (unfortunately :\). It usually isn't a big deal if there are minor discrepancies for other tasks, but for this one (since it deals with source code quality in modules), it is.

sun’s picture

Status: Postponed (maintainer needs more info) » Active

Well, I also elaborated on this question. It took me approx. one week to write coder_format, and given the limited scope of this GHOP task, I think it should be doable to fix the remaining errors regarding Drupal core (at least) within one week, too.
FYI: After all, there will be still some contrib modules (f.e. eCommerce) that use even more ill syntax than Drupal core...

Please bear in mind that coder_format is already performing quite well. So the referenced resources about coding standards are only necessary to find out how something should look like if there are any wrong formattings. At least for me, it is quite hard to believe that the attached patch is already based on a completely re-formatted Drupal core, which means that all files have been re-written by coder_format. (Insane, isn't it?! *g*)
Pre- and post-processors are already part of the script, so the mentioned post-processor for cleaning up lines containing only white-space is definitely not a big deal. Also, the mentioned bug in drupal_urlencode() is clearly caused by the pre-processor coder_preprocessor_inline_comment().

Admittedly, probably unlike other tasks, this task is a pure debugging job. However, I'd propose to add it to the queue, and let's just see if one of the students feels like Cool, easy one - let's get it done!.
Additionally, I'd like to mention that I will support the claiming student in all possible ways.

aclight’s picture

Status: Active » Reviewed & tested by the community

Sounds good to me. Go ahead and taskify it according to http://groups.drupal.org/node/7360#tasks

If you're not a member of the Google GHOP project group on google, you won't be able to set the status of the task or clean up the tags. You can either contact one of the admins (IRC, contact tab, etc.) and give us your google account so we can add you, of just submit the task to the google tracker and one of us will clean up the tags, etc. for you.

sun’s picture

New issue: http://drupal.org/node/208767
There's no one online who could add me as a project member at Google currently.

aclight’s picture

@sun: You can go ahead and add your issue at any time, but you won't be able to change tags on it or set it to open. I will likely be available on IRC most of the day today (aclight) so you can ping or pm me and shoot me your google account and I'll add you as a member.

aclight’s picture

Status: Reviewed & tested by the community » Closed (fixed)

This has been created as an official GHOP task.

The related drupal issue is at: http://drupal.org/node/208767
The GHOP task is at: http://code.google.com/p/google-highly-open-participation-drupal/issues/...