Skip to content

Commit

Permalink
chore: Add clang-tidy 19 checks (#1774)
Browse files Browse the repository at this point in the history
Fix #1664
  • Loading branch information
godexsoft authored Dec 9, 2024
1 parent a7074db commit 475e309
Show file tree
Hide file tree
Showing 87 changed files with 3,123 additions and 2,699 deletions.
12 changes: 11 additions & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Checks: '-*,
bugprone-chained-comparison,
bugprone-compare-pointer-to-member-virtual-function,
bugprone-copy-constructor-init,
bugprone-crtp-constructor-accessibility,
bugprone-dangling-handle,
bugprone-dynamic-static-initializers,
bugprone-empty-catch,
Expand All @@ -33,9 +34,11 @@ Checks: '-*,
bugprone-non-zero-enum-to-bool-conversion,
bugprone-optional-value-conversion,
bugprone-parent-virtual-call,
bugprone-pointer-arithmetic-on-polymorphic-object,
bugprone-posix-return,
bugprone-redundant-branch-condition,
bugprone-reserved-identifier,
bugprone-return-const-ref-from-parameter,
bugprone-shared-ptr-array-mismatch,
bugprone-signal-handler,
bugprone-signed-char-misuse,
Expand All @@ -55,6 +58,7 @@ Checks: '-*,
bugprone-suspicious-realloc-usage,
bugprone-suspicious-semicolon,
bugprone-suspicious-string-compare,
bugprone-suspicious-stringview-data-usage,
bugprone-swapped-arguments,
bugprone-switch-missing-default-case,
bugprone-terminating-continue,
Expand Down Expand Up @@ -91,16 +95,19 @@ Checks: '-*,
misc-throw-by-value-catch-by-reference,
misc-unused-alias-decls,
misc-unused-using-decls,
misc-use-internal-linkage,
modernize-concat-nested-namespaces,
modernize-deprecated-headers,
modernize-make-shared,
modernize-make-unique,
modernize-pass-by-value,
modernize-type-traits,
modernize-use-designated-initializers,
modernize-use-emplace,
modernize-use-equals-default,
modernize-use-equals-delete,
modernize-use-override,
modernize-use-ranges,
modernize-use-starts-ends-with,
modernize-use-std-numbers,
modernize-use-using,
Expand All @@ -121,9 +128,11 @@ Checks: '-*,
readability-convert-member-functions-to-static,
readability-duplicate-include,
readability-else-after-return,
readability-enum-initial-value,
readability-implicit-bool-conversion,
readability-inconsistent-declaration-parameter-name,
readability-make-member-function-const,
readability-math-missing-parentheses,
readability-misleading-indentation,
readability-non-const-parameter,
readability-redundant-casting,
Expand All @@ -135,7 +144,8 @@ Checks: '-*,
readability-simplify-boolean-expr,
readability-static-accessed-through-instance,
readability-static-definition-in-anonymous-namespace,
readability-suspicious-call-argument
readability-suspicious-call-argument,
readability-use-std-min-max
'

CheckOptions:
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/util/async/ExecutionContextBenchmarks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ benchmarkThreads(benchmark::State& state)
}

template <typename CtxType>
void
static void
benchmarkExecutionContextBatched(benchmark::State& state)
{
auto data = generateData();
Expand All @@ -219,7 +219,7 @@ benchmarkExecutionContextBatched(benchmark::State& state)
}

template <typename CtxType>
void
static void
benchmarkAnyExecutionContextBatched(benchmark::State& state)
{
auto data = generateData();
Expand Down
8 changes: 4 additions & 4 deletions src/data/BackendInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,9 @@ BackendInterface::fetchSuccessorObject(
if (succ) {
auto obj = fetchLedgerObject(*succ, ledgerSequence, yield);
if (!obj)
return {{*succ, {}}};
return {{.key = *succ, .blob = {}}};

return {{*succ, *obj}};
return {{.key = *succ, .blob = *obj}};
}
return {};
}
Expand Down Expand Up @@ -283,7 +283,7 @@ BackendInterface::updateRange(uint32_t newMax)
);

if (!range) {
range = {newMax, newMax};
range = {.minSequence = newMax, .maxSequence = newMax};
} else {
range->maxSequence = newMax;
}
Expand All @@ -299,7 +299,7 @@ BackendInterface::setRange(uint32_t min, uint32_t max, bool force)
ASSERT(not range.has_value(), "Range was already set");
}

range = {min, max};
range = {.minSequence = min, .maxSequence = max};
}

