diff --git a/.clang-tidy b/.clang-tidy index a79b565e59..5a1ba7c321 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -45,20 +45,10 @@ Checks: "-*, llvm-namespace-comment, misc-*, - -misc-anonymous-namespace-in-header, - -misc-confusable-identifiers, - -misc-coroutine-hostile-raii, - -misc-misleading-bidirectional, - -misc-misleading-identifier, -misc-multiple-inheritance, - -misc-new-delete-overloads, -misc-no-recursion, - -misc-non-copyable-objects, -misc-non-private-member-variables-in-classes, -misc-override-with-different-visibility, - -misc-predictable-rand, - -misc-unconventional-assign-operator, - -misc-uniqueptr-reset-release, -misc-unused-parameters, -misc-use-anonymous-namespace, -misc-use-internal-linkage, diff --git a/include/xrpl/basics/safe_cast.h b/include/xrpl/basics/safe_cast.h index 483a783f5d..7f2b93a7eb 100644 --- a/include/xrpl/basics/safe_cast.h +++ b/include/xrpl/basics/safe_cast.h @@ -1,5 +1,7 @@ #pragma once +#include // IWYU pragma: keep + #include namespace xrpl { diff --git a/include/xrpl/beast/core/LockFreeStack.h b/include/xrpl/beast/core/LockFreeStack.h index 19225a4343..dd135d2d98 100644 --- a/include/xrpl/beast/core/LockFreeStack.h +++ b/include/xrpl/beast/core/LockFreeStack.h @@ -41,7 +41,7 @@ public: operator=(NodePtr node) { node_ = node; - return static_cast(*this); + return *this; } LockFreeStackIterator& diff --git a/include/xrpl/beast/insight/Gauge.h b/include/xrpl/beast/insight/Gauge.h index b24c4366c3..9a23ea6665 100644 --- a/include/xrpl/beast/insight/Gauge.h +++ b/include/xrpl/beast/insight/Gauge.h @@ -49,6 +49,11 @@ public: impl_->set(value); } + // This is a write-through handle: assignment sets the value of the + // referenced metric. It is const-qualified and returns Gauge const& + // (a non-const Gauge& would require a const_cast), so it does not follow + // the conventional assignment-operator signature. + // NOLINTNEXTLINE(misc-unconventional-assign-operator) Gauge const& operator=(value_type value) const { diff --git a/include/xrpl/beast/utility/Zero.h b/include/xrpl/beast/utility/Zero.h index f54345d437..e28589760b 100644 --- a/include/xrpl/beast/utility/Zero.h +++ b/include/xrpl/beast/utility/Zero.h @@ -26,9 +26,7 @@ struct Zero explicit Zero() = default; }; -namespace { -constexpr Zero kZero{}; -} // namespace +inline constexpr Zero kZero{}; /** Default implementation of signum calls the method on the class. */ template diff --git a/include/xrpl/protocol/STObject.h b/include/xrpl/protocol/STObject.h index c96086b1d0..fe5c611648 100644 --- a/include/xrpl/protocol/STObject.h +++ b/include/xrpl/protocol/STObject.h @@ -555,7 +555,11 @@ public: ValueProxy& operator=(ValueProxy const&) = delete; + // Write-through proxy: assignment sets the referenced field to the given + // value, so it intentionally takes the assigned value rather than a + // ValueProxy. template + // NOLINTNEXTLINE(misc-unconventional-assign-operator) ValueProxy& operator=(U&& u) requires(std::is_assignable_v); @@ -800,6 +804,7 @@ STObject::Proxy::assign(U&& u) template template +// NOLINTNEXTLINE(misc-unconventional-assign-operator) STObject::ValueProxy& STObject::ValueProxy::operator=(U&& u) requires(std::is_assignable_v) diff --git a/src/test/app/LedgerReplay_test.cpp b/src/test/app/LedgerReplay_test.cpp index bac1d8b61f..4cc83608d6 100644 --- a/src/test/app/LedgerReplay_test.cpp +++ b/src/test/app/LedgerReplay_test.cpp @@ -28,6 +28,7 @@ #include #include +#include #include #include #include @@ -452,7 +453,7 @@ struct TestPeerSet : public PeerSet dropRate = 100; } - if (((rand() % 100) + 1) <= dropRate) + if (randInt(1, 100) <= dropRate) return; switch (type) diff --git a/src/test/basics/Number_test.cpp b/src/test/basics/Number_test.cpp index d704efa27a..9383fd6808 100644 --- a/src/test/basics/Number_test.cpp +++ b/src/test/basics/Number_test.cpp @@ -1094,6 +1094,7 @@ public: XRPAmount const xrp0{0}; Number const n0 = xrp0; BEAST_EXPECT(n0 == Number{0}); + // NOLINTNEXTLINE(misc-confusable-identifiers) XRPAmount const xrp1{n0}; BEAST_EXPECT(xrp1 == xrp0); } diff --git a/src/test/rpc/GetAggregatePrice_test.cpp b/src/test/rpc/GetAggregatePrice_test.cpp index 22c021865d..3e0bfa1fd3 100644 --- a/src/test/rpc/GetAggregatePrice_test.cpp +++ b/src/test/rpc/GetAggregatePrice_test.cpp @@ -7,6 +7,7 @@ #include #include +#include #include #include #include @@ -16,7 +17,7 @@ #include #include -#include +#include #include #include #include @@ -173,7 +174,7 @@ public: Oracle const oracle( env, {.owner = owner, - .documentID = rand(), + .documentID = randInt(), .series = {{"XRP", "USD", 740 + i, 1}, {"XRP", "EUR", 740, 1}}, .fee = baseFee}); oracles.emplace_back(owner, oracle.documentID());