Bug 27615 - Fix false positives for switch statement indentation check in cpplint
Summary: Fix false positives for switch statement indentation check in cpplint
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-07-23 12:14 PDT by Jakob Petsovits
Modified: 2009-07-23 15:54 PDT (History)
2 users (show)

See Also:


Attachments
Fix false positives for switch statement indentation check in cpplint (5.48 KB, patch)
2009-07-23 12:35 PDT, Jakob Petsovits
manyoso: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.