LedgerPage
Expand Down
4 changes: 2 additions & 2 deletions src/data/CassandraBackend.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class BasicCassandraBackend : public BackendInterface {
{
auto rng = fetchLedgerRange();
if (!rng)
return {{}, {}};
return {.txns = {}, .cursor = {}};

Statement const statement = [this, forward, &account]() {
if (forward)
Expand Down Expand Up @@ -399,7 +399,7 @@ class BasicCassandraBackend : public BackendInterface {
{
auto rng = fetchLedgerRange();
if (!rng)
return {{}, {}};
return {.txns = {}, .cursor = {}};

Statement const statement = [this, forward, &tokenID]() {
if (forward)
Expand Down
6 changes: 3 additions & 3 deletions src/data/LedgerCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ LedgerCache::update(std::vector<LedgerObject> const& objs, uint32_t seq, bool is

auto& e = map_[obj.key];
if (seq > e.seq) {
e = {seq, obj.blob};
e = {.seq = seq, .blob = obj.blob};
}
} else {
map_.erase(obj.key);
Expand All @@ -101,7 +101,7 @@ LedgerCache::getSuccessor(ripple::uint256 const& key, uint32_t seq) const
if (e == map_.end())
return {};
++successorHitCounter_.get();
return {{e->first, e->second.blob}};
return {{.key = e->first, .blob = e->second.blob}};
}

std::optional<LedgerObject>
Expand All @@ -117,7 +117,7 @@ LedgerCache::getPredecessor(ripple::uint256 const& key, uint32_t seq) const
if (e == map_.begin())
return {};
--e;
return {{e->first, e->second.blob}};
return {{.key = e->first, .blob = e->second.blob}};
}

std::optional<Blob>
Expand Down
4 changes: 2 additions & 2 deletions src/data/cassandra/Handle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Handle::connect() const
Handle::FutureType
Handle::asyncConnect(std::string_view keyspace) const
{
return cass_session_connect_keyspace(session_, cluster_, keyspace.data());
return cass_session_connect_keyspace_n(session_, cluster_, keyspace.data(), keyspace.size());
}

Handle::MaybeErrorType
Expand Down Expand Up @@ -155,7 +155,7 @@ Handle::asyncExecute(std::vector<StatementType> const& statements, std::function
Handle::PreparedStatementType
Handle::prepare(std::string_view query) const
{
Handle::FutureType const future = cass_session_prepare(session_, query.data());
Handle::FutureType const future = cass_session_prepare_n(session_, query.data(), query.size());
auto const rc = future.await();
if (rc)
return cass_future_get_prepared(future);
Expand Down
4 changes: 2 additions & 2 deletions src/data/cassandra/SettingsProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
namespace data::cassandra {

namespace impl {
inline Settings::ContactPoints
inline static Settings::ContactPoints
tag_invoke(boost::json::value_to_tag<Settings::ContactPoints>, boost::json::value const& value)
{
if (not value.is_object()) {
Expand All @@ -59,7 +59,7 @@ tag_invoke(boost::json::value_to_tag<Settings::ContactPoints>, boost::json::valu
return out;
}

inline Settings::SecureConnectionBundle
inline static Settings::SecureConnectionBundle
tag_invoke(boost::json::value_to_tag<Settings::SecureConnectionBundle>, boost::json::value const& value)
{
if (not value.is_string())
Expand Down
2 changes: 1 addition & 1 deletion src/data/cassandra/impl/Statement.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class Statement : public ManagedObject<CassStatement> {
*/
template <typename... Args>
explicit Statement(std::string_view query, Args&&... args)
: ManagedObject{cass_statement_new(query.data(), sizeof...(args)), deleter}
: ManagedObject{cass_statement_new_n(query.data(), query.size(), sizeof...(args)), deleter}
{
cass_statement_set_consistency(*this, CASS_CONSISTENCY_QUORUM);
cass_statement_set_is_idempotent(*this, cass_true);
Expand Down
12 changes: 9 additions & 3 deletions src/etl/MPTHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <xrpl/protocol/SField.h>
#include <xrpl/protocol/STLedgerEntry.h>
#include <xrpl/protocol/STObject.h>
#include <xrpl/protocol/Serializer.h>
#include <xrpl/protocol/TER.h>
#include <xrpl/protocol/TxFormats.h>

Expand All @@ -41,7 +42,8 @@ namespace etl {
* @param txMeta Transaction metadata
* @return MPT and holder account pair
*/
static std::optional<MPTHolderData>
std::optional<MPTHolderData>
// NOLINTNEXTLINE(misc-use-internal-linkage)
getMPTokenAuthorize(ripple::TxMeta const& txMeta)
{
for (ripple::STObject const& node : txMeta.getNodes()) {
Expand All @@ -50,13 +52,16 @@ getMPTokenAuthorize(ripple::TxMeta const& txMeta)

if (node.getFName() == ripple::sfCreatedNode) {
auto const& newMPT = node.peekAtField(ripple::sfNewFields).downcast<ripple::STObject>();
return MPTHolderData{newMPT[ripple::sfMPTokenIssuanceID], newMPT.getAccountID(ripple::sfAccount)};
return MPTHolderData{
.mptID = newMPT[ripple::sfMPTokenIssuanceID], .holder = newMPT.getAccountID(ripple::sfAccount)
};
}
}
return {};
}

std::optional<MPTHolderData>
// NOLINTNEXTLINE(misc-use-internal-linkage)
getMPTHolderFromTx(ripple::TxMeta const& txMeta, ripple::STTx const& sttx)
{
if (txMeta.getResultTER() != ripple::tesSUCCESS || sttx.getTxnType() != ripple::TxType::ttMPTOKEN_AUTHORIZE)
Expand All @@ -66,6 +71,7 @@ getMPTHolderFromTx(ripple::TxMeta const& txMeta, ripple::STTx const& sttx)
}

std::optional<MPTHolderData>
// NOLINTNEXTLINE(misc-use-internal-linkage)
getMPTHolderFromObj(std::string const& key, std::string const& blob)
{
ripple::STLedgerEntry const sle =
Expand All @@ -77,7 +83,7 @@ getMPTHolderFromObj(std::string const& key, std::string const& blob)
auto const mptIssuanceID = sle[ripple::sfMPTokenIssuanceID];
auto const holder = sle.getAccountID(ripple::sfAccount);

return MPTHolderData{mptIssuanceID, holder};
return MPTHolderData{.mptID = mptIssuanceID, .holder = holder};
}

} // namespace etl
Loading

0 comments on commit 475e309

Please sign in to comment.