Bug 128751

Summary: [check-webkit-style] False positive when using the ternary operators with multiple lines.
Product: WebKit Reporter: Javier Fernandez <jfernandez>
Component: Tools / TestsAssignee: Nobody <webkit-unassigned>
Status: NEW    
Severity: Normal CC: llango.u-szeged
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   

Javier Fernandez
Reported 2014-02-13 11:32:55 PST
This scenario triggers the following style issue: * Wrong number of spaces before statement. (expected: 24) [whitespace/indent] [4] For what could understand, the use of the ternary operator in multiple lines makes the style checker to trigger indent issues in different lines. These lines in the CSSParser.cpp file are the root cause of the problem: RefPtr<CSSPrimitiveValue> amount = arg->id == CSSValueAuto ? cssValuePool().createIdentifierValue(CSSValueAuto) : createPrimitiveNumericValue(arg); I'm not really sure whether such syntax is correct or not. If it's correct, this is a false positive, otherwise this bug should be resolved by adding a new style check to prevent that way of using the ternary operator.
Attachments
László Langó
Comment 1 2014-03-21 06:40:50 PDT
I think the ternary operator should be use only in short cases. If your code with ternary operator does not fit into one line, then you should use if-else instead. We don't have any rule for this case as I know, but maybe this would be useful.
Note You need to log in before you can comment on or make changes to this bug.