Add clang tidy (#864)

Fixes #863
This commit is contained in:
Sergey Kuznetsov
2023-10-03 10:43:54 +01:00
committed by GitHub
parent 69f5025a29
commit 4b53bef1f5
198 changed files with 2168 additions and 1288 deletions

View File

@@ -68,9 +68,7 @@ protected:
boost::log::register_simple_formatter_factory<util::Severity, char>("Severity");
});
namespace src = boost::log::sources;
namespace keywords = boost::log::keywords;
namespace sinks = boost::log::sinks;
namespace expr = boost::log::expressions;
auto core = boost::log::core::get();
@@ -126,7 +124,7 @@ struct AsyncAsioContextTest : virtual public NoLoggerFixture
runner.emplace([&] { ctx.run(); });
}
~AsyncAsioContextTest()
~AsyncAsioContextTest() override
{
work.reset();
if (runner->joinable())

View File

@@ -34,7 +34,7 @@ struct MockLoadBalancer
MOCK_METHOD(void, loadInitialLedger, (std::uint32_t, bool), ());
MOCK_METHOD(std::optional<FakeFetchResponse>, fetchLedger, (uint32_t, bool, bool), ());
MOCK_METHOD(bool, shouldPropagateTxnStream, (Source*), (const));
MOCK_METHOD(bool, shouldPropagateTxnStream, (etl::Source*), (const));
MOCK_METHOD(boost::json::value, toJson, (), (const));
MOCK_METHOD(
std::optional<boost::json::object>,

View File

@@ -36,8 +36,7 @@ hexStringToBinaryString(std::string const& hex)
ripple::uint256
binaryStringToUint256(std::string const& bin)
{
ripple::uint256 uint;
return uint.fromVoid(static_cast<void const*>(bin.data()));
return ripple::uint256::fromVoid(static_cast<void const*>(bin.data()));
}
std::string

View File

@@ -96,7 +96,7 @@ CreatePaymentTransactionObject(
obj.setAccountID(ripple::sfDestination, account2.value());
obj.setFieldU32(ripple::sfSequence, seq);
const char* key = "test";
ripple::Slice slice(key, 4);
ripple::Slice const slice(key, 4);
obj.setFieldVL(ripple::sfSigningPubKey, slice);
return obj;
}
@@ -175,7 +175,7 @@ CreateCreateOfferTransactionObject(
obj.setFieldAmount(ripple::sfFee, amount);
obj.setFieldU32(ripple::sfSequence, seq);
// add amount
ripple::Issue issue1(
ripple::Issue const issue1(
ripple::Currency{currency}, ripple::parseBase58<ripple::AccountID>(std::string(issuer)).value());
if (reverse)
{
@@ -189,7 +189,7 @@ CreateCreateOfferTransactionObject(
}
auto key = "test";
ripple::Slice slice(key, 4);
ripple::Slice const slice(key, 4);
obj.setFieldVL(ripple::sfSigningPubKey, slice);
return obj;
}
@@ -199,9 +199,11 @@ GetIssue(std::string_view currency, std::string_view issuerId)
{
// standard currency
if (currency.size() == 3)
{
return ripple::Issue(
ripple::to_currency(std::string(currency)),
ripple::parseBase58<ripple::AccountID>(std::string(issuerId)).value());
}
return ripple::Issue(
ripple::Currency{currency}, ripple::parseBase58<ripple::AccountID>(std::string(issuerId)).value());
}
@@ -217,7 +219,7 @@ CreateMetaDataForBookChange(
int perviousTakerPays)
{
ripple::STObject finalFields(ripple::sfFinalFields);
ripple::Issue issue1 = GetIssue(currency, issueId);
ripple::Issue const issue1 = GetIssue(currency, issueId);
finalFields.setFieldAmount(ripple::sfTakerPays, ripple::STAmount(issue1, finalTakerPays));
finalFields.setFieldAmount(ripple::sfTakerGets, ripple::STAmount(finalTakerGets, false));
ripple::STObject previousFields(ripple::sfPreviousFields);
@@ -246,7 +248,7 @@ CreateMetaDataForCreateOffer(
bool reverse)
{
ripple::STObject finalFields(ripple::sfNewFields);
ripple::Issue issue1 = GetIssue(currency, issueId);
ripple::Issue const issue1 = GetIssue(currency, issueId);
if (reverse)
{
finalFields.setFieldAmount(ripple::sfTakerGets, ripple::STAmount(issue1, finalTakerPays));
@@ -278,7 +280,7 @@ CreateMetaDataForCancelOffer(
int finalTakerPays)
{
ripple::STObject finalFields(ripple::sfFinalFields);
ripple::Issue issue1 = GetIssue(currency, issueId);
ripple::Issue const issue1 = GetIssue(currency, issueId);
finalFields.setFieldAmount(ripple::sfTakerPays, ripple::STAmount(issue1, finalTakerPays));
finalFields.setFieldAmount(ripple::sfTakerGets, ripple::STAmount(finalTakerGets, false));
ripple::STObject metaObj(ripple::sfTransactionMetaData);
@@ -327,7 +329,7 @@ CreatePaymentChannelLedgerObject(
channel.setFieldU32(ripple::sfFlags, 0);
uint8_t key[33] = {0};
key[0] = 2; // KeyType::secp256k1
ripple::Slice slice(key, 33);
ripple::Slice const slice(key, 33);
channel.setFieldVL(ripple::sfPublicKey, slice);
return channel;
}
@@ -372,9 +374,9 @@ CreateOfferLedgerObject(
offer.setAccountID(ripple::sfAccount, GetAccountIDWithString(account));
offer.setFieldU32(ripple::sfSequence, 0);
offer.setFieldU32(ripple::sfFlags, 0);
ripple::Issue issue1 = GetIssue(getsCurrency, getsIssueId);
ripple::Issue const issue1 = GetIssue(getsCurrency, getsIssueId);
offer.setFieldAmount(ripple::sfTakerGets, ripple::STAmount(issue1, takerGets));
ripple::Issue issue2 = GetIssue(paysCurrency, paysIssueId);
ripple::Issue const issue2 = GetIssue(paysCurrency, paysIssueId);
offer.setFieldAmount(ripple::sfTakerPays, ripple::STAmount(issue2, takerPays));
offer.setFieldH256(ripple::sfBookDirectory, ripple::uint256{});
offer.setFieldU64(ripple::sfBookNode, 0);
@@ -551,7 +553,7 @@ CreateMintNFTTxWithMetadata(
tx.setFieldU32(ripple::sfNFTokenTaxon, nfTokenTaxon);
tx.setFieldU32(ripple::sfSequence, seq);
const char* key = "test";
ripple::Slice slice(key, 4);
ripple::Slice const slice(key, 4);
tx.setFieldVL(ripple::sfSigningPubKey, slice);
// meta
@@ -607,7 +609,7 @@ CreateAcceptNFTOfferTxWithMetadata(std::string_view accountId, uint32_t seq, uin
tx.setFieldU32(ripple::sfSequence, seq);
tx.setFieldH256(ripple::sfNFTokenBuyOffer, ripple::uint256{INDEX1});
const char* key = "test";
ripple::Slice slice(key, 4);
ripple::Slice const slice(key, 4);
tx.setFieldVL(ripple::sfSigningPubKey, slice);
// meta
@@ -655,7 +657,7 @@ CreateCancelNFTOffersTxWithMetadata(
});
tx.setFieldV256(ripple::sfNFTokenOffers, offers);
const char* key = "test";
ripple::Slice slice(key, 4);
ripple::Slice const slice(key, 4);
tx.setFieldVL(ripple::sfSigningPubKey, slice);
// meta
@@ -706,7 +708,7 @@ CreateCreateNFTOfferTxWithMetadata(
tx.setFieldU32(ripple::sfSequence, seq);
tx.setFieldH256(ripple::sfNFTokenID, ripple::uint256{nftId});
const char* key = "test";
ripple::Slice slice(key, 4);
ripple::Slice const slice(key, 4);
tx.setFieldVL(ripple::sfSigningPubKey, slice);
// meta
@@ -735,7 +737,7 @@ CreateAmendmentsObject(std::vector<ripple::uint256> const& enabledAmendments)
auto amendments = ripple::STObject(ripple::sfLedgerEntry);
amendments.setFieldU16(ripple::sfLedgerEntryType, ripple::ltAMENDMENTS);
amendments.setFieldU32(ripple::sfFlags, 0);
ripple::STVector256 list(enabledAmendments);
ripple::STVector256 const list(enabledAmendments);
amendments.setFieldV256(ripple::sfAmendments, list);
return amendments;
}

View File

@@ -189,13 +189,13 @@ CreateOfferLedgerObject(
int takerGets,
int takerPays,
std::string_view getsCurrency,
std::string_view payssCurrency,
std::string_view paysCurrency,
std::string_view getsIssueId,
std::string_view paysIssueId,
std::string_view bookDirId);
[[nodiscard]] ripple::STObject
CreateTicketLedgerObject(std::string_view rootIndex, uint32_t sequence);
CreateTicketLedgerObject(std::string_view account, uint32_t sequence);
[[nodiscard]] ripple::STObject
CreateEscrowLedgerObject(std::string_view account, std::string_view dest);
@@ -237,14 +237,14 @@ CreateMintNFTTxWithMetadata(
std::string_view nftID);
[[nodiscard]] data::TransactionAndMetadata
CreateAcceptNFTOfferTxWithMetadata(std::string_view accountId, uint32_t seq, uint32_t fee, std::string_view offerId);
CreateAcceptNFTOfferTxWithMetadata(std::string_view accountId, uint32_t seq, uint32_t fee, std::string_view nftId);
[[nodiscard]] data::TransactionAndMetadata
CreateCancelNFTOffersTxWithMetadata(
std::string_view accountId,
uint32_t seq,
uint32_t fee,
std::vector<std::string> const& nftIds);
std::vector<std::string> const& nftOffers);
[[nodiscard]] data::TransactionAndMetadata
CreateCreateNFTOfferTxWithMetadata(std::string_view accountId, uint32_t seq, uint32_t fee, std::string_view offerId);