style(3p/nix): Add braces around single-line conditionals

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
This commit is contained in:
Vincent Ambo 2020-05-19 18:55:58 +01:00
parent c6a31838cd
commit 867055133d
97 changed files with 2223 additions and 753 deletions

View file

@ -111,7 +111,9 @@ static void prim_getContext(EvalState& state, const Pos& pos, Value** args,
for (const auto& info : contextInfos) {
auto& infoVal = *state.allocAttr(v, state.symbols.create(info.first));
state.mkAttrs(infoVal, 3);
if (info.second.path) mkBool(*state.allocAttr(infoVal, sPath), true);
if (info.second.path) {
mkBool(*state.allocAttr(infoVal, sPath), true);
}
if (info.second.allOutputs)
mkBool(*state.allocAttr(infoVal, sAllOutputs), true);
if (!info.second.outputs.empty()) {
@ -147,11 +149,15 @@ static void prim_appendContext(EvalState& state, const Pos& pos, Value** args,
if (!state.store->isStorePath(i.name))
throw EvalError("Context key '%s' is not a store path, at %s", i.name,
i.pos);
if (!settings.readOnlyMode) state.store->ensurePath(i.name);
if (!settings.readOnlyMode) {
state.store->ensurePath(i.name);
}
state.forceAttrs(*i.value, *i.pos);
auto iter = i.value->attrs->find(sPath);
if (iter != i.value->attrs->end()) {
if (state.forceBool(*iter->value, *iter->pos)) context.insert(i.name);
if (state.forceBool(*iter->value, *iter->pos)) {
context.insert(i.name);
}
}
iter = i.value->attrs->find(sAllOutputs);

View file

@ -37,7 +37,9 @@ GitInfo exportGit(ref<Store> store, const std::string& uri,
runProgram("git", true,
{"-C", uri, "diff-index", "--quiet", "HEAD", "--"});
} catch (ExecError& e) {
if (!WIFEXITED(e.status) || WEXITSTATUS(e.status) != 1) throw;
if (!WIFEXITED(e.status) || WEXITSTATUS(e.status) != 1) {
throw;
}
clean = false;
}
@ -78,7 +80,9 @@ GitInfo exportGit(ref<Store> store, const std::string& uri,
ref = "HEAD"s;
}
if (!ref) ref = "HEAD"s;
if (!ref) {
ref = "HEAD"s;
}
if (rev != "" && !std::regex_match(rev, revRegex))
throw Error("invalid Git revision '%s'", rev);
@ -166,7 +170,9 @@ GitInfo exportGit(ref<Store> store, const std::string& uri,
}
} catch (SysError& e) {
if (e.errNo != ENOENT) throw;
if (e.errNo != ENOENT) {
throw;
}
}
// FIXME: should pipe this, or find some better way to extract a

View file

@ -73,7 +73,9 @@ HgInfo exportMercurial(ref<Store> store, const std::string& uri,
}
}
if (rev == "") rev = "default";
if (rev == "") {
rev = "default";
}
Path cacheDir = fmt("%s/nix/hg/%s", getCacheDir(),
hashString(htSHA256, uri).to_string(Base32, false));
@ -149,7 +151,9 @@ HgInfo exportMercurial(ref<Store> store, const std::string& uri,
}
} catch (SysError& e) {
if (e.errNo != ENOENT) throw;
if (e.errNo != ENOENT) {
throw;
}
}
Path tmpDir = createTempDir();