Bug 40723 - Fix paren matching rules for switch/if/while in check-webkit-style script
Summary: Fix paren matching rules for switch/if/while in check-webkit-style script
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC OS X 10.5
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-16 11:11 PDT by Sam Magnuson
Modified: 2010-06-23 00:48 PDT (History)
8 users (show)

See Also:


Attachments
Proposed patch (8.00 KB, patch)
2010-06-16 11:17 PDT, Sam Magnuson
no flags Details | Formatted Diff | Diff
Updated change (11.00 KB, patch)
2010-06-17 10:36 PDT, Sam Magnuson
no flags Details | Formatted Diff | Diff
Proposed patch (10.79 KB, patch)
2010-06-17 10:49 PDT, Sam Magnuson
no flags Details | Formatted Diff | Diff
The right patch this time, sigh. (7.98 KB, patch)
2010-06-17 10:51 PDT, Sam Magnuson
hamaji: review+
Details | Formatted Diff | Diff
Rediff against trunk (7.64 KB, patch)
2010-06-22 16:11 PDT, Sam Magnuson
hamaji: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Sam Magnuson 2010-06-16 11:11:14 PDT
I've been bitten a few times going through the review process with:

if( foo )

being flagged as bad style by a reviewer but never flagged by the check-webkit-style script. Since these roundtrips waste everybody's time it would be great if check-webkit-style would flag it on my end (to help newcomers like me learn the rules)
Comment 1 Sam Magnuson 2010-06-16 11:17:51 PDT
Created attachment 58908 [details]
Proposed patch

I've updated the unit tests so that all pass.
Comment 2 Shinichiro Hamaji 2010-06-16 23:33:40 PDT
Comment on attachment 58908 [details]
Proposed patch

Looks good. Thanks for this patch!

Please run the style checker for WebCore/*/*.{cpp,h} and examine if there are no false postives.

WebKitTools/Scripts/webkitpy/style/processors/cpp_unittest.py: 
 +          self.assert_lint('while (  foo  ) {', 'Should have zero or one spaces inside'
I think we still want this test. Maybe this case should produce two errors?
Comment 3 Sam Magnuson 2010-06-17 10:36:10 PDT
Created attachment 59009 [details]
Updated change
Comment 4 Sam Magnuson 2010-06-17 10:37:24 PDT
(In reply to comment #2)
> (From update of attachment 58908 [details])
> Looks good. Thanks for this patch!
> 
> Please run the style checker for WebCore/*/*.{cpp,h} and examine if there are no false postives.
> 

I shouldn't have been so confident :) I noticed that:

for(int a = 0; a < 10; )

Got broken with my change, I've fixed that in the revised patch.

> WebKitTools/Scripts/webkitpy/style/processors/cpp_unittest.py: 
>  +          self.assert_lint('while (  foo  ) {', 'Should have zero or one spaces inside'
> I think we still want this test. Maybe this case should produce two errors?

This actually will spit out the to messages (one for the space after '(' and one for the space before ')'. I didn't see any other tests that check for two errors, are there anyway?
Comment 5 Sam Magnuson 2010-06-17 10:49:26 PDT
Created attachment 59010 [details]
Proposed patch
Comment 6 Sam Magnuson 2010-06-17 10:51:49 PDT
Created attachment 59011 [details]
The right patch this time, sigh.
Comment 7 Eric Seidel (no email) 2010-06-17 15:30:15 PDT
Comment on attachment 58908 [details]
Proposed patch

Cleared Shinichiro Hamaji's review+ from obsolete attachment 58908 [details] so that this bug does not appear in http://webkit.org/pending-commit.
Comment 8 Shinichiro Hamaji 2010-06-17 21:47:19 PDT
Comment on attachment 59011 [details]
The right patch this time, sigh.

> This actually will spit out the to messages (one for the space after '(' and one for the space before ')'. I didn't see any other tests that check for two errors, are there anyway?

I think assert_lint can take a list of errors as the second parameter. Like,

self.assert_lint('while (  foo  ) {',
                 ['the first error!',
                  'the second error!'])
Comment 9 Sam Magnuson 2010-06-22 16:11:51 PDT
Created attachment 59436 [details]
Rediff against trunk
Comment 10 WebKit Review Bot 2010-06-22 16:14:17 PDT
Attachment 59436 [details] did not pass style-queue:

Failed to run "['WebKitTools/Scripts/check-webkit-style', '--no-squash']" exit_code: 1
WebKitTools/Scripts/webkitpy/style/checkers/cpp_unittest.py:1183:  whitespace before ')'  [pep8/E202] [5]
Total errors found: 1 in 3 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 11 Shinichiro Hamaji 2010-06-22 21:21:51 PDT
Comment on attachment 59436 [details]
Rediff against trunk

WebKitTools/ChangeLog:13
 +  2010-06-16  Sam Magnuson  <smagnuson@netflix.com>
It's better to put this new changelog entry on the top of this file.
Comment 12 Shinichiro Hamaji 2010-06-22 21:22:31 PDT
Comment on attachment 59436 [details]
Rediff against trunk

Also, please fix the style error the review bot found. Otherwise this patch looks good. Thanks!
Comment 13 Shinichiro Hamaji 2010-06-22 21:24:29 PDT
Ah, you are not a committer yet, right? So, I'll land this patch with fixes I've suggested. You don't need to update the patch again.
Comment 14 Shinichiro Hamaji 2010-06-23 00:11:33 PDT
Committed r61666: <http://trac.webkit.org/changeset/61666>
Comment 15 WebKit Review Bot 2010-06-23 00:48:02 PDT
http://trac.webkit.org/changeset/61666 might have broken Qt Linux Release
The following changes are on the blame list:
http://trac.webkit.org/changeset/61666
http://trac.webkit.org/changeset/61667
http://trac.webkit.org/changeset/61668