diff options
author | Vincent Ambo <tazjin@google.com> | 2020-05-19T17·55+0100 |
---|---|---|
committer | Vincent Ambo <tazjin@google.com> | 2020-05-19T17·55+0100 |
commit | 867055133d3f487e52dd44149f76347c2c28bf10 (patch) | |
tree | c367803ad94f024b0052727a2c7a037af169169a /third_party/nix/src/libexpr/nixexpr.cc | |
parent | c6a31838cd7e88ebcb01422b329a499d04ab4b6b (diff) |
style(3p/nix): Add braces around single-line conditionals r/771
These were not caught by the previous clang-tidy invocation, but were instead sorted out using amber[0] as such: ambr --regex 'if (\(.+\))\s([a-z].*;)' 'if $1 { $2 }' [0]: https://github.com/dalance/amber
Diffstat (limited to 'third_party/nix/src/libexpr/nixexpr.cc')
-rw-r--r-- | third_party/nix/src/libexpr/nixexpr.cc | 36 |
1 files changed, 27 insertions, 9 deletions
diff --git a/third_party/nix/src/libexpr/nixexpr.cc b/third_party/nix/src/libexpr/nixexpr.cc index 9c25530efdba..4c0536f35cc1 100644 --- a/third_party/nix/src/libexpr/nixexpr.cc +++ b/third_party/nix/src/libexpr/nixexpr.cc @@ -70,7 +70,9 @@ void ExprVar::show(std::ostream& str) const { str << name; } void ExprSelect::show(std::ostream& str) const { str << "(" << *e << ")." << showAttrPath(attrPath); - if (def) str << " or (" << *def << ")"; + if (def) { + str << " or (" << *def << ")"; + } } void ExprOpHasAttr::show(std::ostream& str) const { @@ -78,7 +80,9 @@ void ExprOpHasAttr::show(std::ostream& str) const { } void ExprAttrs::show(std::ostream& str) const { - if (recursive) str << "rec "; + if (recursive) { + str << "rec "; + } str << "{ "; for (auto& i : attrs) if (i.second.inherited) @@ -108,16 +112,24 @@ void ExprLambda::show(std::ostream& str) const { else str << ", "; str << i.name; - if (i.def) str << " ? " << *i.def; + if (i.def) { + str << " ? " << *i.def; + } } if (formals->ellipsis) { - if (!first) str << ", "; + if (!first) { + str << ", "; + } str << "..."; } str << " }"; - if (!arg.empty()) str << " @ "; + if (!arg.empty()) { + str << " @ "; + } + } + if (!arg.empty()) { + str << arg; } - if (!arg.empty()) str << arg; str << ": " << *body << ")"; } @@ -239,13 +251,17 @@ void ExprSelect::bindVars(const StaticEnv& env) { def->bindVars(env); } for (auto& i : attrPath) - if (!i.symbol.set()) i.expr->bindVars(env); + if (!i.symbol.set()) { + i.expr->bindVars(env); + } } void ExprOpHasAttr::bindVars(const StaticEnv& env) { e->bindVars(env); for (auto& i : attrPath) - if (!i.symbol.set()) i.expr->bindVars(env); + if (!i.symbol.set()) { + i.expr->bindVars(env); + } } void ExprAttrs::bindVars(const StaticEnv& env) { @@ -296,7 +312,9 @@ void ExprLambda::bindVars(const StaticEnv& env) { } for (auto& i : formals->formals) - if (i.def) i.def->bindVars(newEnv); + if (i.def) { + i.def->bindVars(newEnv); + } } body->bindVars(newEnv); |