Bug 27615

Summary: Fix false positives for switch statement indentation check in cpplint
Product: WebKit Reporter: Jakob Petsovits <jpetsovits>
Component: Tools / TestsAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: levin, manyoso
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: PC   
OS: All   
Attachments:
Description Flags
Fix false positives for switch statement indentation check in cpplint manyoso: review+

Description Jakob Petsovits 2009-07-23 12:14:52 PDT
Mike Fenton brought to my attention that code like the following throws an indentation warning in cpplint:

switch (blah) {
default: break;
}

As far as I can see, the styleguide doesn't specifically allow these kinds of one-liners, but it also doesn't forbid them. And anyways, the error message for the indentation check would be wrong in this case anyways:

"A case label should not be indented, but line up with its switch statement."

The patch below fixes this issues by making the case label regex more permissive (hm... deja-vu?). It also adds more testcases and only ends the check when the (supposed) closing brace for the switch is actually on the same level of indentation as the switch statement itself. And a slight restructuring of comments and (el)ifs for better readability.
Comment 1 Jakob Petsovits 2009-07-23 12:35:36 PDT
Created attachment 33354 [details]
Fix false positives for switch statement indentation check in cpplint
Comment 2 David Levin 2009-07-23 13:18:40 PDT
I haven't looked at the patch in depth yet... but it feels like the it should be not only "return" but also "break" or even "continue". I think the intent is to not put an "else" if you don't need to.

Ironic, huh ? :)
Comment 3 Adam Treat 2009-07-23 15:54:18 PDT
Landed with r46294.