Skip to content

Commit af73671

Browse files
style: clang-tidy auto fixes (#2958)
Co-authored-by: godexsoft <385326+godexsoft@users.noreply.github.com>
1 parent 2d6f82c commit af73671

38 files changed

+138
-72
lines changed

src/app/CliArgs.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,11 @@ CliArgs::parse(int argc, char const* argv[])
104104

105105
if (parsed.contains("migrate")) {
106106
auto const opt = parsed["migrate"].as<std::string>();
107-
if (opt == "status")
107+
if (opt == "status") {
108108
return Action{Action::Migrate{
109109
.configPath = std::move(configPath), .subCmd = MigrateSubCmd::status()
110110
}};
111+
}
111112
return Action{Action::Migrate{
112113
.configPath = std::move(configPath), .subCmd = MigrateSubCmd::migration(opt)
113114
}};

src/data/cassandra/Handle.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,11 @@ Handle::disconnect() const
8585
Handle::FutureType
8686
Handle::asyncReconnect(std::string_view keyspace) const
8787
{
88-
if (auto rc = asyncDisconnect().await(); not rc) // sync
88+
if (auto rc = asyncDisconnect().await(); not rc) { // sync
8989
throw std::logic_error(
9090
"Reconnect to keyspace '" + std::string{keyspace} + "' failed: " + rc.error()
9191
);
92+
}
9293
return asyncConnect(keyspace);
9394
}
9495

src/data/cassandra/impl/Statement.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,11 @@ class Statement : public ManagedObject<CassStatement> {
9696
{
9797
using std::to_string;
9898
auto throwErrorIfNeeded = [idx](CassError rc, std::string_view label) {
99-
if (rc != CASS_OK)
99+
if (rc != CASS_OK) {
100100
throw std::logic_error(
101101
fmt::format("[{}] at idx {}: {}", label, idx, cass_error_desc(rc))
102102
);
103+
}
103104
};
104105

105106
auto bindBytes = [this, idx](auto const* data, size_t size) {

src/etl/LoadBalancer.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,11 @@ LoadBalancer::LoadBalancer(
203203
LOG(log_.info()) << "Added etl source - " << sources_.back()->toString();
204204
}
205205

206-
if (!etlState_)
206+
if (!etlState_) {
207207
checkOnETLFailure(
208208
"Failed to fetch ETL state from any source. Please check the configuration and network"
209209
);
210+
}
210211

211212
if (sources_.empty())
212213
checkOnETLFailure("No ETL sources configured. Please check the configuration");

src/etl/NFTHelpers.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,7 @@ getNFTokenMintData(ripple::TxMeta const& txMeta, ripple::STTx const& sttx)
138138
// Find the first NFT ID that doesn't match. We're looking for an
139139
// added NFT, so the one we want will be the mismatch in finalIDs.
140140
// NOLINTNEXTLINE(modernize-use-ranges)
141-
auto const diff =
142-
std::mismatch(finalIDs.begin(), finalIDs.end(), prevIDs.begin(), prevIDs.end());
141+
auto const diff = std::ranges::mismatch(finalIDs, prevIDs);
143142

144143
// There should always be a difference so the returned finalIDs
145144
// iterator should never be end(). But better safe than sorry.
@@ -402,10 +401,11 @@ getNFTDataFromObj(std::uint32_t const seq, std::string const& key, std::string c
402401
auto const owner = ripple::AccountID::fromVoid(key.data());
403402
std::vector<NFTsData> nfts;
404403

405-
for (ripple::STObject const& node : sle.getFieldArray(ripple::sfNFTokens))
404+
for (ripple::STObject const& node : sle.getFieldArray(ripple::sfNFTokens)) {
406405
nfts.emplace_back(
407406
node.getFieldH256(ripple::sfNFTokenID), seq, owner, node.getFieldVL(ripple::sfURI)
408407
);
408+
}
409409

410410
return nfts;
411411
}

src/etl/impl/Registry.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,11 @@ class Registry : public RegistryInterface {
173173
// send entire vector path
174174
{
175175
auto const expand = [&](auto&& p) {
176-
if constexpr (requires { p.onInitialObjects(seq, data, lastKey); })
176+
if constexpr (requires { p.onInitialObjects(seq, data, lastKey); }) {
177177
executeIfAllowed(p, [seq, &data, &lastKey](auto& p) {
178178
p.onInitialObjects(seq, data, lastKey);
179179
});
180+
}
180181
};
181182

182183
std::apply([&expand](auto&&... xs) { (expand(xs), ...); }, store_);
@@ -212,10 +213,11 @@ class Registry : public RegistryInterface {
212213
{
213214
auto const expand = [&]<typename P>(P&& p, model::Transaction const& tx) {
214215
if constexpr (requires { p.onInitialTransaction(data.seq, tx); }) {
215-
if (std::decay_t<P>::spec::wants(tx.type))
216+
if (std::decay_t<P>::spec::wants(tx.type)) {
216217
executeIfAllowed(p, [&data, &tx](auto& p) {
217218
p.onInitialTransaction(data.seq, tx);
218219
});
220+
}
219221
}
220222
};
221223

src/rpc/CredentialHelpers.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,11 @@ fetchCredentialArray(
153153
if (credentials::checkExpired(sleCred, info))
154154
return Error{Status{RippledError::rpcBAD_CREDENTIALS, "credentials are expired"}};
155155

156-
if (sleCred.getAccountID(ripple::sfSubject) != srcAcc)
156+
if (sleCred.getAccountID(ripple::sfSubject) != srcAcc) {
157157
return Error{Status{
158158
RippledError::rpcBAD_CREDENTIALS, "credentials don't belong to the root account"
159159
}};
160+
}
160161

161162
auto credential = ripple::STObject::makeInnerObject(ripple::sfCredential);
162163
credential.setAccountID(ripple::sfIssuer, sleCred.getAccountID(ripple::sfIssuer));

src/rpc/Errors.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,11 @@ makeError(Status const& status)
223223
auto res = visit(
224224
util::OverloadSet{
225225
[&status, &wrapOptional](RippledError err) {
226-
if (err == ripple::rpcUNKNOWN)
226+
if (err == ripple::rpcUNKNOWN) {
227227
return boost::json::object{
228228
{"error", status.message}, {"type", "response"}, {"status", "error"}
229229
};
230+
}
230231

231232
return makeError(err, wrapOptional(status.error), wrapOptional(status.message));
232233
},

src/rpc/Factories.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,11 @@ makeWsContext(
6262
commandValue = request.at("command");
6363
}
6464

65-
if (!commandValue.is_string())
65+
if (!commandValue.is_string()) {
6666
return Error{
6767
{ClioError::RpcCommandIsMissing, "Method/Command is not specified or is not a string."}
6868
};
69+
}
6970

7071
auto const apiVersion = apiVersionParser.get().parse(request);
7172
if (!apiVersion)
@@ -99,11 +100,12 @@ makeHttpContext(
99100

100101
auto const command = boost::json::value_to<std::string>(request.at("method"));
101102

102-
if (command == "subscribe" || command == "unsubscribe")
103+
if (command == "subscribe" || command == "unsubscribe") {
103104
return Error{
104105
{RippledError::rpcBAD_SYNTAX,
105106
"Subscribe and unsubscribe are only allowed for websocket."}
106107
};
108+
}
107109

108110
if (!request.at("params").is_array())
109111
return Error{{ClioError::RpcParamsUnparsable, "Missing params array."}};

src/rpc/RPCHelpers.cpp

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -694,10 +694,11 @@ traverseOwnedNodes(
694694
auto const [nextNFTPage, nftsCount] = cursorMaybe.value();
695695

696696
// if limit reach , we return the next page and max as marker
697-
if (nftsCount >= limit)
697+
if (nftsCount >= limit) {
698698
return AccountCursor{
699699
.index = nextNFTPage, .hint = std::numeric_limits<uint32_t>::max()
700700
};
701+
}
701702

702703
// adjust limit ,continue traversing owned nodes
703704
limit -= nftsCount;
@@ -772,10 +773,11 @@ traverseOwnedNodes(
772773
for (;;) {
773774
auto const ownerDir = backend.fetchLedgerObject(currentIndex.key, sequence, yield);
774775

775-
if (!ownerDir)
776+
if (!ownerDir) {
776777
return std::unexpected{
777778
Status(ripple::rpcINVALID_PARAMS, "Owner directory not found.")
778779
};
780+
}
779781

780782
ripple::SerialIter ownedDirIt{ownerDir->data(), ownerDir->size()};
781783
ripple::SLE const ownedDirSle{ownedDirIt, currentIndex.key};
@@ -1428,25 +1430,29 @@ parseBook(
14281430
std::expected<ripple::Book, Status>
14291431
parseBook(boost::json::object const& request)
14301432
{
1431-
if (!request.contains("taker_pays"))
1433+
if (!request.contains("taker_pays")) {
14321434
return std::unexpected{
14331435
Status{RippledError::rpcINVALID_PARAMS, "Missing field 'taker_pays'"}
14341436
};
1437+
}
14351438

1436-
if (!request.contains("taker_gets"))
1439+
if (!request.contains("taker_gets")) {
14371440
return std::unexpected{
14381441
Status{RippledError::rpcINVALID_PARAMS, "Missing field 'taker_gets'"}
14391442
};
1443+
}
14401444

1441-
if (!request.at("taker_pays").is_object())
1445+
if (!request.at("taker_pays").is_object()) {
14421446
return std::unexpected{
14431447
Status{RippledError::rpcINVALID_PARAMS, "Field 'taker_pays' is not an object"}
14441448
};
1449+
}
14451450

1446-
if (!request.at("taker_gets").is_object())
1451+
if (!request.at("taker_gets").is_object()) {
14471452
return std::unexpected{
14481453
Status{RippledError::rpcINVALID_PARAMS, "Field 'taker_gets' is not an object"}
14491454
};
1455+
}
14501456

14511457
auto takerPays = request.at("taker_pays").as_object();
14521458
if (!takerPays.contains("currency"))
@@ -1482,10 +1488,11 @@ parseBook(boost::json::object const& request)
14821488

14831489
ripple::AccountID payIssuer;
14841490
if (takerPays.contains("issuer")) {
1485-
if (!takerPays.at("issuer").is_string())
1491+
if (!takerPays.at("issuer").is_string()) {
14861492
return std::unexpected{
14871493
Status{RippledError::rpcINVALID_PARAMS, "takerPaysIssuerNotString"}
14881494
};
1495+
}
14891496

14901497
if (!ripple::to_issuer(
14911498
payIssuer, boost::json::value_to<std::string>(takerPays.at("issuer"))
@@ -1512,18 +1519,20 @@ parseBook(boost::json::object const& request)
15121519
}};
15131520
}
15141521

1515-
if ((!isXRP(payCurrency)) && (!takerPays.contains("issuer")))
1522+
if ((!isXRP(payCurrency)) && (!takerPays.contains("issuer"))) {
15161523
return std::unexpected{
15171524
Status{RippledError::rpcSRC_ISR_MALFORMED, "Missing non-XRP issuer."}
15181525
};
1526+
}
15191527

15201528
ripple::AccountID getIssuer;
15211529

15221530
if (takerGets.contains("issuer")) {
1523-
if (!takerGets["issuer"].is_string())
1531+
if (!takerGets["issuer"].is_string()) {
15241532
return std::unexpected{
15251533
Status{RippledError::rpcINVALID_PARAMS, "taker_gets.issuer should be string"}
15261534
};
1535+
}
15271536

15281537
if (!ripple::to_issuer(
15291538
getIssuer, boost::json::value_to<std::string>(takerGets.at("issuer"))

0 commit comments

Comments
 (0)