about summary refs log tree commit diff
path: root/third_party/nix/src/nix/repl.cc
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/repl.cc
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/repl.cc')
-rw-r--r--third_party/nix/src/nix/repl.cc26
1 files changed, 18 insertions, 8 deletions
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;