Bug 128751 - [check-webkit-style] False positive when using the ternary operators with multiple lines.
Summary: [check-webkit-style] False positive when using the ternary operators with mul...
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-02-13 11:32 PST by Javier Fernandez
Modified: 2014-03-21 06:40 PDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Javier Fernandez 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.
Comment 1 László Langó 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.