-
Notifications
You must be signed in to change notification settings - Fork 29.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
benchmark,lib,test: use braces for multiline block #13828
Conversation
For if/else and loops where the bodies span more than one line, use curly braces. Refs: nodejs#13623 (comment)
/cc @addaleax |
@@ -29,20 +29,23 @@ function main(conf) { | |||
function benchFor(buffer, n) { | |||
bench.start(); | |||
|
|||
for (var k = 0; k < n; k++) | |||
for (var i = 0; i < buffer.length; i++) | |||
for (var k = 0; k < n; k++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get why braces would be added here, but why also on the for
below if it does not contain a multi-line body? Ditto for all other instances of this in this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mscdex To make the decision about things like that, I looked at surrounding code and also used my own judgment as to what was more readable.
In this case, having one for
with braces wrapping another for
without braces seemed less readable to me than both having braces. Additionally, there were no other examples in this file of blocks without braces.
After such changes I usually ask: "Can you now turn on an ESLint rule?" |
For if/else and loops where the bodies span more than one line, use curly braces. PR-URL: nodejs#13828 Ref: nodejs#13623 (comment) Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: James M Snell <[email protected]>
Landed in 095c0de |
@Trott This doesn’t land cleanly on 8.x; if you can backport it, great, but if you don’t think it’s worth it feel free to add the dont-land label. |
For if/else and loops where the bodies span more than one line, use curly braces. PR-URL: nodejs#13828 Ref: nodejs#13623 (comment) Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: James M Snell <[email protected]>
For if/else and loops where the bodies span more than one line, use curly braces. Original-PR-URL: #13828 Ref: #13623 (comment) Original-Reviewed-By: Anna Henningsen <[email protected]> Original-Reviewed-By: Colin Ihrig <[email protected]> Original-Reviewed-By: Michaël Zasso <[email protected]> Original-Reviewed-By: James M Snell <[email protected]> PR-URL: #13995 Reviewed-By: Anna Henningsen <[email protected]>
For if/else and loops where the bodies span more than one line, use curly braces. Original-PR-URL: #13828 Ref: #13623 (comment) Original-Reviewed-By: Anna Henningsen <[email protected]> Original-Reviewed-By: Colin Ihrig <[email protected]> Original-Reviewed-By: Michaël Zasso <[email protected]> Original-Reviewed-By: James M Snell <[email protected]> PR-URL: #13995 Reviewed-By: Anna Henningsen <[email protected]>
For if/else and loops where the bodies span more than one line, use curly braces. Original-PR-URL: #13828 Ref: #13623 (comment) Original-Reviewed-By: Anna Henningsen <[email protected]> Original-Reviewed-By: Colin Ihrig <[email protected]> Original-Reviewed-By: Michaël Zasso <[email protected]> Original-Reviewed-By: James M Snell <[email protected]> PR-URL: #13995 Reviewed-By: Anna Henningsen <[email protected]>
For if/else and loops where the bodies span more than one line, use curly braces. Original-PR-URL: #13828 Ref: #13623 (comment) Original-Reviewed-By: Anna Henningsen <[email protected]> Original-Reviewed-By: Colin Ihrig <[email protected]> Original-Reviewed-By: Michaël Zasso <[email protected]> Original-Reviewed-By: James M Snell <[email protected]> PR-URL: #13995 Reviewed-By: Anna Henningsen <[email protected]>
Should this be backported to |
For if/else and loops where the bodies span more than one line, use
curly braces.
Refs: #13623 (comment)
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
benchmark lib test