Bug 128751
Summary: | [check-webkit-style] False positive when using the ternary operators with multiple lines. | ||
---|---|---|---|
Product: | WebKit | Reporter: | Javier Fernandez <jfernandez> |
Component: | Tools / Tests | Assignee: | Nobody <webkit-unassigned> |
Status: | NEW | ||
Severity: | Normal | CC: | llango.u-szeged |
Priority: | P2 | ||
Version: | 528+ (Nightly build) | ||
Hardware: | Unspecified | ||
OS: | Unspecified |
Javier Fernandez
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 | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
László Langó
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.