Bug 35717 - check-webkit-style: false positive for empty loop
Summary: check-webkit-style: false positive for empty loop
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: Shinichiro Hamaji
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-03-03 22:01 PST by Shinichiro Hamaji
Modified: 2010-03-07 22:56 PST (History)
1 user (show)

See Also:


Attachments
Patch v1 (2.60 KB, patch)
2010-03-03 22:02 PST, Shinichiro Hamaji
no flags Details | Formatted Diff | Diff
Patch v2 (2.55 KB, patch)
2010-03-04 18:58 PST, Shinichiro Hamaji
eric: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Shinichiro Hamaji 2010-03-03 22:01:56 PST
For loops like "for (...) {}", check-webkit-style thinks the opened brace isn't closed and produces a false alarm for the close brace in two lines below.

void foo()
{
    for (int i = 0; i < 100; i++) { }
    return;
}  // check-webkit-style thinks this close brace corresponds to the open brace after "for (...)" .

test.cpp:5:  One line control clauses should not use braces.  [whitespace/braces] [4]
Total errors found: 1 in 1 files

See Bug 35557 for a real example.
Comment 1 Shinichiro Hamaji 2010-03-03 22:02:54 PST
Created attachment 49984 [details]
Patch v1
Comment 2 Eric Seidel (no email) 2010-03-04 14:03:26 PST
Comment on attachment 49984 [details]
Patch v1

I'm not sure I understand.  Why would one ever want if (foo) {}?

Can you point to the style guide as to where this is documented?  Or maybe the tests just need to be changed to use for or while.
Comment 3 Shinichiro Hamaji 2010-03-04 18:58:13 PST
Created attachment 50080 [details]
Patch v2
Comment 4 Shinichiro Hamaji 2010-03-04 18:59:55 PST
> Can you point to the style guide as to where this is documented?  Or maybe the
> tests just need to be changed to use for or while.

Oops! Yes, we need to use for or while to make the tests reasonable. Thanks for catching this.
Comment 5 Eric Seidel (no email) 2010-03-05 13:18:46 PST
Comment on attachment 50080 [details]
Patch v2

OK.  "while (condition)" would still be better with a real example of a useful "condition", but this looks OK.
Comment 6 WebKit Commit Bot 2010-03-05 14:05:11 PST
Attachment 50080 [details] was posted by a committer and has review+, assigning to Shinichiro Hamaji for commit.
Comment 7 Shinichiro Hamaji 2010-03-07 22:56:09 PST
Committed r55656: <http://trac.webkit.org/changeset/55656>