Bug 32991

Summary: [Qt] check-webkit-style generates false report on "#include *.moc"
Product: WebKit Reporter: Chang Shu <cshu>
Component: Tools / TestsAssignee: Chang Shu <cshu>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, eric, hamaji, levin, webkit.review.bot
Priority: P3 Keywords: Qt
Version: 528+ (Nightly build)   
Hardware: PC   
OS: Linux   
Attachments:
Description Flags
fix patch
eric: review-
alternative fix
abarth: review-
added unit tests none

Description Chang Shu 2009-12-28 12:33:27 PST
check-webkit-style generated the following error report on patch 45564 in bug 32614.
Failed to run "WebKitTools/Scripts/check-webkit-style" exit_code: 1
JavaScriptCore/wtf/qt/ThreadingQt.cpp:293:  Found header this file implements
after other header. Should be: config.h, primary header, blank line, and then
alphabetically sorted.  [build/include_order] [4]
Total errors found: 1

I think it's a false alarm.
Lines like "#include ThreadingQt.moc" in a Qt cpp file should not follow the general include style.
Comment 1 Chang Shu 2009-12-28 12:43:32 PST
Created attachment 45568 [details]
fix patch

Include files ending with ".moc" were accidentally categorized as PRIMARY_HEADER.
Comment 2 WebKit Review Bot 2009-12-28 12:47:10 PST
style-queue ran check-webkit-style on attachment 45568 [details] without any errors.
Comment 3 Eric Seidel (no email) 2009-12-29 00:06:09 PST
Comment on attachment 45568 [details]
fix patch

This requires a unittest.  I'm not familiar enough with this code to know if this is the right approach.
Comment 4 Chang Shu 2009-12-29 06:53:51 PST
(In reply to comment #3)
> (From update of attachment 45568 [details])
> This requires a unittest.  I'm not familiar enough with this code to know if
> this is the right approach.

The line I have changed is to check the primary header by comparing the base file name. For example, if the cpp file is test.cpp, test.h will be the primary header. However, for Qt, a line such as "#include test.moc" may show up at the end of the file. Its base name is also "test" but we should exclude this from primary header.
Comment 5 Chang Shu 2009-12-29 10:15:31 PST
Created attachment 45612 [details]
alternative fix

This is an alternative fix. It simply changes the order of processing headers.
Comment 6 WebKit Review Bot 2009-12-29 10:19:19 PST
style-queue ran check-webkit-style on attachment 45612 [details] without any errors.
Comment 7 Adam Barth 2009-12-29 11:47:21 PST
Comment on attachment 45612 [details]
alternative fix

I'm not a cpp_lint expert, but this second patch looks like a good approach.  However, we still need a test.  cpp_lint has extensive unit tests.  It should be straightforward to modify one to test this new behavior.
Comment 8 Chang Shu 2009-12-29 13:19:24 PST
Created attachment 45620 [details]
added unit tests

2 new unit tests added for Qt moc headers.
Comment 9 WebKit Review Bot 2009-12-29 13:21:17 PST
style-queue ran check-webkit-style on attachment 45620 [details] without any errors.
Comment 10 Adam Barth 2009-12-29 13:58:35 PST
Comment on attachment 45620 [details]
added unit tests

LGTM.  A cpp_lint expert might want to double check.  Thanks for the test.
Comment 11 WebKit Commit Bot 2009-12-29 15:06:40 PST
Comment on attachment 45620 [details]
added unit tests

Clearing flags on attachment: 45620

Committed r52636: <http://trac.webkit.org/changeset/52636>
Comment 12 WebKit Commit Bot 2009-12-29 15:06:48 PST
All reviewed patches have been landed.  Closing bug.