From b490742a511dd03afc43f5143d6d61edaeeb8091 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Tue, 19 May 2020 17:38:04 +0100 Subject: style(3p/nix): Enforce braces around loops and conditionals This change was generated with: fd -e cc -e hh | xargs -I{} clang-tidy {} -p ~/projects/nix-build/ \ --checks='-*,readability-braces-around-statements' --fix \ -fix-errors Some manual fixes were applied because some convoluted unbraced statements couldn't be untangled by clang-tidy. This commit still includes invalid files, but I decided to clean them up in a subsequent commit so that it becomes more obvious where clang-tidy failed. Maybe this will allow for a bug-report to clang-tidy. --- third_party/nix/src/nix/repl.cc | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'third_party/nix/src/nix/repl.cc') diff --git a/third_party/nix/src/nix/repl.cc b/third_party/nix/src/nix/repl.cc index 27bb77071f..a24020b7ba 100644 --- a/third_party/nix/src/nix/repl.cc +++ b/third_party/nix/src/nix/repl.cc @@ -155,7 +155,9 @@ static char* completionCallback(char* s, int* match) { }; size_t start = strlen(s); size_t len = 0; - while (checkAllHaveSameAt(start + len)) ++len; + while (checkAllHaveSameAt(start + len)) { + ++len; + } if (len > 0) { *match = 1; auto* res = strdup(std::string(*possible.begin(), start, len).c_str()); @@ -295,7 +297,9 @@ bool NixRepl::getLine(string& input, const std::string& prompt) { return true; } - if (!s) return false; + if (!s) { + return false; + } input += s; input += '\n'; return true; @@ -384,7 +388,9 @@ static int runProgram(const string& program, const Strings& args) { bool isVarName(const string& s) { if (s.size() == 0) return false; char c = s[0]; - if ((c >= '0' && c <= '9') || c == '-' || c == '\'') return false; + if ((c >= '0' && c <= '9') || c == '-' || c == '\'') { + return false; + } for (auto& i : s) if (!((i >= 'a' && i <= 'z') || (i >= 'A' && i <= 'Z') || (i >= '0' && i <= '9') || i == '_' || i == '-' || i == '\'')) @@ -682,8 +688,10 @@ std::ostream& NixRepl::printValue(std::ostream& str, Value& v, } str << "}"; - } else - str << "{ ... }"; + } else { + str + } + << "{ ... }"; break; } @@ -694,7 +702,7 @@ std::ostream& NixRepl::printValue(std::ostream& str, Value& v, seen.insert(&v); str << "[ "; - if (maxDepth > 0) + if (maxDepth > 0) { for (unsigned int n = 0; n < v.listSize(); ++n) { if (seen.find(v.listElems()[n]) != seen.end()) str << "«repeated»"; @@ -706,8 +714,10 @@ std::ostream& NixRepl::printValue(std::ostream& str, Value& v, } str << " "; } - else - str << "... "; + } else { + str + } + << "... "; str << "]"; break; -- cgit 1.4.1