about summary refs log tree commit diff
path: root/third_party/nix/src/libexpr/parser.y
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2020-05-19T17·55+0100
committerVincent Ambo <tazjin@google.com>2020-05-19T17·55+0100
commit867055133d3f487e52dd44149f76347c2c28bf10 (patch)
treec367803ad94f024b0052727a2c7a037af169169a /third_party/nix/src/libexpr/parser.y
parentc6a31838cd7e88ebcb01422b329a499d04ab4b6b (diff)
style(3p/nix): Add braces around single-line conditionals r/771
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
Diffstat (limited to 'third_party/nix/src/libexpr/parser.y')
-rw-r--r--third_party/nix/src/libexpr/parser.y20
1 files changed, 10 insertions, 10 deletions
diff --git a/third_party/nix/src/libexpr/parser.y b/third_party/nix/src/libexpr/parser.y
index ddcd1a4dae74..5aa38bf2b82c 100644
--- a/third_party/nix/src/libexpr/parser.y
+++ b/third_party/nix/src/libexpr/parser.y
@@ -89,7 +89,7 @@ static void addAttr(ExprAttrs * attrs, AttrPath & attrPath,
             if (j != attrs->attrs.end()) {
                 if (!j->second.inherited) {
                     ExprAttrs * attrs2 = dynamic_cast<ExprAttrs *>(j->second.e);
-                    if (!attrs2) dupAttr(attrPath, pos, j->second.pos);
+                    if (!attrs2) { dupAttr(attrPath, pos, j->second.pos); }
                     attrs = attrs2;
                 } else
                     dupAttr(attrPath, pos, j->second.pos);
@@ -148,7 +148,7 @@ static void addFormal(const Pos & pos, Formals * formals, const Formal & formal)
 
 static Expr * stripIndentation(const Pos & pos, SymbolTable & symbols, vector<Expr *> & es)
 {
-    if (es.empty()) return new ExprString(symbols.create(""));
+    if (es.empty()) { return new ExprString(symbols.create("")); }
 
     /* Figure out the minimum indentation.  Note that by design
        whitespace-only final lines are not taken into account.  (So
@@ -162,7 +162,7 @@ static Expr * stripIndentation(const Pos & pos, SymbolTable & symbols, vector<Ex
             /* Anti-quotations end the current start-of-line whitespace. */
             if (atStartOfLine) {
                 atStartOfLine = false;
-                if (curIndent < minIndent) minIndent = curIndent;
+                if (curIndent < minIndent) { minIndent = curIndent; }
             }
             continue;
         }
@@ -176,7 +176,7 @@ static Expr * stripIndentation(const Pos & pos, SymbolTable & symbols, vector<Ex
                     curIndent = 0;
                 } else {
                     atStartOfLine = false;
-                    if (curIndent < minIndent) minIndent = curIndent;
+                    if (curIndent < minIndent) { minIndent = curIndent; }
                 }
             } else if (e->s[j] == '\n') {
                 atStartOfLine = true;
@@ -216,7 +216,7 @@ static Expr * stripIndentation(const Pos & pos, SymbolTable & symbols, vector<Ex
                 }
             } else {
                 s2 += e->s[j];
-                if (e->s[j] == '\n') atStartOfLine = true;
+                if (e->s[j] == '\n') { atStartOfLine = true; }
             }
         }
 
@@ -559,7 +559,7 @@ Expr * EvalState::parse(const char * text,
     int res = yyparse(scanner, &data);
     yylex_destroy(scanner);
 
-    if (res) throw ParseError(data.error);
+    if (res) { throw ParseError(data.error); }
 
     data.result->bindVars(staticEnv);
 
@@ -577,7 +577,7 @@ Path resolveExprPath(Path path)
     while (true) {
         if (lstat(path.c_str(), &st))
             throw SysError(format("getting status of '%1%'") % path);
-        if (!S_ISLNK(st.st_mode)) break;
+        if (!S_ISLNK(st.st_mode)) { break; }
         path = absPath(readLink(path), dirOf(path));
     }
 
@@ -656,9 +656,9 @@ Path EvalState::findFile(SearchPath & searchPath, const string & path, const Pos
             suffix = path.size() == s ? "" : "/" + string(path, s);
         }
         auto r = resolveSearchPathElem(i);
-        if (!r.first) continue;
+        if (!r.first) { continue; }
         Path res = r.second + suffix;
-        if (pathExists(res)) return canonPath(res);
+        if (pathExists(res)) { return canonPath(res); }
     }
     format f = format(
         "file '%1%' was not found in the Nix search path (add it using $NIX_PATH or -I)"
@@ -671,7 +671,7 @@ Path EvalState::findFile(SearchPath & searchPath, const string & path, const Pos
 std::pair<bool, std::string> EvalState::resolveSearchPathElem(const SearchPathElem & elem)
 {
     auto i = searchPathResolved.find(elem.second);
-    if (i != searchPathResolved.end()) return i->second;
+    if (i != searchPathResolved.end()) { return i->second; }
 
     std::pair<bool, std::string> res;