Bug 27499 - Coding style - Clarify some cases with spacing
Summary: Coding style - Clarify some cases with spacing
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Website (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC All
: P2 Minor
Assignee: Nobody
Depends on:
Reported: 2009-07-21 07:40 PDT by Luciano Wolf
Modified: 2009-07-22 07:32 PDT (History)
3 users (show)

See Also:

Add explicit rule about no space before comma or semicolon (2.03 KB, patch)
2009-07-22 05:39 PDT, Kenneth Rohde Christiansen
manyoso: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Luciano Wolf 2009-07-21 07:40:39 PDT
Clarify the case where there is spacing before a comma/semicolon in a control condition and in functions.

I would like for it to be clear if the following is wrong or right according to the coding style.

for (int i = 0 ; i < 10 ; i++)

// Qt's foreach
foreach (QString &item , items)

f(a , b);
Comment 1 Kenneth Rohde Christiansen 2009-07-21 15:39:28 PDT
Personally I would vote for this being discouraged by the coding style, and I have personally yet to find such code in the webkit project.

What is your guys take on this?
Comment 2 David Levin 2009-07-21 15:49:20 PDT
Putting no spaces before ; and , is basically following the current project style even though it isn't in the style guide.  I would likely mention it in a review.
Comment 3 Kenneth Rohde Christiansen 2009-07-21 15:52:19 PDT
So you think it would be OK to make a patch for the coding style guidelines? If so, I can do that.
Comment 4 David Levin 2009-07-21 15:57:07 PDT
Maybe just ask if this the current style on webkit-dev before and mention that you're willing to creating a style guide patch.

That's how I saw it happen when someone else added something to the guide.  This way everyone has a chance to see the style guide change. (They may not see the patch being submitted).
Comment 5 Kenneth Rohde Christiansen 2009-07-21 16:06:26 PDT
I agree and have send an e-mail to the discussion list.
Comment 6 Kenneth Rohde Christiansen 2009-07-22 05:32:38 PDT
From the mailing list:

I believe it is quite well established that a space should not be allowed before a ; or , in such circumstances.  (I have r-ed for it even ;) ).  I think we should definitely explicitly call this out in the guidelines if it is not already.


The examples in the coding style guidelines use the right style (i.e. no space before the comma or semicolon), it would be fine to make it an explicit rule.

 - Maciej

Patch coming up!
Comment 7 Kenneth Rohde Christiansen 2009-07-22 05:39:31 PDT
Created attachment 33257 [details]
Add explicit rule about no space before comma or semicolon
Comment 8 Adam Treat 2009-07-22 05:54:07 PDT
Comment on attachment 33257 [details]
Add explicit rule about no space before comma or semicolon

Please take out the foreach examples as that's likely to confuse people not familiar with Qt :)  Otherwise, r+ following discussions on webkit-dev.
Comment 9 Kenneth Rohde Christiansen 2009-07-22 06:04:59 PDT
Landed in r46219