Bug 30021 - check-webkit-style does not detect missing spaces around &=, |=, -=, and +=
Summary: check-webkit-style does not detect missing spaces around &=, |=, -=, and +=
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC All
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-10-02 09:58 PDT by Carol Szabo
Modified: 2009-10-04 14:12 PDT (History)
2 users (show)

See Also:


Attachments
Proposed patch (2.73 KB, patch)
2009-10-02 11:24 PDT, Carol Szabo
eric: review-
Details | Formatted Diff | Diff
Proposed patch (7.26 KB, patch)
2009-10-02 14:55 PDT, Carol Szabo
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Carol Szabo 2009-10-02 09:58:29 PDT
While these binary operators require spaces around them (per the webkit style guidelines) check-webkit-style currently misses these errors, despite detecting similar errors involving ==, !=, <= and >=.
Fix to follow shortly
Comment 1 Carol Szabo 2009-10-02 11:24:17 PDT
Created attachment 40536 [details]
Proposed patch

This patch addresses lack of white space detection for a lot of binary operators.
Comment 2 Eric Seidel (no email) 2009-10-02 13:04:35 PDT
Comment on attachment 40536 [details]
Proposed patch

I need to see more unit testing before I can be sure this is correct.
Comment 3 Carol Szabo 2009-10-02 14:55:28 PDT
Created attachment 40548 [details]
Proposed patch

Added some unit tests, but I think the best test is the fact that over the entire existing WebKit codebase, there is no change in the output of the tool introduced by my changes.
This means that at least my change is very unlikely to hide common errors that were previously detected and very unlikely to introduce a lot of annoying false errors.
My recorded unit tests as well as running the tool on my own patches proves that it finds a few things that were  not found before.
By the way, I noticed that check-webkit-style is intentionally coded to allow constructs such as a = 3<<4; This exception from the normal "binary operator rule" is not mentioned in the coding styles webpage or I have missed it (http://webkit.org/coding/coding-style.html). Also, another exception is if ((a=b) != c) construction where a comment in the check-webkit-style file says that there must NOT be spaces around = inside if. This exception is not mentioned in the guidelines either.
Comment 4 Darin Adler 2009-10-02 15:00:08 PDT
(In reply to comment #3)
> I noticed that check-webkit-style is intentionally coded to allow
> constructs such as a = 3<<4;

That sounds wrong. WebKit coding style would require spaces there.

> Also, another exception is if
> ((a=b) != c) construction where a comment in the check-webkit-style file says
> that there must NOT be spaces around = inside if.

That's wrong. My guess is that it came from someone else's coding style guidelines. Maybe Google internal guidelines?
Comment 5 Carol Szabo 2009-10-02 15:06:18 PDT
(In reply to comment #4)
> (In reply to comment #3)
> > I noticed that check-webkit-style is intentionally coded to allow
> > constructs such as a = 3<<4;
> 
> That sounds wrong. WebKit coding style would require spaces there.
> 
> > Also, another exception is if
> > ((a=b) != c) construction where a comment in the check-webkit-style file says
> > that there must NOT be spaces around = inside if.
> 
> That's wrong. My guess is that it came from someone else's coding style
> guidelines. Maybe Google internal guidelines?

Thanks for the clarification. If I'll edit the check-webkit-style file again I shall fix those, but till then I'd like my current fixes landed so that I do not have to manually add them to my new workspaces.
Comment 6 David Levin 2009-10-04 14:02:01 PDT
Comment on attachment 40548 [details]
Proposed patch

Looks good.  Thanks for making it better!

btw, about the allowed items that shouldn't be allowed, check-webkit-style is a recent addition to WebKit and thus may be more liberal than desired (due to its heritage from checking Google style).
Comment 7 WebKit Commit Bot 2009-10-04 14:12:34 PDT
Comment on attachment 40548 [details]
Proposed patch

Clearing flags on attachment: 40548

Committed r49078: <http://trac.webkit.org/changeset/49078>
Comment 8 WebKit Commit Bot 2009-10-04 14:12:37 PDT
All reviewed patches have been landed.  Closing bug.