diff options
author | Vincent Ambo <tazjin@google.com> | 2020-05-19T16·38+0100 |
---|---|---|
committer | Vincent Ambo <tazjin@google.com> | 2020-05-19T16·38+0100 |
commit | b490742a511dd03afc43f5143d6d61edaeeb8091 (patch) | |
tree | 727370e8e7607a3078c2ce1cd6d717105c7d9c44 /third_party/nix/src/nix | |
parent | c758de9d22506eb279c5abe61f621e5c8f61af95 (diff) |
style(3p/nix): Enforce braces around loops and conditionals r/767
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.
Diffstat (limited to 'third_party/nix/src/nix')
-rw-r--r-- | third_party/nix/src/nix/build.cc | 4 | ||||
-rw-r--r-- | third_party/nix/src/nix/doctor.cc | 4 | ||||
-rw-r--r-- | third_party/nix/src/nix/installables.cc | 14 | ||||
-rw-r--r-- | third_party/nix/src/nix/legacy.hh | 4 | ||||
-rw-r--r-- | third_party/nix/src/nix/ls.cc | 6 | ||||
-rw-r--r-- | third_party/nix/src/nix/repl.cc | 26 |
6 files changed, 41 insertions, 17 deletions
diff --git a/third_party/nix/src/nix/build.cc b/third_party/nix/src/nix/build.cc index e23f63199fa2..41d8e6f0d075 100644 --- a/third_party/nix/src/nix/build.cc +++ b/third_party/nix/src/nix/build.cc @@ -40,7 +40,9 @@ struct CmdBuild : MixDryRun, InstallablesCommand { void run(ref<Store> store) override { auto buildables = build(store, dryRun ? DryRun : Build, installables); - if (dryRun) return; + if (dryRun) { + return; + } for (size_t i = 0; i < buildables.size(); ++i) { auto& b(buildables[i]); diff --git a/third_party/nix/src/nix/doctor.cc b/third_party/nix/src/nix/doctor.cc index 93016e007a84..e4138f28d88c 100644 --- a/third_party/nix/src/nix/doctor.cc +++ b/third_party/nix/src/nix/doctor.cc @@ -36,7 +36,9 @@ struct CmdDoctor : StoreCommand { } success &= checkStoreProtocol(store->getProtocol()); - if (!success) throw Exit(2); + if (!success) { + throw Exit(2); + } } bool checkNixInPath() { diff --git a/third_party/nix/src/nix/installables.cc b/third_party/nix/src/nix/installables.cc index 00cb71a231fa..f708a5a9fa14 100644 --- a/third_party/nix/src/nix/installables.cc +++ b/third_party/nix/src/nix/installables.cc @@ -22,7 +22,9 @@ SourceExprCommand::SourceExprCommand() { } Value* SourceExprCommand::getSourceExpr(EvalState& state) { - if (vSourceExpr) return vSourceExpr; + if (vSourceExpr) { + return vSourceExpr; + } auto sToplevel = state.symbols.create("_toplevel"); @@ -223,7 +225,9 @@ std::shared_ptr<Installable> parseInstallable(SourceExprCommand& cmd, Buildables build(ref<Store> store, RealiseMode mode, std::vector<std::shared_ptr<Installable>> installables) { - if (mode != Build) settings.readOnlyMode = true; + if (mode != Build) { + settings.readOnlyMode = true; + } Buildables buildables; @@ -244,8 +248,10 @@ Buildables build(ref<Store> store, RealiseMode mode, if (mode == DryRun) { printMissing(store, pathsToBuild); - } else if (mode == Build) - store->buildPaths(pathsToBuild); + } else { + if + } + (mode == Build) store->buildPaths(pathsToBuild); return buildables; } diff --git a/third_party/nix/src/nix/legacy.hh b/third_party/nix/src/nix/legacy.hh index 09a102218132..a9bc65c02e76 100644 --- a/third_party/nix/src/nix/legacy.hh +++ b/third_party/nix/src/nix/legacy.hh @@ -13,7 +13,9 @@ struct RegisterLegacyCommand { static Commands* commands; RegisterLegacyCommand(const std::string& name, MainFunction fun) { - if (!commands) commands = new Commands; + if (!commands) { + commands = new Commands; + } (*commands)[name] = fun; } }; diff --git a/third_party/nix/src/nix/ls.cc b/third_party/nix/src/nix/ls.cc index b23f83eb7824..68a2c203defa 100644 --- a/third_party/nix/src/nix/ls.cc +++ b/third_party/nix/src/nix/ls.cc @@ -74,8 +74,10 @@ struct MixLs : virtual Args, MixJSON { if (json) { JSONPlaceholder jsonRoot(std::cout); listNar(jsonRoot, accessor, path, recursive); - } else - listText(accessor); + } else { + listText + } + (accessor); } }; diff --git a/third_party/nix/src/nix/repl.cc b/third_party/nix/src/nix/repl.cc index 27bb77071f73..a24020b7bac8 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; |