mirror of
https://github.com/XRPLF/rippled.git
synced 2026-06-03 16:56:48 +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:
@@ -71,7 +71,7 @@ class Invariants_test : public beast::unit_test::suite
|
||||
Preclose const& preclose = {},
|
||||
TxAccount setTxAccount = TxAccount::None)
|
||||
{
|
||||
return doInvariantCheck(
|
||||
doInvariantCheck(
|
||||
test::jtx::Env(*this, defaultAmendments()),
|
||||
expect_logs,
|
||||
precheck,
|
||||
@@ -105,7 +105,7 @@ class Invariants_test : public beast::unit_test::suite
|
||||
if (setTxAccount != TxAccount::None)
|
||||
tx.setAccountID(sfAccount, setTxAccount == TxAccount::A1 ? A1.id() : A2.id());
|
||||
|
||||
return doInvariantCheck(std::move(env), A1, A2, expect_logs, precheck, fee, tx, ters);
|
||||
doInvariantCheck(std::move(env), A1, A2, expect_logs, precheck, fee, tx, ters);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -395,22 +395,21 @@ class Invariants_test : public beast::unit_test::suite
|
||||
for (auto const& trustKeylet :
|
||||
{keylet::line(ammAcctID, A1["USD"]), keylet::line(A1, ammIssue)})
|
||||
{
|
||||
if (auto const line = ac.view().peek(trustKeylet); !line)
|
||||
auto const line = ac.view().peek(trustKeylet);
|
||||
if (!line)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
STAmount const lowLimit = line->at(sfLowLimit);
|
||||
STAmount const highLimit = line->at(sfHighLimit);
|
||||
BEAST_EXPECT(
|
||||
trustDelete(
|
||||
ac.view(),
|
||||
line,
|
||||
lowLimit.getIssuer(),
|
||||
highLimit.getIssuer(),
|
||||
ac.journal) == tesSUCCESS);
|
||||
}
|
||||
|
||||
STAmount const lowLimit = line->at(sfLowLimit);
|
||||
STAmount const highLimit = line->at(sfHighLimit);
|
||||
BEAST_EXPECT(
|
||||
trustDelete(
|
||||
ac.view(),
|
||||
line,
|
||||
lowLimit.getIssuer(),
|
||||
highLimit.getIssuer(),
|
||||
ac.journal) == tesSUCCESS);
|
||||
}
|
||||
|
||||
auto const ammSle = ac.view().peek(keylet::amm(ammKey));
|
||||
@@ -2262,14 +2261,16 @@ class Invariants_test : public beast::unit_test::suite
|
||||
};
|
||||
struct Adjustments
|
||||
{
|
||||
std::optional<int> assetsTotal = {};
|
||||
std::optional<int> assetsAvailable = {};
|
||||
std::optional<int> lossUnrealized = {};
|
||||
std::optional<int> assetsMaximum = {};
|
||||
std::optional<int> sharesTotal = {};
|
||||
std::optional<int> vaultAssets = {};
|
||||
std::optional<AccountAmount> accountAssets = {};
|
||||
std::optional<AccountAmount> accountShares = {};
|
||||
// NOLINTBEGIN(readability-redundant-member-init)
|
||||
std::optional<int> assetsTotal = std::nullopt;
|
||||
std::optional<int> assetsAvailable = std::nullopt;
|
||||
std::optional<int> lossUnrealized = std::nullopt;
|
||||
std::optional<int> assetsMaximum = std::nullopt;
|
||||
std::optional<int> sharesTotal = std::nullopt;
|
||||
std::optional<int> vaultAssets = std::nullopt;
|
||||
std::optional<AccountAmount> accountAssets = std::nullopt;
|
||||
std::optional<AccountAmount> accountShares = std::nullopt;
|
||||
// NOLINTEND(readability-redundant-member-init)
|
||||
};
|
||||
auto constexpr adjust = [&](ApplyView& ac, xrpl::Keylet keylet, Adjustments args) {
|
||||
auto sleVault = ac.peek(keylet);
|
||||
@@ -2291,8 +2292,10 @@ class Invariants_test : public beast::unit_test::suite
|
||||
if (args.assetsTotal)
|
||||
(*sleVault)[sfAssetsTotal] = *(*sleVault)[sfAssetsTotal] + *args.assetsTotal;
|
||||
if (args.assetsAvailable)
|
||||
{
|
||||
(*sleVault)[sfAssetsAvailable] =
|
||||
*(*sleVault)[sfAssetsAvailable] + *args.assetsAvailable;
|
||||
}
|
||||
ac.update(sleVault);
|
||||
|
||||
if (args.sharesTotal)
|
||||
@@ -2325,7 +2328,9 @@ class Invariants_test : public beast::unit_test::suite
|
||||
ac.update(sleMPToken);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false; // Not supporting testing with IOU
|
||||
}
|
||||
}
|
||||
|
||||
if (args.accountAssets)
|
||||
@@ -2349,7 +2354,9 @@ class Invariants_test : public beast::unit_test::suite
|
||||
ac.update(sleMPToken);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false; // Not supporting testing with IOU
|
||||
}
|
||||
}
|
||||
|
||||
if (args.accountShares)
|
||||
|
||||
Reference in New Issue
Block a user