Get rid of single-line if statements
Change-Id: I2b603563c650e83354af95ee6fb2fb4c9134fe86
diff --git a/src/ast_handlers.hpp b/src/ast_handlers.hpp
index 4227097..08d2079 100644
--- a/src/ast_handlers.hpp
+++ b/src/ast_handlers.hpp
@@ -77,8 +77,9 @@
const auto& keysNeeded = schema.listKeys(dataPathToSchemaPath(parserContext.m_tmpListPath));
std::set<std::string> keysSupplied;
- for (const auto& it : ast)
+ for (const auto& it : ast) {
keysSupplied.insert(it.first);
+ }
if (keysNeeded != keysSupplied) {
auto listName = std::get<list_>(parserContext.m_tmpListPath.m_nodes.back().m_suffix).m_name;
@@ -89,8 +90,9 @@
keysSupplied.begin(), keysSupplied.end(),
std::inserter(missingKeys, missingKeys.end()));
- for (const auto& it : missingKeys)
+ for (const auto& it : missingKeys) {
parserContext.m_errorMsg += " " + it;
+ }
parserContext.m_errorMsg += ".";
_pass(context) = false;
@@ -105,8 +107,9 @@
x3::error_handler_result on_error(Iterator&, Iterator const&, Exception const&, Context const& context)
{
auto& parserContext = x3::get<parser_context_tag>(context);
- if (parserContext.m_errorMsg.empty())
+ if (parserContext.m_errorMsg.empty()) {
parserContext.m_errorMsg = "Expecting ']' here:";
+ }
return x3::error_handler_result::rethrow;
}
};
@@ -143,8 +146,9 @@
x3::error_handler_result on_error(Iterator&, Iterator const&, Exception const& x, Context const& context)
{
auto& parserContext = x3::get<parser_context_tag>(context);
- if (parserContext.m_errorMsg.empty())
+ if (parserContext.m_errorMsg.empty()) {
parserContext.m_errorMsg = "Expected " + x.which() + " here:";
+ }
return x3::error_handler_result::rethrow;
}
};
@@ -207,8 +211,9 @@
x3::error_handler_result on_error(Iterator&, Iterator const&, Exception const&, Context const& context)
{
auto& parserContext = x3::get<parser_context_tag>(context);
- if (parserContext.m_errorMsg.empty())
+ if (parserContext.m_errorMsg.empty()) {
parserContext.m_errorMsg = "Couldn't parse create/delete command.";
+ }
return x3::error_handler_result::rethrow;
}
};
@@ -218,8 +223,9 @@
x3::error_handler_result on_error(Iterator&, Iterator const&, Exception const&, Context const& context)
{
auto& parserContext = x3::get<parser_context_tag>(context);
- if (parserContext.m_errorMsg.empty())
+ if (parserContext.m_errorMsg.empty()) {
parserContext.m_errorMsg = "Couldn't parse create/delete command.";
+ }
return x3::error_handler_result::rethrow;
}
};
@@ -229,8 +235,9 @@
x3::error_handler_result on_error(Iterator&, Iterator const&, Exception const& x, Context const& context)
{
auto& parserContext = x3::get<parser_context_tag>(context);
- if (parserContext.m_errorMsg.empty())
+ if (parserContext.m_errorMsg.empty()) {
parserContext.m_errorMsg = "Expected " + x.which() + " here:";
+ }
return x3::error_handler_result::rethrow;
}
};
@@ -372,7 +379,8 @@
{
auto& parserContext = x3::get<parser_context_tag>(context);
- if (!parserContext.m_completing)
+ if (!parserContext.m_completing) {
_pass(context) = false;
+ }
}
};
diff --git a/src/ast_path.cpp b/src/ast_path.cpp
index f107cca..44c98c3 100644
--- a/src/ast_path.cpp
+++ b/src/ast_path.cpp
@@ -171,8 +171,9 @@
bool schemaPath_::operator==(const schemaPath_& b) const
{
- if (this->m_nodes.size() != b.m_nodes.size())
+ if (this->m_nodes.size() != b.m_nodes.size()) {
return false;
+ }
return this->m_nodes == b.m_nodes;
}
@@ -188,8 +189,9 @@
bool dataPath_::operator==(const dataPath_& b) const
{
- if (this->m_nodes.size() != b.m_nodes.size())
+ if (this->m_nodes.size() != b.m_nodes.size()) {
return false;
+ }
return this->m_nodes == b.m_nodes;
}
@@ -255,10 +257,11 @@
}
for (const auto& it : path.m_nodes) {
- if (it.m_prefix)
+ if (it.m_prefix) {
res = joinPaths(res, it.m_prefix.value().m_name + ":" + std::visit(nodeToDataStringVisitor(), it.m_suffix));
- else
+ } else {
res = joinPaths(res, (prefixes == Prefixes::Always ? path.m_nodes.at(0).m_prefix.value().m_name + ":" : "") + std::visit(nodeToDataStringVisitor(), it.m_suffix));
+ }
}
return res;
@@ -272,10 +275,11 @@
}
for (const auto& it : path.m_nodes) {
- if (it.m_prefix)
+ if (it.m_prefix) {
res = joinPaths(res, it.m_prefix.value().m_name + ":" + std::visit(nodeToSchemaStringVisitor(), it.m_suffix));
- else
+ } else {
res = joinPaths(res, (prefixes == Prefixes::Always ? path.m_nodes.at(0).m_prefix.value().m_name + ":" : "") + std::visit(nodeToSchemaStringVisitor(), it.m_suffix));
+ }
}
return res;
}
diff --git a/src/cli.cpp b/src/cli.cpp
index 01e504b..8a3536f 100644
--- a/src/cli.cpp
+++ b/src/cli.cpp
@@ -156,8 +156,9 @@
historyFile = std::string(home) + "/.local/share/" + HISTORY_FILE_NAME;
}
- if (historyFile)
+ if (historyFile) {
lineEditor.history_load(historyFile.value());
+ }
while (true) {
auto line = lineEditor.input(parser.currentNode() + "> ");
@@ -191,8 +192,9 @@
lineEditor.history_add(line);
}
- if (historyFile)
+ if (historyFile) {
lineEditor.history_save(historyFile.value());
+ }
return 0;
}
diff --git a/src/interpreter.cpp b/src/interpreter.cpp
index cd84983..3b52960 100644
--- a/src/interpreter.cpp
+++ b/src/interpreter.cpp
@@ -100,8 +100,9 @@
std::cout << "Possible nodes:" << std::endl;
auto recursion{Recursion::NonRecursive};
for (auto it : ls.m_options) {
- if (it == LsOption::Recursive)
+ if (it == LsOption::Recursive) {
recursion = Recursion::Recursive;
+ }
}
auto toPrint = m_datastore.schema()->availableNodes(toCanonicalPath(ls.m_path), recursion);
@@ -218,12 +219,13 @@
void Interpreter::operator()(const help_& help) const
{
- if (help.m_cmd)
+ if (help.m_cmd) {
std::cout << boost::apply_visitor(commandLongHelpVisitor(), help.m_cmd.get()) << std::endl;
- else
+ } else {
boost::mpl::for_each<CommandTypes, boost::type<boost::mpl::_>>([](auto cmd) {
std::cout << commandShortHelpVisitor()(cmd) << std::endl;
});
+ }
}
template <typename PathType>
diff --git a/src/static_schema.cpp b/src/static_schema.cpp
index a7130b3..75ccb4f 100644
--- a/src/static_schema.cpp
+++ b/src/static_schema.cpp
@@ -93,8 +93,9 @@
void StaticSchema::addIdentity(const std::optional<identityRef_>& base, const identityRef_& name)
{
- if (base)
+ if (base) {
m_identities.at(base.value()).emplace(name);
+ }
m_identities.emplace(name, std::set<identityRef_>());
}
diff --git a/src/sysrepo_access.cpp b/src/sysrepo_access.cpp
index 17c86a0..0fac1d8 100644
--- a/src/sysrepo_access.cpp
+++ b/src/sysrepo_access.cpp
@@ -192,8 +192,9 @@
Tree res;
auto fillMap = [this, &res](auto items) {
- if (!items)
+ if (!items) {
return;
+ }
for (unsigned int i = 0; i < items->val_cnt(); i++) {
auto value = leafValueFromVal(items->val(i));
if (m_schema->nodeType(items->val(i)->xpath()) == yang::NodeTypes::LeafList) {
@@ -337,8 +338,9 @@
reportErrors();
}
- if (schema.empty())
+ if (schema.empty()) {
throw std::runtime_error(std::string("Module ") + module + " not available");
+ }
return schema;
}
diff --git a/src/utils.cpp b/src/utils.cpp
index e151417..b3d3601 100644
--- a/src/utils.cpp
+++ b/src/utils.cpp
@@ -189,10 +189,11 @@
std::string operator()(const bool& data) const
{
- if (data)
+ if (data) {
return "true";
- else
+ } else {
return "false";
+ }
}
template <typename T>
diff --git a/src/yang_schema.cpp b/src/yang_schema.cpp
index 9e63348..575e241 100644
--- a/src/yang_schema.cpp
+++ b/src/yang_schema.cpp
@@ -80,8 +80,9 @@
bool YangSchema::leafIsKey(const std::string& leafPath) const
{
auto node = getSchemaNode(leafPath);
- if (!node || node->nodetype() != LYS_LEAF)
+ if (!node || node->nodetype() != LYS_LEAF) {
return false;
+ }
return libyang::Schema_Node_Leaf{node}.is_key().get();
}
@@ -347,8 +348,9 @@
}
for (const auto& node : nodes) {
- if (node->module()->name() == "ietf-yang-library"sv)
+ if (node->module()->name() == "ietf-yang-library"sv) {
continue;
+ }
if (recursion == Recursion::Recursive) {
for (auto it : node->tree_dfs()) {