From 867055133d3f487e52dd44149f76347c2c28bf10 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Tue, 19 May 2020 18:55:58 +0100 Subject: style(3p/nix): Add braces around single-line conditionals 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 --- third_party/nix/src/libexpr/nixexpr.cc | 36 +++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) (limited to 'third_party/nix/src/libexpr/nixexpr.cc') diff --git a/third_party/nix/src/libexpr/nixexpr.cc b/third_party/nix/src/libexpr/nixexpr.cc index 9c25530efd..4c0536f35c 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); -- cgit 1.4.1