Chromium Code Reviews
DescriptionEnforced new rules for braces in conditional and loop bodies in style checker.
Consensus was reached on blink-dev to change the style rules for
braces in conditional and loop bodies (previously called "control
clauses"). Previously, braces were forbidden for single-line
conditionals like
if (condition)
doSomething();
Now, as in Google's C++ style guide, braces are optional in this case.
The style checker now enforces the following rules:
- Braces are required for single, multi-line statements in
conditionals and loop bodies.
- If any arm of an if/else statement uses braces, all must use them.
Once this lands, section "Braces" in the style guide will be updated
with the following rules adapted from the Google C++ style guide, with
examples:
- Rule 3 ("One-line control clauses...") will be removed.
- 3. Curly braces are not required for single-line conditional
or loop bodies, but are required for single-statement bodies
that span multiple lines. [braces-single-line]
- 4. If one part of an if-else statement uses curly braces, the
other part must too. [braces-must-match]
Note that much existing Blink code will be in violation of the new
style; it will have to be updated incrementally.
BUG=242696
R=eseidel@chromium.org
Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=151858
Patch Set 1 #Patch Set 2 : Updated numbering in unit test. #Patch Set 3 : Rebased. #Patch Set 4 : Clarified terminology based on feedback from Peter Kasting. #Patch Set 5 : Updated terminology in comments. #
Total comments: 1
Patch Set 6 : #Patch Set 7 : Rebased. #
Messages
Total messages: 26 (0 generated)
|
||||||||||||||||||||||||||||