refactor: Add simple clang-tidy readability checks (#6556)

This change enables the following clang-tidy checks:
-  readability-avoid-nested-conditional-operator,
-  readability-avoid-return-with-void-value,
-  readability-braces-around-statements,
-  readability-const-return-type,
-  readability-container-contains,
-  readability-container-size-empty,
-  readability-else-after-return,
-  readability-make-member-function-const,
-  readability-redundant-casting,
-  readability-redundant-inline-specifier,
-  readability-redundant-member-init,
-  readability-redundant-string-init,
-  readability-reference-to-constructed-temporary,
-  readability-static-definition
This commit is contained in:
Alex Kremer
2026-03-18 16:41:49 +00:00
committed by GitHub
parent b92a9a3053
commit 57e4cbbcd9
328 changed files with 4415 additions and 1176 deletions

View File

@@ -60,10 +60,8 @@ getFieldType(Json::StaticString fieldName)
{
return it->second;
}
else
{
Throw<std::runtime_error>("`mappings` is missing field " + std::string(fieldName.c_str()));
}
Throw<std::runtime_error>("`mappings` is missing field " + std::string(fieldName.c_str()));
}
std::string
@@ -110,10 +108,12 @@ class LedgerEntry_test : public beast::unit_test::suite
if (BEAST_EXPECT(jv.isMember(jss::status)))
BEAST_EXPECTS(jv[jss::status] == "error", std::to_string(location.line()));
if (BEAST_EXPECT(jv.isMember(jss::error)))
{
BEAST_EXPECTS(
jv[jss::error] == err,
"Expected error " + err + ", received " + jv[jss::error].asString() + ", at line " +
std::to_string(location.line()) + ", " + jv.toStyledString());
}
if (msg.empty())
{
BEAST_EXPECTS(
@@ -122,11 +122,13 @@ class LedgerEntry_test : public beast::unit_test::suite
"\", at line " + std::to_string(location.line()) + ", " + jv.toStyledString());
}
else if (BEAST_EXPECT(jv.isMember(jss::error_message)))
{
BEAST_EXPECTS(
jv[jss::error_message] == msg,
"Expected error message \"" + msg + "\", received \"" +
jv[jss::error_message].asString() + "\", at line " +
std::to_string(location.line()) + ", " + jv.toStyledString());
}
}
std::vector<Json::Value>
@@ -175,7 +177,7 @@ class LedgerEntry_test : public beast::unit_test::suite
values.reserve(allBadValues.size() - indexSet.size());
for (std::size_t i = 0; i < allBadValues.size(); ++i)
{
if (indexSet.find(i) == indexSet.end())
if (!indexSet.contains(i))
{
values.push_back(allBadValues[i]);
}
@@ -286,10 +288,14 @@ class LedgerEntry_test : public beast::unit_test::suite
Json::Value const jrr = env.rpc(
apiVersion, "json", "ledger_entry", to_string(correctRequest))[jss::result];
if (apiVersion < 2u)
{
checkErrorValue(jrr, "unknownOption", "", location);
}
else
{
checkErrorValue(
jrr, "invalidParams", "No ledger_entry params provided.", location);
}
}
auto tryField = [&](Json::Value fieldValue) -> void {
correctRequest[fieldName] = fieldValue;
@@ -491,9 +497,13 @@ class LedgerEntry_test : public beast::unit_test::suite
env.rpc("json", "ledger_entry", to_string(jvParams))[jss::result];
if (apiVersion < 2u)
{
checkErrorValue(jrr, "unknownOption", "");
}
else
{
checkErrorValue(jrr, "invalidParams", "No ledger_entry params provided.");
}
}
});
}
@@ -2640,7 +2650,9 @@ class LedgerEntry_XChain_test : public beast::unit_test::suite,
BEAST_EXPECT(jv[jss::error_message] == Json::nullValue || jv[jss::error_message] == "");
}
else if (BEAST_EXPECT(jv.isMember(jss::error_message)))
{
BEAST_EXPECT(jv[jss::error_message] == msg);
}
}
void