mirror of
https://github.com/XRPLF/clio.git
synced 2026-06-09 11:46:44 +00:00
chore: Enable more clang-tidy checks (#3054)
This commit is contained in:
@@ -130,7 +130,7 @@ public:
|
||||
*
|
||||
* @return The report
|
||||
*/
|
||||
boost::json::object
|
||||
[[nodiscard]] boost::json::object
|
||||
report() const;
|
||||
|
||||
private:
|
||||
@@ -152,7 +152,7 @@ private:
|
||||
void
|
||||
registerError(std::uint64_t count);
|
||||
|
||||
boost::json::object
|
||||
[[nodiscard]] boost::json::object
|
||||
report() const;
|
||||
|
||||
private:
|
||||
|
||||
@@ -188,7 +188,7 @@ BackendInterface::fetchBookOffers(
|
||||
auto mid2 = std::chrono::system_clock::now();
|
||||
numSucc++;
|
||||
succMillis += getMillis(mid2 - mid1);
|
||||
if (!offerDir || offerDir->key >= bookEnd) {
|
||||
if (not offerDir.has_value() || offerDir->key >= bookEnd) {
|
||||
LOG(log_.trace()) << "offerDir.has_value() " << offerDir.has_value() << " breaking";
|
||||
break;
|
||||
}
|
||||
@@ -208,8 +208,10 @@ BackendInterface::fetchBookOffers(
|
||||
auto nextKey = ripple::keylet::page(uTipIndex, next);
|
||||
auto nextDir = fetchLedgerObject(nextKey.key, ledgerSequence, yield);
|
||||
ASSERT(nextDir.has_value(), "Next dir must exist");
|
||||
// NOLINTBEGIN(bugprone-unchecked-optional-access)
|
||||
offerDir->blob = *nextDir;
|
||||
offerDir->key = nextKey.key;
|
||||
// NOLINTEND(bugprone-unchecked-optional-access)
|
||||
}
|
||||
auto mid3 = std::chrono::system_clock::now();
|
||||
pageMillis += getMillis(mid3 - mid2);
|
||||
@@ -312,6 +314,7 @@ BackendInterface::fetchLedgerPage(
|
||||
return (cursor ? *cursor : kFIRST_KEY);
|
||||
}();
|
||||
|
||||
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
|
||||
std::uint32_t const seq = outOfOrder ? range_->maxSequence : ledgerSequence;
|
||||
auto succ = fetchSuccessorKey(curCursor, seq, yield);
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ public:
|
||||
/**
|
||||
* @return The error message as a C string
|
||||
*/
|
||||
char const*
|
||||
[[nodiscard]] char const*
|
||||
what() const throw() override
|
||||
{
|
||||
return "Database read timed out. Please retry the request";
|
||||
|
||||
@@ -99,7 +99,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
NFTsAndCursor
|
||||
[[nodiscard]] NFTsAndCursor
|
||||
fetchNFTsByIssuer(
|
||||
ripple::AccountID const& issuer,
|
||||
std::optional<std::uint32_t> const& taxon,
|
||||
@@ -190,7 +190,7 @@ public:
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::vector<ripple::uint256>
|
||||
[[nodiscard]] std::vector<ripple::uint256>
|
||||
fetchAccountRoots(
|
||||
std::uint32_t number,
|
||||
std::uint32_t pageSize,
|
||||
|
||||
@@ -102,7 +102,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
NFTsAndCursor
|
||||
[[nodiscard]] NFTsAndCursor
|
||||
fetchNFTsByIssuer(
|
||||
ripple::AccountID const& issuer,
|
||||
std::optional<std::uint32_t> const& taxon,
|
||||
@@ -162,7 +162,7 @@ public:
|
||||
* @param yield The coroutine context.
|
||||
* @return A vector of ripple::uint256 representing the account root hashes.
|
||||
*/
|
||||
std::vector<ripple::uint256>
|
||||
[[nodiscard]] std::vector<ripple::uint256>
|
||||
fetchAccountRoots(
|
||||
[[maybe_unused]] std::uint32_t number,
|
||||
[[maybe_unused]] std::uint32_t pageSize,
|
||||
@@ -175,7 +175,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<ripple::uint256>
|
||||
[[nodiscard]] std::vector<ripple::uint256>
|
||||
fetchNFTIDsByTaxon(
|
||||
ripple::AccountID const& issuer,
|
||||
std::uint32_t const taxon,
|
||||
@@ -198,7 +198,7 @@ private:
|
||||
return nftIDs;
|
||||
}
|
||||
|
||||
std::vector<ripple::uint256>
|
||||
[[nodiscard]] std::vector<ripple::uint256>
|
||||
fetchNFTIDsWithoutTaxon(
|
||||
ripple::AccountID const& issuer,
|
||||
std::uint32_t const limit,
|
||||
@@ -242,7 +242,7 @@ private:
|
||||
* @brief Takes a list of NFT IDs, fetches their full data, and assembles the final result with
|
||||
* a cursor.
|
||||
*/
|
||||
NFTsAndCursor
|
||||
[[nodiscard]] NFTsAndCursor
|
||||
populateNFTsAndCreateCursor(
|
||||
std::vector<ripple::uint256> const& nftIDs,
|
||||
std::uint32_t const ledgerSequence,
|
||||
|
||||
@@ -55,7 +55,7 @@ public:
|
||||
* @param seq The sequence to fetch for
|
||||
* @return If found in cache, will return the cached Blob; otherwise nullopt is returned
|
||||
*/
|
||||
virtual std::optional<Blob>
|
||||
[[nodiscard]] virtual std::optional<Blob>
|
||||
get(ripple::uint256 const& key, uint32_t seq) const = 0;
|
||||
|
||||
/**
|
||||
@@ -65,7 +65,7 @@ public:
|
||||
* @param seq The sequence to fetch for
|
||||
* @return If found in deleted cache, will return the cached Blob; otherwise nullopt is returned
|
||||
*/
|
||||
virtual std::optional<Blob>
|
||||
[[nodiscard]] virtual std::optional<Blob>
|
||||
getDeleted(ripple::uint256 const& key, uint32_t seq) const = 0;
|
||||
|
||||
/**
|
||||
@@ -77,7 +77,7 @@ public:
|
||||
* @param seq The sequence to fetch for
|
||||
* @return If found in cache, will return the cached successor; otherwise nullopt is returned
|
||||
*/
|
||||
virtual std::optional<LedgerObject>
|
||||
[[nodiscard]] virtual std::optional<LedgerObject>
|
||||
getSuccessor(ripple::uint256 const& key, uint32_t seq) const = 0;
|
||||
|
||||
/**
|
||||
@@ -89,7 +89,7 @@ public:
|
||||
* @param seq The sequence to fetch for
|
||||
* @return If found in cache, will return the cached predcessor; otherwise nullopt is returned
|
||||
*/
|
||||
virtual std::optional<LedgerObject>
|
||||
[[nodiscard]] virtual std::optional<LedgerObject>
|
||||
getPredecessor(ripple::uint256 const& key, uint32_t seq) const = 0;
|
||||
|
||||
/**
|
||||
@@ -101,7 +101,7 @@ public:
|
||||
/**
|
||||
* @return true if the cache is disabled; false otherwise
|
||||
*/
|
||||
virtual bool
|
||||
[[nodiscard]] virtual bool
|
||||
isDisabled() const = 0;
|
||||
|
||||
/**
|
||||
@@ -117,33 +117,33 @@ public:
|
||||
/**
|
||||
* @return The latest ledger sequence for which cache is available.
|
||||
*/
|
||||
virtual uint32_t
|
||||
[[nodiscard]] virtual uint32_t
|
||||
latestLedgerSequence() const = 0;
|
||||
|
||||
/**
|
||||
* @return true if the cache has all data for the most recent ledger; false otherwise
|
||||
*/
|
||||
virtual bool
|
||||
[[nodiscard]] virtual bool
|
||||
isFull() const = 0;
|
||||
|
||||
/**
|
||||
* @return The total size of the cache.
|
||||
*/
|
||||
virtual size_t
|
||||
[[nodiscard]] virtual size_t
|
||||
size() const = 0;
|
||||
|
||||
/**
|
||||
* @return A number representing the success rate of hitting an object in the cache versus
|
||||
* missing it.
|
||||
*/
|
||||
virtual float
|
||||
[[nodiscard]] virtual float
|
||||
getObjectHitRate() const = 0;
|
||||
|
||||
/**
|
||||
* @return A number representing the success rate of hitting a successor in the cache versus
|
||||
* missing it.
|
||||
*/
|
||||
virtual float
|
||||
[[nodiscard]] virtual float
|
||||
getSuccessorHitRate() const = 0;
|
||||
|
||||
/**
|
||||
|
||||
@@ -564,7 +564,7 @@ public:
|
||||
<< ", key = " << ripple::to_string(key);
|
||||
if (auto const res = executor_.read(yield, schema_->selectObject, key, sequence); res) {
|
||||
if (auto const result = res->template get<Blob, std::uint32_t>(); result) {
|
||||
auto [_, seq] = result.value();
|
||||
auto [_, seq] = *result;
|
||||
return seq;
|
||||
}
|
||||
LOG(log_.debug()) << "Could not fetch ledger object sequence - no rows";
|
||||
@@ -923,14 +923,15 @@ public:
|
||||
record.tokenID
|
||||
));
|
||||
statements.push_back(schema_->insertNFTURI.bind(
|
||||
record.tokenID, record.ledgerSequence, record.uri.value()
|
||||
record.tokenID, record.ledgerSequence, *record.uri
|
||||
));
|
||||
}
|
||||
} else {
|
||||
// only uri changed, we update the uri table only
|
||||
statements.push_back(schema_->insertNFTURI.bind(
|
||||
record.tokenID, record.ledgerSequence, record.uri.value()
|
||||
));
|
||||
statements.push_back(
|
||||
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
|
||||
schema_->insertNFTURI.bind(record.tokenID, record.ledgerSequence, *record.uri)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1002,7 +1003,7 @@ protected:
|
||||
return false;
|
||||
}
|
||||
|
||||
if (not maybeSuccess.value()) {
|
||||
if (not *maybeSuccess) {
|
||||
LOG(log_.warn()) << "Update failed. Checking if DB state is what we expect";
|
||||
|
||||
// error may indicate that another writer wrote something.
|
||||
|
||||
@@ -65,7 +65,7 @@ public:
|
||||
/**
|
||||
* @return The final error message as a std::string
|
||||
*/
|
||||
std::string
|
||||
[[nodiscard]] std::string
|
||||
message() const
|
||||
{
|
||||
return message_;
|
||||
@@ -74,7 +74,7 @@ public:
|
||||
/**
|
||||
* @return The error code
|
||||
*/
|
||||
uint32_t
|
||||
[[nodiscard]] uint32_t
|
||||
code() const
|
||||
{
|
||||
return code_;
|
||||
@@ -83,7 +83,7 @@ public:
|
||||
/**
|
||||
* @return true if the wrapped error is considered a timeout; false otherwise
|
||||
*/
|
||||
bool
|
||||
[[nodiscard]] bool
|
||||
isTimeout() const
|
||||
{
|
||||
return code_ == CASS_ERROR_LIB_NO_HOSTS_AVAILABLE or
|
||||
@@ -94,7 +94,7 @@ public:
|
||||
/**
|
||||
* @return true if the wrapped error is an invalid query; false otherwise
|
||||
*/
|
||||
bool
|
||||
[[nodiscard]] bool
|
||||
isInvalidQuery() const
|
||||
{
|
||||
return code_ == CASS_ERROR_SERVER_INVALID_QUERY;
|
||||
|
||||
@@ -114,7 +114,7 @@ public:
|
||||
*
|
||||
* @return Possibly an error
|
||||
*/
|
||||
[[maybe_unused]] MaybeErrorType
|
||||
[[nodiscard]] [[maybe_unused]] MaybeErrorType
|
||||
disconnect() const;
|
||||
|
||||
/**
|
||||
@@ -162,7 +162,7 @@ public:
|
||||
* @return The result or an error
|
||||
*/
|
||||
template <typename... Args>
|
||||
[[maybe_unused]] ResultOrErrorType
|
||||
[[nodiscard]] [[maybe_unused]] ResultOrErrorType
|
||||
execute(std::string_view query, Args&&... args) const
|
||||
{
|
||||
return asyncExecute<Args...>(query, std::forward<Args>(args)...).get();
|
||||
@@ -189,7 +189,7 @@ public:
|
||||
* @param statements The statements to execute
|
||||
* @return Possibly an error
|
||||
*/
|
||||
[[maybe_unused]] MaybeErrorType
|
||||
[[nodiscard]] [[maybe_unused]] MaybeErrorType
|
||||
executeEach(std::vector<StatementType> const& statements) const;
|
||||
|
||||
/**
|
||||
@@ -250,7 +250,7 @@ public:
|
||||
* @param statement The statement to execute
|
||||
* @return The result or an error
|
||||
*/
|
||||
[[maybe_unused]] ResultOrErrorType
|
||||
[[nodiscard]] [[maybe_unused]] ResultOrErrorType
|
||||
execute(StatementType const& statement) const;
|
||||
|
||||
/**
|
||||
@@ -270,7 +270,7 @@ public:
|
||||
* @param statements The statements to execute
|
||||
* @return Possibly an error
|
||||
*/
|
||||
[[maybe_unused]] MaybeErrorType
|
||||
[[nodiscard]] [[maybe_unused]] MaybeErrorType
|
||||
execute(std::vector<StatementType> const& statements) const;
|
||||
|
||||
/**
|
||||
|
||||
@@ -123,8 +123,8 @@ Cluster::setupContactPoints(Settings::ContactPoints const& points)
|
||||
}
|
||||
|
||||
if (points.port) {
|
||||
auto const rc = cass_cluster_set_port(*this, points.port.value());
|
||||
throwErrorIfNeeded(rc, "port", to_string(points.port.value()));
|
||||
auto const rc = cass_cluster_set_port(*this, *points.port);
|
||||
throwErrorIfNeeded(rc, "port", to_string(*points.port));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,10 +158,8 @@ Cluster::setupCredentials(Settings const& settings)
|
||||
if (not settings.username || not settings.password)
|
||||
return;
|
||||
|
||||
LOG(log_.debug()) << "Set credentials; username: " << settings.username.value();
|
||||
cass_cluster_set_credentials(
|
||||
*this, settings.username.value().c_str(), settings.password.value().c_str()
|
||||
);
|
||||
LOG(log_.debug()) << "Set credentials; username: " << *settings.username;
|
||||
cass_cluster_set_credentials(*this, settings.username->c_str(), settings.password->c_str());
|
||||
}
|
||||
|
||||
} // namespace data::cassandra::impl
|
||||
|
||||
@@ -525,13 +525,13 @@ private:
|
||||
{
|
||||
// mutex lock required to prevent race condition around spurious
|
||||
// wakeup
|
||||
std::lock_guard const lck(throttleMutex_);
|
||||
std::scoped_lock const lck(throttleMutex_);
|
||||
throttleCv_.notify_one();
|
||||
}
|
||||
if (cur == 0) {
|
||||
// mutex lock required to prevent race condition around spurious
|
||||
// wakeup
|
||||
std::lock_guard const lck(syncMutex_);
|
||||
std::scoped_lock const lck(syncMutex_);
|
||||
syncCv_.notify_one();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,10 +13,10 @@ namespace data::cassandra::impl {
|
||||
struct Future : public ManagedObject<CassFuture> {
|
||||
/* implicit */ Future(CassFuture* ptr);
|
||||
|
||||
MaybeError
|
||||
[[nodiscard]] MaybeError
|
||||
await() const;
|
||||
|
||||
ResultOrError
|
||||
[[nodiscard]] ResultOrError
|
||||
get() const;
|
||||
};
|
||||
|
||||
|
||||
@@ -108,7 +108,7 @@ struct Result : public ManagedObject<CassResult const> {
|
||||
hasRows() const;
|
||||
|
||||
template <typename... RowTypes>
|
||||
std::optional<std::tuple<RowTypes...>>
|
||||
[[nodiscard]] std::optional<std::tuple<RowTypes...>>
|
||||
get() const
|
||||
requires(std::tuple_size<std::tuple<RowTypes...>>{} > 1)
|
||||
{
|
||||
@@ -126,7 +126,7 @@ struct Result : public ManagedObject<CassResult const> {
|
||||
}
|
||||
|
||||
template <typename RowType>
|
||||
std::optional<RowType>
|
||||
[[nodiscard]] std::optional<RowType>
|
||||
get() const
|
||||
{
|
||||
// row managed internally by cassandra driver, hence no ManagedObject.
|
||||
@@ -153,7 +153,7 @@ public:
|
||||
hasMore() const;
|
||||
|
||||
template <typename... RowTypes>
|
||||
std::tuple<RowTypes...>
|
||||
[[nodiscard]] std::tuple<RowTypes...>
|
||||
extractCurrentRow() const
|
||||
{
|
||||
// note: row is invalidated on each iteration.
|
||||
|
||||
@@ -171,7 +171,7 @@ public:
|
||||
* @return A bound and ready to execute Statement object
|
||||
*/
|
||||
template <typename... Args>
|
||||
Statement
|
||||
[[nodiscard]] Statement
|
||||
bind(Args&&... args) const
|
||||
{
|
||||
Statement statement = cass_prepared_bind(*this);
|
||||
|
||||
@@ -93,7 +93,7 @@ public:
|
||||
|
||||
private:
|
||||
template <typename Type>
|
||||
Type
|
||||
[[nodiscard]] Type
|
||||
extractNext() const
|
||||
{
|
||||
using std::to_string;
|
||||
|
||||
Reference in New Issue
Block a user