about summary refs log tree commit diff
path: root/third_party/nix/src/nix
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2020-05-19T16·38+0100
committerVincent Ambo <tazjin@google.com>2020-05-19T16·38+0100
commitb490742a511dd03afc43f5143d6d61edaeeb8091 (patch)
tree727370e8e7607a3078c2ce1cd6d717105c7d9c44 /third_party/nix/src/nix
parentc758de9d22506eb279c5abe61f621e5c8f61af95 (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.cc4
-rw-r--r--third_party/nix/src/nix/doctor.cc4
-rw-r--r--third_party/nix/src/nix/installables.cc14
-rw-r--r--third_party/nix/src/nix/legacy.hh4
-rw-r--r--third_party/nix/src/nix/ls.cc6
-rw-r--r--third_party/nix/src/nix/repl.cc26
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 e23f63199f..41d8e6f0d0 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 93016e007a..e4138f28d8 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 00cb71a231..f708a5a9fa 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 09a1022181..a9bc65c02e 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 b23f83eb78..68a2c203de 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 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;