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. 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.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.incthat 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.
- First of all, inline documentation in the coder_format script.
- Drupal Coding Standards (see also more up to date doc in CVS).
- Coder's issue queue which contains some very valuable information about proper coding-styles (use Advanced Search to find older issues).
- PHP's Tokenizer and Tokenizer Tokens which are used to identify PHP's syntax.
- http://www.regular-expressions.info/tutorial.html provides a great resource for regex-related questions and howto's, you will probably need.
- If you are working on Windows, you might additionally use the coder_format Windows installer, which I'll update with an improved version when this task has been claimed.
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.
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. 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.
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().
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).
| Comment | File | Size | Author |
|---|---|---|---|
| #60 | coder-DRUPAL-6--1.patch | 8.51 KB | sun |
| #59 | coder-DRUPAL-6--1.patch | 7.17 KB | sun |
| #58 | coder-DRUPAL-6--1.patch | 9.48 KB | sun |
| #57 | coder-format-gamma-4.patch | 9 KB | ezyang |
| #56 | coder-format-gamma-3.patch | 8.44 KB | ezyang |
Comments
Comment #1
aclight commentedThe offical GHOP task related to this issue can be found at:
http://code.google.com/p/google-highly-open-participation-drupal/issues/...
Comment #2
ezyang commentedSee comments #1 and #2 here: http://drupal.org/node/149826#comment-693264 ... I accidentally posted them in the wrong place. I hope it's not too much of an inconvenience. I'll repost below:
The first order of business is to get coder_format working on Windows. This patch fixes a number of problems I found. Specifically:
Coder needs a dose of its own medicine, but that will be done in good time. :-)
Here are the changes coder identified for the action.inc file. Most of them are sensible, but a few are hazy. Specifically:
Comment #3
ezyang commentedbatch.inc is fairly straightforward; same issues as action.inc, but also, we have a lot of reference assignments converted from =& func() to = &func(). I hope this is the intended behavior, although it is not mentioned in Drupal or PEAR's coding style manual.
Comment #4
ezyang commentedbootstrap.inc:
Comment #5
ezyang commentedcache.inc and cache-install.inc are clean except for some minor whitespace changes.
Comment #6
ezyang commentedAh, the first major problems are found in common.inc:
I'll terminate analysis for now and fix these issues. But before I do, any insights into what may be causing these problems?
Comment #7
sunhttp://drupal.org/node/149826 contains the latest code of coder_format including a Windows installer now. The first two mentioned issues in #2 are fixed in that patch. Please use that version for your work on this task. I hope it will be committed ASAP.
Also, if you are working on Windows, you really should use the Windows Explorer integration to quickly and recursively clean/unclean the coding-style of Drupal core.
General:
-poption for diff. See http://drupal.org/patch/create for further info. Diff header lines in your patches for coder_format should always look like this:Questions:
mymodule_foo($op, &$node)), and functions declared by reference (i.e.&mymodule_foo();) both use this style, we should use it for variable declarations, too.(object)array()- bug: double slashes in multi-line comments: yep
- bug: wrongly interpreted double-slashes: definitely! This bug in drupal_url_encode() is the cause for the wrong indent in all following lines.
Now, writing this answer was a bit cumbersome. How about creating a Wiki page at http://groups.drupal.org/coding-standards-and-performance-optimization containing a table (or the like) with all findings, questions and answers?
Comment #8
sunSorry, small addition FYI: To disable a pre-/post-processor, simply comment out the key
'#search', and it won't be executed. To receive debugging info on the command line, just add the item'#debug' => TRUE,.Comment #9
sun@ezyang: http://drupal.org/node/149826 has been committed, so be sure to use a fresh checkout of coder_format (or wait approx. 12 hours until a new development snapshot has been packaged).
Comment #10
ezyang commentedI've made the wiki page: http://groups.drupal.org/node/8224 I'll post here when I make updates to that page, unless you say otherwise.
Also, it looks like conf_path() fix hasn't be committed yet, so here's a cleaner patch for the issue. We also have a (separate) patch for the two comment issues, which also appears to fix the indent problem.
Updated common.inc patch, with one more issue described on the wiki page. When it's verified, change it to OPEN.
Also attached are "clean" patches for other includes. They had no problems.
Comment #11
sunReminder: Last patch was not created from coder.module's directory. If you create patches for Drupal contrib modules, everyone expects them to be based on the root of the corresponding module (except Drupal core). See http://drupal.org/patch/create for further information.
I've committed that patch, because it included only basic changes to get this task started. Upcoming patches will be kept in this issue until the issue is set to RTBC. I don't know the GHOP rules in detail, but I think one patch including all improvements will give us a better overview about the results of this task.
Wiki page: The current "File" and "Location" won't work out, because lines in "Location" refer to a patch file, while "File" refers to another file. Proposed procedure:
- Let's always refer to actual files in Drupal core - thus, also refer to line number(s) in those files (instead of temporary patch files). Everyone is able to track these issues in their own setups then.
- Let's move "File" + "Location" to the beginning of the table, and rename "Location" to "Line(s)".
- "Resolution" is actually a "Status".
- Could you add one example (!) filename and line number for the first three rows?
- It probably makes sense to add the file path to filenames (includes/bootstrap.inc), and order all table rows alphabetically.
Posting here and there will keep this issue warm and publicly visible, which is good.
Comment #12
ezyang commentedQuick note, there were updates to the post above before you posted. Composing a response now (will make a new comment, this might take a while).
Comment #13
sunPatch files: Simply stating that a file does not include wrong formattings is enough. Please don't attach patches for those files. Instead, we might add a table row for each file indicating the status 'OK' - or what do you think? Too much clutter? Then a second table for reviewed, but 'ok' files would sound appropriate to me.
Please forget my (foolish) comment about line numbers. Let's replace them with function names instead. (Line numbers change quite often, and we still have 7 critical issues for D6)
Any updates regarding the white-space post-processor (to keep further patches smaller)?
Comment #14
sunYou've added a comma in coder_preprocessor_inline_comment() without updating the explanation (badly needed):
Comment #15
ezyang commentedMy apologies for all the mistakes. I'll try to iron out these errors. I've updated the table with your suggestions. I will handle the comma thing (it too is to prevent matching of double slashes in quotes, but I'll make it explicit that this is also for multiline arrays). I totally missed the whitespace bug too, so I'll need to fix that.
I'll post cumulative patches for coder_format. This makes it more difficult to see what changed, but wth. I'm also going to abstain from posting coder_format diffs, but I will be posting test-cases (hopefully, we can get them automated or something).
Comment #16
sunRe: cumulative patches: That's absolutely okay, just keep on posting any updates! This is why: By reviewing all Drupal core files, we are creating a definitive list of bugs or bogus results at the Wiki page. This is our test plan. It is not only checked during development, but will also completely checked again in front of committing all fixes. It is okay, if only you and me are able to track the changes between coder_format patches in follow-ups of this issue, as long as others are able to understand (through inline/PHPdoc comments) how coder_format is working.
I hope that the existing inline documentation is sufficient enough to understand how coder_format works. Since you are one of the first developers that tries to understand and enhance it, feel free to improve the inline documentation in places you think it is missing or not sufficient. That will surely help other developers to enhance the script in the future.
While randomly looking through files, I discovered another two bugs:
However, I didn't look thoroughly through both files, so there may be more issues.
Comment #17
ezyang commentedUpdated: all outstanding issues fixed except for one! Whitespace issue required a globals hack, but I don't think it should be a problem as we are not running coder_format_string recursively.
The coder_format documentation is quite good. There are some design decisions (such as the heavy reliance on regexes) that I don't agree with, but it works well and I, so far, have been able to get it to do what I want it to do.
For the two issues you brought up, I've fixed the // // one. As for the indent of closing braces, I'm not sure if this actually is intended behavior: isn't this syntax:
Valid?
Comment #18
ezyang commentedThe previous patch broke a lot of spacing things, due to a faulty implementation of the lookbehind check. I've converted coder_br into accepting $result as a reference, which solves the problem and also looks cleaner!
Update 1: Here's another update, with includes up to locale.inc checked. 12 more to go!
Update 2: Analysis of last 12 files done! Mostly everything is savvy; I'd just like you to checkup on some of the new issues before I fix them.
Comment #19
ezyang commentedMarking code needs review
Comment #20
sunGreat work so far! I really like the changes you made to coder_br()'s $result handling.
However:
$in_function_declmay be$in_function_declarationor at least$in_func_declaration)$in_function_declarationis missing. I don't understand why it is set to FALSE incase '(', and why exactly it has been added.@notePHPdoc command, just remove it and the indent. Everything between the one-line function short-description and function parameters are considered "notes". :)$string{123}. Thus,should probably be
All other questions have been answered in the wiki page.
Comment #21
ezyang commentedIssues addressed.
I respectfully disagree with the proposition that newline collapsing should be a post-processor: this is because there's no way to tell if we're inside a string/heredoc/etc or not. Granted, in most cases, some removed whitespace won't make a difference, but things are safest if we do rtrimming when the code has explicitly given us permission to input whitespace.
Also, curly brace syntax will be deprecated with PHP 6, so I'm sticking with square brackets.
P.S. Curiously enough, the for loop still works properly in both cases: when $i hits zero it evaluates false and terminates the loop! I have fixed it, however.
Comment #22
ezyang commentedJuicy new multiline array indenter added. Also, docs added for the hyphen fix.
Comment #23
sunWow! That's totally awesome! :)
Unfortunately, I've discovered some very odd results in common.inc:
- drupal_add_feed(): The line containing
drupal_add_link(array('rel' => 'alternate',has been deleted.- drupal_add_js(): The line containing
array('basePath' => base_path()),has been deleted.- watchdog_severity_levels(): The whole array has been deleted.
Your arguments about trimming white-space are good. I've marked the corresponding issue fixed.
Comment #24
sunI'm not sure if we really should investigate the new multiline array indent processor further. As mentioned before, multiline arrays are also used in hook_menu(), and from my knowledge, many developers would not be happy to see their menu items indented like this, f.e. in aggregator.module.
I'd say: Let's keep this in mind (and in the patch), disable the processor (for now), and focus on the other bugs. Would that be okay with you?
Comment #25
ezyang commentedOk.
Did you merge the common.inc :: drupal_common_theme() issues? I would prefer it the other way, as when they're merged, I can't set the status for a specific task otherwise; I think I've fixed "coder_preprocessor_ml_array_add_comma() should add a comma to multi-line array values, which required for case ')'." but not the above issue.
A lot of processors need the same regexps (for example, there is a lot of multi-line array handling). How should we reuse these regular expressions?
Comment #26
ezyang commentedI'm suspicious about this patch. It seems to work, but I haven't tested it enough. This fixes mail.inc :: drupal_mail_send, and should (theoretically) also make some of the comma pre-processing obsolete.
Comment #27
sunRe: drupal_common_theme() issues: Can't remember. If it was me, it happened not intentional during a clean-up.
Re: preprocessor_ml_array_add_comma: Performed only a quick check - unfortunately, it introduced a bug in common.inc:url().
Comment #28
suneerm... IRC? *g*
Comment #29
ezyang commentedUpdated preprocessor_ml_array_add_comma(), should be working properly now. Sorry, I have to run now. If you're still around in about three hours, I'll be back.
Comment #30
ezyang commentedUnzip this file in your tests/ directory for coder, set things up by reading the README.txt file, apply the latest coder patch, and then fire up the SimpleTest and enjoy insta-unit-tests for Coder! This will make regression testing a lot easier. Whee!
Comment #31
sunBoy! That is a fantastic idea! It blows my head!
Since introducing unit tests for coder_format is a bit out of scope of this issue, I'll try to work with you in parallel on that. Unfortunately, I have no experience with SimpleTest yet.
Comment #32
sunvar $foostatements.The latest patch for coder_format is included in this patch. Since this is an AWESOME way to speed up our reviews, I would propose to include all these changes in future patches. I hope I can get into touch with Doug to coordinate this. Without coordination, we would need to place those new test files into the coder_format directory.
Comment #33
sunNew patch,
- moves coder_format tests into scripts/coder_format/tests/
- creates a stub file tests/coder_format.test to let SimpleTest know of these tests.
- allows to add <?php tags in the first line of all coder_format tests for proper syntax highlighting in editors.
- includes some more code clean-up in the new SimpleTest functions (actually, I've created the previous patch in the wrong directory...).
I'll start to add the existing unit test cases from the wiki page now, so hopefully, you can focus on fixing the outstanding bugs later on.
Comment #34
sunNow we are talking! :)
Comment #35
sunSimpleTests have been committed.
Comment #36
ezyang commentedAll tests pass. There have been some fairly major architectural changes in this patch: namely, I'm starting to move some of the processors to the tokenizer. Why? Regexps are quick and dirty, but they cause lots of problems when you hit the edge-cases. Using the tokenizer lets us use a much richer set of contextual rules.
It feels pretty impossible to separate the patches, so there are changes to the tests in here too. Namely, they've been revised into 1 KB or less chunks.
Comment #37
ezyang commentedComment processing moved into the tokenizer. In this case, putting it there greatly simplifies our code by eliminating the need for checking all of those edge cases (is it in a comment, a multiline, an array, inside a string, etc). It looks like some tests are missing from the previous patch, this one has them.
Comment #38
sunEdward: This rocks!
This is the first time that Drupal 6 core does not output a fatal error after applying coder_format! Yeeeeha!
I'm already pretty sure that, once finished, all this work will gain very much attention among Drupal developers.
The new multiline array processing is quite impressive. I did not find any error.
I've tried to clean-up the inline documentation a bit. However, I'm not sure I understood the new variables correctly. If I'm not totally wrong,
$in_multilineand$in_arrayare both controllers for inline comment placement? If they are, the PHPdoc for them could be a bit more detailed.I agree with you regarding small unit tests. However, most of them require some context to check real world examples. Furthermore, we would need plenty of test files then. Especially regarding comments and parenthesis, there are many tests that have to be passed. After reviewing core files in
includes/once again, I've added some important tests now. Do whatever you think is best to do, but please don't delete 'em.. ;)Regarding inline comments immediately following an function/if/elseif statement, I was not sure what the proper default should be. Sometimes a developer is commenting the statement itself, sometimes the contents of it. IMHO, moving them always above the remarked line should work out in 99% of all cases. To make this point clear, I added two functions (namely
db_query_range()and_locale_import_read_po()) to comments.phpt.I guess that
--EXPECT--is optional now?I've replaced variables.phpt with some code that I actually wanted to use in my last patch.
IMHO it would be a good idea to stuff all possibilities into unit tests. There are only two days left until this task needs to be completed, and we might get some help from contributors to review Drupal core and find all wrong formattings. If all of them are covered by unit tests, you could concentrate on fixing coder_format instead of reviewing core files.
Finally, is it possible that the SimpleTest result table is reversed, i.e. actual results should be left? In failing tests, lines in the expected result are marked instead of lines in the actual result.
Comment #39
ezyang commentedWhoo! Just a few clarifications before I continue hammering away:
They're slightly magical. I'll document them better.
I agree. However, that's not the point of unit tests per se; we should be careful to partition real-world tests into their own area.
It's always been optional. When omitted, we expect the input to come out.
Hmm... that would be a SimpleTest bug. I'm not very happy with the way they're displaying results, so expect a barrage of patches there (I've already opened up another bug requesting they hide pass cases by default--a trivial fix, but they have to agree to it).
Comment #40
sunApplied coder_format on coder_format.
Comment #41
sunFor reference: This is patch against complete Drupal core, using the latest version of coder_format in this thread.
Among possible wrong formattings applied by coder_format, you'll see that Drupal core indeed contains bad coding-style. :)
Comment #42
ezyang commentedThis patch is only for coder_format.inc. Please apply it in the proper directory, thanks. (I couldn't get CVS to ignore my test file changes). Fixed are the variable alignment and curly-brace index syntax.
Lowdown on current issues:
Multiline array comma-adding with trailing comments, triggered by:
<?php
$v = array(
'foo' => 'asdf',
'as' => 23 // something
);
We don't know when to add the trailing comma until we hit the parenthesis, but by then it's very difficult to get back to the proper string index to add it (a naive algorithm will accidentally append the comma to the comment). Somehow, this data needs to be made available.
Comment #43
sunNew patch,
- implemented logic to allow multiple tests in one test file
- splitted existing tests and added a some more
- fixed output of test results to be displayed in the page content
- added handling for class member function properties (such as abstract, private, public, protected)
- fixed class properties
var- improved some inline documentation
I've made these changes since they are not in the scope of this task.
Also, contrary to my earlier posts, I'd suggest to commit this patch now, so further patches will be smaller.
Comment #44
ezyang commentedUpdated patch which fixes the multiline comma issue.
Comment #45
ezyang commentedAll tests pass!
Comment #46
ezyang commentedNow with docs!
Comment #47
ezyang commentedEven better docs, and some bugfixes in the unit testing framework.
Comment #48
ezyang commentedNewest patch.
Comment #49
sunPlease help ezyang to review Drupal core! Time's running out!
1) Download Drupal 6 tarball and extract it somewhere on your drive.
2) Checkout Coder from CVS (or download attached archive). If you choose to use an existing Drupal installation, make sure to create a backup first.
3) Open a command line.
4) Read the included README.txt for coder_format to find out how to apply coder_format recursively on Drupal core. Basically, it should work out like this (assuming Drupal core is in /websites/drupal):
Windows:
Linux:
Comment #50
webchickI gave this a run-through tonight. Very impressive! I spot-checked a few files in core (not the whole thing) and for the most part it looks a-ok.
There are some clean-up things and bike-shed arguments that will likely need to happen before this is 'formally' marked fixed, but ezyang appears to have fulfilled the requirements for this task (a patch to coder_format that's RTBC, as it has been several times now), and he also has a good track record for coming back and cleaning up on tasks post-closure if any issues come up. Since tha_sun probably wont be around for another ~8-10 hours, and we're down to about 27 hours left for student to claim tasks, I'm going to go ahead and mark this closed in the Google tracker. Great job!!
Comment #51
sunIndeed, Edward, your performance has been awesome! I really enjoyed to work with you on this task.
Given the concerns that were raised during this task's proposal, I can only say: The goals have been accomplished (by far exceeded), and development for coder_format has become much easier because of the implementation of SimpleTests.
@ezyang: If you could just post a patch including your latest improvements for inline PHP tags, that would be great. I'll do a code clean-up for coder_format, and a thorough review for Drupal core then. If you want to (I hope so), we can then join forces after you've completed your other GHOP tasks.
Comment #52
ezyang commentedNot a problem. Here's the updated patch. I accidently ran coder_format on coder_format, so there's also some stylistic changes in there too.
Comment #53
sunHeh... from now on, applying coder_format on a file can't be considered as an accident anymore!
All tests pass, so I've committed all changes in #52. Attached is a new patch against Drupal core for review.
I will add (and commit) unit tests for all wrong formattings I can find throughout Drupal core. Unfortunately, I've already found these:
(i) A case statement in a case statement (filter.module) gets wrong indents.
(ii) Line breaks are added to inline PHP that includes a control structure (like an
if).(iii) Line breaks are added after curly braces in a quoted string (usually found in some JavaScript generating code). Confusingly, the new unit test passes, but locale.inc is completely broken due to
_locale_rebuild_js().Setting to RTBC so this hopefully gains some more attention, reviewers, subscribers, and follow-ups.
@whoever: Feel free to post any pointers to wrong formattings. If you do so, please provide the same information like in the wiki page.
/me keeps dreaming of a patch against Drupal 6 core, and coder_format being added to the scripts directory in core...
Comment #54
ezyang commented(message scrubbed)
Comment #55
ezyang commentedCase statement in case statement fixed. A quick note: In the future, try to make test-cases shorter. The really long lines in that one made it difficult to read the diff; I reduced it in my patch.
Comment #56
ezyang commentedNew patch that causes all tests to pass. Now will investigate the JS bug.
Comment #57
ezyang commentedHammered out a bunch of bugs with the case and case patch. I'm not seeing the locale.inc bug, sorry. We likely need docs for all the new code, so just tell me what you don't understand and I'll document it!
Comment #58
sunGotcha! Spent some time debugging the locale mystery...
I needed to switch the order of conditions for opening curly braces:
All tests still pass, but locale_rebuild_js() in locale.inc looks finally correct now. However, I still don't get why the remaining conditions need to be enclosed by extra braces.
Comment #59
sunFixed coder_preprocessor_switch_duplicate_exit() and cleaned-up some of the regular expressions.
Also, please note that http://drupal.org/node/213072 has been committed, so usage of coder_format.php has slightly changed.
Comment #60
sunPost-processor
coder_postprocessor_if_curly_braces()is finally working now, yay!Comment #61
dwwI looked over http://drupal.org/files/issues/drupal6.patch from #53, especially stuff from update.module, since that's almost entirely my code. ;) Some valid concerns and bikeshed-esque nitpicks:
A) This looks like a bug:
B) I really don't think hunks like this improve readability of the code, which is ultimately the point of consistent use of coding standards:
C) I find this is an even more important regression for readability:
Especially when there are multiple lines close by like this, closing their own div's, I really want to see the code comments label the exact line they're referring to. There's nothing in our coding conventions that says 1-liners at the end of a given line of code are forbidden (for good reason), and just because it confuses your regular expressions in here is not a good reason to call this a violation of code style or otherwise mark it as an error.
D) Do we actually have any specific guidelines for how to indent multi-line if clauses? I know we generally tend to avoid those in the coding style, but there is some pretty complicated if logic in update status module, and I think it's much more readable as multiple lines. I'm not sure the changes recommended here are any improvement to readability, either. I think it's visually clear how the logic is grouped via the indentation I used, so I'm curious what justification there is (if any) for the proposed changes. ;)
Comment #62
ezyang commentedThese are good concerns you bring up. A is a bug, and is due to insufficient testing of OOP code; I'll check it out. B is, curiously enough, also a bug: alignments should not extend over blank lines.
C is contentious. I have heard that comments should never ever be on the same line as code, in Drupal. If this is not the case, we can undo this!
For D, do you have an example?
Comment #63
sunPatch in #53 has become quite outdated in the meantime. So, A + B might already be solved.
Regarding C, you'll find a in-depth discussion here: http://drupal.org/node/150626
After reviewing plenty of reformatted code by coder_format I have seen many places (in core and contrib) where these changes really improved the readability, and the sense of a comment. Of course, there might be inline comments that may loose their context. However, given your snippet, IMHO this is exactly a great example of an inline comment that rather confuses than explains something. If that DIV was opened in another function or somewhere between the lines, a helpful comment could rather look like:
So, generally spoken, these re-formattings help developers to ensure that their comments are in fact helpful to others who try to understand the code.
Comment #64
dwwA) Cool, thanks.
B) Frankly, I generally find "alignment" spacing to make things harder to read, and there's no mention of it anywhere to be found at http://drupal.org/coding-standards. Examples of it in core are rare. Seems like this is a personal preference, and not generally agreed upon, so I don't think it's wise for this code to enforce it.
C) Again, no mention at all at http://drupal.org/coding-standards. The closest reference is: "C style comments (/* */) and standard C++ comments (//) are both fine.". Well, C++ comments like this are often used inline with the code they clarify. ;)
D) There are a bunch of hunks in the patch, for example:
The original indentation aligns the if clauses inside the if () itself, so it's clear those belong to the if. The proposed indentation just normally indents, as if those are lines of code inside the code block defined by the if, not the if itself. see what i mean?
Comment #65
dww@sun #63: see http://drupal.org/node/150626#comment-716075
Comment #66
ezyang commentedB. Actually, aligning assignments is a fairly common practice. I've had it recommended to me by George Schlossnagle; I think it does improve readability IF an excessive amount is NOT added.
D. Ew... that looks like some nasty hacks to the indentation code. I understand what you're talking about though. My personal preference is:
But that's because I use four spaces for indents. The convention makes less sense when there's only two indents:
I think, however, there are two conclusions to be made:
coder_format configuration will require quite of bit of architectural restructuring, though.
Comment #67
sunComment #68
klausiCoder for Drupal 6 is now frozen and only security fixes will be applied. Feel free to update this issue and reopen against 7.x-2.x or 8.x-2.x.