mirror of
https://github.com/XRPLF/rippled.git
synced 2026-06-07 02:36:47 +00:00
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:
@@ -107,7 +107,9 @@ Env::close(NetClock::time_point closeTime, std::optional<std::chrono::millisecon
|
||||
// Go through the rpc interface unless we need to simulate
|
||||
// a specific consensus delay.
|
||||
if (consensusDelay)
|
||||
{
|
||||
app().getOPs().acceptLedger(consensusDelay);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto resp = rpc("ledger_accept");
|
||||
@@ -115,11 +117,17 @@ Env::close(NetClock::time_point closeTime, std::optional<std::chrono::millisecon
|
||||
{
|
||||
std::string reason = "internal error";
|
||||
if (resp.isMember("error_what"))
|
||||
{
|
||||
reason = resp["error_what"].asString();
|
||||
}
|
||||
else if (resp.isMember("error_message"))
|
||||
{
|
||||
reason = resp["error_message"].asString();
|
||||
}
|
||||
else if (resp.isMember("error"))
|
||||
{
|
||||
reason = resp["error"].asString();
|
||||
}
|
||||
|
||||
JLOG(journal.error()) << "Env::close() failed: " << reason;
|
||||
res = false;
|
||||
@@ -199,16 +207,14 @@ Env::balance(Account const& account, MPTIssue const& mptIssue) const
|
||||
STAmount const amount{mptIssue, sle->getFieldU64(sfOutstandingAmount), 0, true};
|
||||
return {amount, lookup(issuer).name()};
|
||||
}
|
||||
else
|
||||
{
|
||||
// Holder balance
|
||||
auto const sle = le(keylet::mptoken(id, account));
|
||||
if (!sle)
|
||||
return {STAmount(mptIssue, 0), account.name()};
|
||||
|
||||
STAmount const amount{mptIssue, sle->getFieldU64(sfMPTAmount)};
|
||||
return {amount, lookup(issuer).name()};
|
||||
}
|
||||
// Holder balance
|
||||
auto const sle = le(keylet::mptoken(id, account));
|
||||
if (!sle)
|
||||
return {STAmount(mptIssue, 0), account.name()};
|
||||
|
||||
STAmount const amount{mptIssue, sle->getFieldU64(sfMPTAmount)};
|
||||
return {amount, lookup(issuer).name()};
|
||||
}
|
||||
|
||||
PrettyAmount
|
||||
@@ -336,10 +342,14 @@ Env::parseResult(Json::Value const& jr)
|
||||
parsed.rpcCode.emplace(rpcSUCCESS);
|
||||
}
|
||||
else
|
||||
{
|
||||
error(parsed, result);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
error(parsed, jr);
|
||||
}
|
||||
|
||||
return parsed;
|
||||
}
|
||||
@@ -362,16 +372,14 @@ Env::submit(JTx const& jt, std::source_location const& loc)
|
||||
|
||||
return jr;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Parsing failed or the JTx is
|
||||
// otherwise missing the stx field.
|
||||
parsedResult.ter = ter_ = temMALFORMED;
|
||||
|
||||
return Json::Value();
|
||||
}
|
||||
// Parsing failed or the JTx is
|
||||
// otherwise missing the stx field.
|
||||
parsedResult.ter = ter_ = temMALFORMED;
|
||||
|
||||
return Json::Value();
|
||||
}();
|
||||
return postconditions(jt, parsedResult, jr, loc);
|
||||
postconditions(jt, parsedResult, jr, loc);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -409,7 +417,7 @@ Env::sign_and_submit(JTx const& jt, Json::Value params, std::source_location con
|
||||
test.expect(parsedResult.ter, "ter uninitialized!");
|
||||
ter_ = parsedResult.ter.value_or(telENV_RPC_FAILED);
|
||||
|
||||
return postconditions(jt, parsedResult, jr, loc);
|
||||
postconditions(jt, parsedResult, jr, loc);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -532,9 +540,13 @@ Env::autofill_sig(JTx& jt)
|
||||
}
|
||||
auto const ar = le(account);
|
||||
if (ar && ar->isFieldPresent(sfRegularKey))
|
||||
{
|
||||
jtx::sign(jv, lookup(ar->getAccountID(sfRegularKey)));
|
||||
}
|
||||
else
|
||||
{
|
||||
jtx::sign(jv, account);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
Reference in New Issue
Block a user