diff --git a/.clang-tidy b/.clang-tidy index 07274eb53a..e67e7a4c6c 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -10,26 +10,26 @@ Checks: "-*, bugprone-chained-comparison, bugprone-compare-pointer-to-member-virtual-function, bugprone-copy-constructor-init, - # bugprone-crtp-constructor-accessibility, # has issues + bugprone-crtp-constructor-accessibility, bugprone-dangling-handle, bugprone-dynamic-static-initializers, - # bugprone-empty-catch, # has issues + bugprone-empty-catch, bugprone-fold-init-type, - # bugprone-forward-declaration-namespace, # has issues - # bugprone-inaccurate-erase, - # bugprone-inc-dec-in-conditions, - # bugprone-incorrect-enable-if, - # bugprone-incorrect-roundings, - # bugprone-infinite-loop, - # bugprone-integer-division, + bugprone-forward-declaration-namespace, + bugprone-inaccurate-erase, + bugprone-inc-dec-in-conditions, + bugprone-incorrect-enable-if, + bugprone-incorrect-roundings, + bugprone-infinite-loop, + bugprone-integer-division, bugprone-lambda-function-name, - # bugprone-macro-parentheses, # has issues + bugprone-macro-parentheses, bugprone-macro-repeated-side-effects, bugprone-misplaced-operator-in-strlen-in-alloc, bugprone-misplaced-pointer-arithmetic-in-alloc, bugprone-misplaced-widening-cast, bugprone-move-forwarding-reference, - # bugprone-multi-level-implicit-pointer-conversion, # has issues + bugprone-multi-level-implicit-pointer-conversion, bugprone-multiple-new-in-one-expression, bugprone-multiple-statement-macro, bugprone-no-escape, @@ -39,13 +39,13 @@ Checks: "-*, bugprone-pointer-arithmetic-on-polymorphic-object, bugprone-posix-return, bugprone-redundant-branch-condition, - # bugprone-reserved-identifier, # has issues - # bugprone-return-const-ref-from-parameter, # has issues + bugprone-reserved-identifier, + bugprone-return-const-ref-from-parameter, bugprone-shared-ptr-array-mismatch, bugprone-signal-handler, bugprone-signed-char-misuse, bugprone-sizeof-container, - # bugprone-sizeof-expression, # has issues + bugprone-sizeof-expression, bugprone-spuriously-wake-up-functions, bugprone-standalone-empty, bugprone-string-constructor, @@ -62,7 +62,7 @@ Checks: "-*, bugprone-suspicious-string-compare, bugprone-suspicious-stringview-data-usage, bugprone-swapped-arguments, - # bugprone-switch-missing-default-case, # has issues + bugprone-switch-missing-default-case, bugprone-terminating-continue, bugprone-throw-keyword-missing, bugprone-too-small-loop-variable, @@ -73,7 +73,7 @@ Checks: "-*, bugprone-unhandled-self-assignment, bugprone-unique-ptr-array-mismatch, bugprone-unsafe-functions, - # bugprone-use-after-move, # has issues + bugprone-use-after-move, # has issues bugprone-unused-raii, bugprone-unused-return-value, bugprone-unused-local-non-trivial-variable, diff --git a/include/xrpl/basics/BasicConfig.h b/include/xrpl/basics/BasicConfig.h index eaa53f93d6..f6fa5c52dc 100644 --- a/include/xrpl/basics/BasicConfig.h +++ b/include/xrpl/basics/BasicConfig.h @@ -296,7 +296,7 @@ set(T& target, std::string const& name, Section const& section) if ((found_and_valid = val.has_value())) target = *val; } - catch (boost::bad_lexical_cast&) + catch (boost::bad_lexical_cast const&) // NOLINT(bugprone-empty-catch) { } return found_and_valid; @@ -330,7 +330,7 @@ get(Section const& section, std::string const& name, T const& defaultValue = T{} { return section.value_or(name, defaultValue); } - catch (boost::bad_lexical_cast&) + catch (boost::bad_lexical_cast const&) // NOLINT(bugprone-empty-catch) { } return defaultValue; @@ -345,7 +345,7 @@ get(Section const& section, std::string const& name, char const* defaultValue) if (val.has_value()) return *val; } - catch (boost::bad_lexical_cast&) + catch (boost::bad_lexical_cast const&) // NOLINT(bugprone-empty-catch) { } return defaultValue; diff --git a/include/xrpl/basics/CountedObject.h b/include/xrpl/basics/CountedObject.h index 1acba18949..675d1b163b 100644 --- a/include/xrpl/basics/CountedObject.h +++ b/include/xrpl/basics/CountedObject.h @@ -112,7 +112,6 @@ private: return c; } -public: CountedObject() noexcept { getCounter().increment(); @@ -126,10 +125,13 @@ public: CountedObject& operator=(CountedObject const&) noexcept = default; +public: ~CountedObject() noexcept { getCounter().decrement(); } + + friend Object; }; } // namespace xrpl diff --git a/include/xrpl/basics/Log.h b/include/xrpl/basics/Log.h index 08da3e57b5..500a1f37c1 100644 --- a/include/xrpl/basics/Log.h +++ b/include/xrpl/basics/Log.h @@ -226,7 +226,7 @@ private: // expensive argument lists if the stream is not active. #ifndef JLOG #define JLOG(x) \ - if (!x) \ + if (!(x)) \ { \ } \ else \ @@ -235,7 +235,7 @@ private: #ifndef CLOG #define CLOG(ss) \ - if (!ss) \ + if (!(ss)) \ ; \ else \ *ss diff --git a/include/xrpl/basics/SlabAllocator.h b/include/xrpl/basics/SlabAllocator.h index 4ed88a32f7..90e64b58a2 100644 --- a/include/xrpl/basics/SlabAllocator.h +++ b/include/xrpl/basics/SlabAllocator.h @@ -60,7 +60,7 @@ class SlabAllocator { // Use memcpy to avoid unaligned UB // (will optimize to equivalent code) - std::memcpy(data, &l_, sizeof(std::uint8_t*)); + std::memcpy(data, static_cast(&l_), sizeof(std::uint8_t*)); l_ = data; data += item; } @@ -102,7 +102,7 @@ class SlabAllocator { // Use memcpy to avoid unaligned UB // (will optimize to equivalent code) - std::memcpy(&l_, ret, sizeof(std::uint8_t*)); + std::memcpy(static_cast(&l_), ret, sizeof(std::uint8_t*)); } } @@ -127,7 +127,7 @@ class SlabAllocator // Use memcpy to avoid unaligned UB // (will optimize to equivalent code) - std::memcpy(ptr, &l_, sizeof(std::uint8_t*)); + std::memcpy(ptr, static_cast(&l_), sizeof(std::uint8_t*)); l_ = ptr; } }; diff --git a/include/xrpl/beast/container/detail/aged_associative_container.h b/include/xrpl/beast/container/detail/aged_associative_container.h index 34e9560cbb..af6774eb9e 100644 --- a/include/xrpl/beast/container/detail/aged_associative_container.h +++ b/include/xrpl/beast/container/detail/aged_associative_container.h @@ -26,7 +26,7 @@ struct aged_associative_container_extract_t Value const& operator()(Value const& value) const { - return value; + return value; // NOLINT(bugprone-return-const-ref-from-parameter) } }; diff --git a/include/xrpl/beast/container/detail/aged_ordered_container.h b/include/xrpl/beast/container/detail/aged_ordered_container.h index dad0d92e0b..554fed2d58 100644 --- a/include/xrpl/beast/container/detail/aged_ordered_container.h +++ b/include/xrpl/beast/container/detail/aged_ordered_container.h @@ -257,7 +257,8 @@ private: config_t(config_t&& other) : KeyValueCompare(std::move(other.key_compare())) - , beast::detail::empty_base_optimization(std::move(other)) + , beast::detail::empty_base_optimization(std::move( + static_cast&>(other))) , clock(other.clock) { } diff --git a/include/xrpl/beast/core/List.h b/include/xrpl/beast/core/List.h index 560467c8dd..a6ba71680b 100644 --- a/include/xrpl/beast/core/List.h +++ b/include/xrpl/beast/core/List.h @@ -35,9 +35,11 @@ struct CopyConst template class ListNode { -private: + ListNode() = default; + using value_type = T; + friend T; friend class List; template diff --git a/include/xrpl/beast/hash/hash_append.h b/include/xrpl/beast/hash/hash_append.h index d456bb3a73..cfae15e26b 100644 --- a/include/xrpl/beast/hash/hash_append.h +++ b/include/xrpl/beast/hash/hash_append.h @@ -203,7 +203,8 @@ template inline std::enable_if_t::value> hash_append(Hasher& h, T const& t) noexcept { - h(std::addressof(t), sizeof(t)); + // NOLINTNEXTLINE(bugprone-sizeof-expression) + h(static_cast(std::addressof(t)), sizeof(t)); } template diff --git a/include/xrpl/beast/rfc2616.h b/include/xrpl/beast/rfc2616.h index b19c2c511a..f43060eb20 100644 --- a/include/xrpl/beast/rfc2616.h +++ b/include/xrpl/beast/rfc2616.h @@ -53,8 +53,9 @@ is_white(char c) case '\t': case '\v': return true; + default: + return false; }; - return false; } template diff --git a/include/xrpl/beast/unit_test/reporter.h b/include/xrpl/beast/unit_test/reporter.h index 63ad90ff7c..011e2ca3c0 100644 --- a/include/xrpl/beast/unit_test/reporter.h +++ b/include/xrpl/beast/unit_test/reporter.h @@ -118,18 +118,18 @@ private: //------------------------------------------------------------------------------ -template +template void -reporter<_>::suite_results::add(case_results const& r) +reporter::suite_results::add(case_results const& r) { ++cases; total += r.total; failed += r.failed; } -template +template void -reporter<_>::results::add(suite_results const& r) +reporter::results::add(suite_results const& r) { ++suites; total += r.total; @@ -160,13 +160,13 @@ reporter<_>::results::add(suite_results const& r) //------------------------------------------------------------------------------ -template -reporter<_>::reporter(std::ostream& os) : os_(os) +template +reporter::reporter(std::ostream& os) : os_(os) { } -template -reporter<_>::~reporter() +template +reporter::~reporter() { if (results_.top.size() > 0) { @@ -180,9 +180,9 @@ reporter<_>::~reporter() << amount{results_.failed, "failure"} << std::endl; } -template +template std::string -reporter<_>::fmtdur(typename clock_type::duration const& d) +reporter::fmtdur(typename clock_type::duration const& d) { using namespace std::chrono; auto const ms = duration_cast(d); @@ -193,46 +193,46 @@ reporter<_>::fmtdur(typename clock_type::duration const& d) return ss.str(); } -template +template void -reporter<_>::on_suite_begin(suite_info const& info) +reporter::on_suite_begin(suite_info const& info) { suite_results_ = suite_results{info.full_name()}; } -template +template void -reporter<_>::on_suite_end() +reporter::on_suite_end() { results_.add(suite_results_); } -template +template void -reporter<_>::on_case_begin(std::string const& name) +reporter::on_case_begin(std::string const& name) { case_results_ = case_results(name); os_ << suite_results_.name << (case_results_.name.empty() ? "" : (" " + case_results_.name)) << std::endl; } -template +template void -reporter<_>::on_case_end() +reporter::on_case_end() { suite_results_.add(case_results_); } -template +template void -reporter<_>::on_pass() +reporter::on_pass() { ++case_results_.total; } -template +template void -reporter<_>::on_fail(std::string const& reason) +reporter::on_fail(std::string const& reason) { ++case_results_.failed; ++case_results_.total; @@ -240,9 +240,9 @@ reporter<_>::on_fail(std::string const& reason) << std::endl; } -template +template void -reporter<_>::on_log(std::string const& s) +reporter::on_log(std::string const& s) { os_ << s; } diff --git a/include/xrpl/beast/unit_test/results.h b/include/xrpl/beast/unit_test/results.h index b8a8e2aadf..57327639a5 100644 --- a/include/xrpl/beast/unit_test/results.h +++ b/include/xrpl/beast/unit_test/results.h @@ -145,9 +145,9 @@ public: void insert(case_results&& r) { - cont().emplace_back(std::move(r)); total_ += r.tests.total(); failed_ += r.tests.failed(); + cont().emplace_back(std::move(r)); } void diff --git a/include/xrpl/beast/unit_test/suite.h b/include/xrpl/beast/unit_test/suite.h index fa5157e126..2f0b69b8a0 100644 --- a/include/xrpl/beast/unit_test/suite.h +++ b/include/xrpl/beast/unit_test/suite.h @@ -36,7 +36,7 @@ make_reason(String const& reason, char const* file, int line) } // namespace detail -class thread; +class Thread; enum abort_t { no_abort_on_fail, abort_on_fail }; @@ -295,7 +295,7 @@ public: } private: - friend class thread; + friend class Thread; static suite** p_this_suite() @@ -538,7 +538,7 @@ suite::run(runner& r) { run(); } - catch (abort_exception const&) + catch (abort_exception const&) // NOLINT(bugprone-empty-catch) { // ends the suite } diff --git a/include/xrpl/beast/unit_test/thread.h b/include/xrpl/beast/unit_test/thread.h index b49f8ed36e..9267b84ac3 100644 --- a/include/xrpl/beast/unit_test/thread.h +++ b/include/xrpl/beast/unit_test/thread.h @@ -14,7 +14,7 @@ namespace beast { namespace unit_test { /** Replacement for std::thread that handles exceptions in unit tests. */ -class thread +class Thread { private: suite* s_ = nullptr; @@ -24,17 +24,17 @@ public: using id = std::thread::id; using native_handle_type = std::thread::native_handle_type; - thread() = default; - thread(thread const&) = delete; - thread& - operator=(thread const&) = delete; + Thread() = default; + Thread(Thread const&) = delete; + Thread& + operator=(Thread const&) = delete; - thread(thread&& other) : s_(other.s_), t_(std::move(other.t_)) + Thread(Thread&& other) : s_(other.s_), t_(std::move(other.t_)) { } - thread& - operator=(thread&& other) + Thread& + operator=(Thread&& other) { s_ = other.s_; t_ = std::move(other.t_); @@ -42,10 +42,10 @@ public: } template - explicit thread(suite& s, F&& f, Args&&... args) : s_(&s) + explicit Thread(suite& s, F&& f, Args&&... args) : s_(&s) { std::function b = std::bind(std::forward(f), std::forward(args)...); - t_ = std::thread(&thread::run, this, std::move(b)); + t_ = std::thread(&Thread::run, this, std::move(b)); } bool @@ -80,7 +80,7 @@ public: } void - swap(thread& other) + swap(Thread& other) { std::swap(s_, other.s_); std::swap(t_, other.t_); @@ -94,7 +94,7 @@ private: { f(); } - catch (suite::abort_exception const&) + catch (suite::abort_exception const&) // NOLINT(bugprone-empty-catch) { } catch (std::exception const& e) diff --git a/include/xrpl/beast/xor_shift_engine.h b/include/xrpl/beast/xor_shift_engine.h index 4fbe5ec165..85504f51aa 100644 --- a/include/xrpl/beast/xor_shift_engine.h +++ b/include/xrpl/beast/xor_shift_engine.h @@ -43,15 +43,15 @@ private: murmurhash3(result_type x); }; -template -xor_shift_engine<_>::xor_shift_engine(result_type val) +template +xor_shift_engine::xor_shift_engine(result_type val) { seed(val); } -template +template void -xor_shift_engine<_>::seed(result_type seed) +xor_shift_engine::seed(result_type seed) { if (seed == 0) throw std::domain_error("invalid seed"); @@ -59,9 +59,9 @@ xor_shift_engine<_>::seed(result_type seed) s_[1] = murmurhash3(s_[0]); } -template +template auto -xor_shift_engine<_>::operator()() -> result_type +xor_shift_engine::operator()() -> result_type { result_type s1 = s_[0]; result_type const s0 = s_[1]; @@ -70,9 +70,9 @@ xor_shift_engine<_>::operator()() -> result_type return (s_[1] = (s1 ^ s0 ^ (s1 >> 17) ^ (s0 >> 26))) + s0; } -template +template auto -xor_shift_engine<_>::murmurhash3(result_type x) -> result_type +xor_shift_engine::murmurhash3(result_type x) -> result_type { x ^= x >> 33; x *= 0xff51afd7ed558ccdULL; diff --git a/include/xrpl/net/AutoSocket.h b/include/xrpl/net/AutoSocket.h index 29cec23998..1c24e07f05 100644 --- a/include/xrpl/net/AutoSocket.h +++ b/include/xrpl/net/AutoSocket.h @@ -134,7 +134,7 @@ public: { lowest_layer().shutdown(plain_socket::shutdown_both); } - catch (boost::system::system_error& e) + catch (boost::system::system_error const& e) { ec = e.code(); } diff --git a/include/xrpl/protocol/ApiVersion.h b/include/xrpl/protocol/ApiVersion.h index 8772b5a49d..653b4830bf 100644 --- a/include/xrpl/protocol/ApiVersion.h +++ b/include/xrpl/protocol/ApiVersion.h @@ -138,9 +138,11 @@ forApiVersions(Fn const& fn, Args&&... args) { constexpr auto size = maxVer + 1 - minVer; [&](std::index_sequence) { + // NOLINTBEGIN(bugprone-use-after-move) (((void)fn( std::integral_constant{}, std::forward(args)...)), ...); + // NOLINTEND(bugprone-use-after-move) }(std::make_index_sequence{}); } diff --git a/include/xrpl/protocol/Feature.h b/include/xrpl/protocol/Feature.h index 112f66f4a1..cbd41b84f8 100644 --- a/include/xrpl/protocol/Feature.h +++ b/include/xrpl/protocol/Feature.h @@ -125,10 +125,12 @@ namespace detail { #pragma push_macro("XRPL_RETIRE_FIX") #undef XRPL_RETIRE_FIX +// NOLINTBEGIN(bugprone-macro-parentheses) #define XRPL_FEATURE(name, supported, vote) +1 #define XRPL_FIX(name, supported, vote) +1 #define XRPL_RETIRE_FEATURE(name) +1 #define XRPL_RETIRE_FIX(name) +1 +// NOLINTEND(bugprone-macro-parentheses) // This value SHOULD be equal to the number of amendments registered in // Feature.cpp. Because it's only used to reserve storage, and determine how diff --git a/include/xrpl/protocol/KnownFormats.h b/include/xrpl/protocol/KnownFormats.h index c454683e19..d965f43b78 100644 --- a/include/xrpl/protocol/KnownFormats.h +++ b/include/xrpl/protocol/KnownFormats.h @@ -74,10 +74,12 @@ public: Derived classes will load the object with all the known formats. */ +private: KnownFormats() : name_(beast::type_name()) { } +public: /** Destroy the known formats object. The defined formats are deleted. @@ -181,6 +183,7 @@ private: boost::container::flat_map names_; boost::container::flat_map types_; + friend Derived; }; } // namespace xrpl diff --git a/include/xrpl/protocol/LedgerFormats.h b/include/xrpl/protocol/LedgerFormats.h index 06fd1040e1..009a96533a 100644 --- a/include/xrpl/protocol/LedgerFormats.h +++ b/include/xrpl/protocol/LedgerFormats.h @@ -211,7 +211,7 @@ enum LedgerEntryType : std::uint16_t { // lsfRequireDestTag = 0x00020000, // ... // }; -#define TO_VALUE(name, value) name = value, +#define TO_VALUE(name, value) name = (value), #define NULL_NAME(name, values) values #define NULL_OUTPUT(name, value) enum LedgerSpecificFlags : std::uint32_t { XMACRO(NULL_NAME, TO_VALUE, NULL_OUTPUT) }; diff --git a/include/xrpl/protocol/Permissions.h b/include/xrpl/protocol/Permissions.h index 0ec4f04f1a..ea8bd77643 100644 --- a/include/xrpl/protocol/Permissions.h +++ b/include/xrpl/protocol/Permissions.h @@ -20,7 +20,7 @@ enum GranularPermissionType : std::uint32_t { #pragma push_macro("PERMISSION") #undef PERMISSION -#define PERMISSION(type, txType, value) type = value, +#define PERMISSION(type, txType, value) type = (value), #include diff --git a/include/xrpl/protocol/SField.h b/include/xrpl/protocol/SField.h index 7a864b1b58..cbc2c12f4e 100644 --- a/include/xrpl/protocol/SField.h +++ b/include/xrpl/protocol/SField.h @@ -84,7 +84,7 @@ class STCurrency; #pragma push_macro("TO_MAP") #undef TO_MAP -#define TO_ENUM(name, value) name = value, +#define TO_ENUM(name, value) name = (value), #define TO_MAP(name, value) {#name, value}, enum SerializedTypeID { XMACRO(TO_ENUM) }; diff --git a/include/xrpl/protocol/STAmount.h b/include/xrpl/protocol/STAmount.h index 3fa4a53e3f..e33d7f0df4 100644 --- a/include/xrpl/protocol/STAmount.h +++ b/include/xrpl/protocol/STAmount.h @@ -401,7 +401,7 @@ amountFromJsonNoThrow(STAmount& result, Json::Value const& jvSource); inline STAmount const& toSTAmount(STAmount const& a) { - return a; + return a; // NOLINT(bugprone-return-const-ref-from-parameter) } //------------------------------------------------------------------------------ diff --git a/include/xrpl/protocol/STObject.h b/include/xrpl/protocol/STObject.h index 7553521237..561758df16 100644 --- a/include/xrpl/protocol/STObject.h +++ b/include/xrpl/protocol/STObject.h @@ -1188,6 +1188,7 @@ STObject::getFieldByConstRef(SField const& field, V const& empty) const SerializedTypeID const id = rf->getSType(); if (id == STI_NOTPRESENT) + // NOLINTNEXTLINE(bugprone-return-const-ref-from-parameter) return empty; // optional field not present T const* cf = dynamic_cast(rf); diff --git a/include/xrpl/protocol/TxFlags.h b/include/xrpl/protocol/TxFlags.h index 7c2085109f..7bbbd12707 100644 --- a/include/xrpl/protocol/TxFlags.h +++ b/include/xrpl/protocol/TxFlags.h @@ -235,7 +235,7 @@ XMACRO(NULL_NAME, TO_VALUE, NULL_OUTPUT, NULL_MASK_ADJ) // The mask adjustment (maskAdj) allows adding flags back to the mask, making them invalid. // For example, Batch uses MASK_ADJ(tfInnerBatchTxn) to reject tfInnerBatchTxn on outer Batch. #define TO_MASK(name, values, maskAdj) \ - inline constexpr FlagValue tf##name##Mask = ~(tfUniversal values) | maskAdj; + inline constexpr FlagValue tf##name##Mask = ~(tfUniversal values) | (maskAdj); #define VALUE_TO_MASK(name, value) | name #define MASK_ADJ_TO_MASK(value) value XMACRO(TO_MASK, VALUE_TO_MASK, VALUE_TO_MASK, MASK_ADJ_TO_MASK) diff --git a/include/xrpl/protocol/json_get_or_throw.h b/include/xrpl/protocol/json_get_or_throw.h index 4406d9ff24..949fb64cf2 100644 --- a/include/xrpl/protocol/json_get_or_throw.h +++ b/include/xrpl/protocol/json_get_or_throw.h @@ -146,7 +146,7 @@ getOptional(Json::Value const& v, xrpl::SField const& field) { return getOrThrow(v, field); } - catch (...) + catch (...) // NOLINT(bugprone-empty-catch) { } return {}; diff --git a/include/xrpl/server/detail/BasePeer.h b/include/xrpl/server/detail/BasePeer.h index afa1ceb993..35c6acb198 100644 --- a/include/xrpl/server/detail/BasePeer.h +++ b/include/xrpl/server/detail/BasePeer.h @@ -34,6 +34,7 @@ protected: boost::asio::strand strand_; public: + // NOLINTNEXTLINE(bugprone-crtp-constructor-accessibility) BasePeer( Port const& port, Handler& handler, diff --git a/include/xrpl/server/detail/BaseWSPeer.h b/include/xrpl/server/detail/BaseWSPeer.h index 9213a955f0..ebc504a863 100644 --- a/include/xrpl/server/detail/BaseWSPeer.h +++ b/include/xrpl/server/detail/BaseWSPeer.h @@ -392,7 +392,7 @@ BaseWSPeer::cancel_timer() { timer_.cancel(); } - catch (boost::system::system_error const&) + catch (boost::system::system_error const&) // NOLINT(bugprone-empty-catch) { // ignored } diff --git a/include/xrpl/tx/paths/detail/FlowDebugInfo.h b/include/xrpl/tx/paths/detail/FlowDebugInfo.h index 3a1f45fd02..dd25939d27 100644 --- a/include/xrpl/tx/paths/detail/FlowDebugInfo.h +++ b/include/xrpl/tx/paths/detail/FlowDebugInfo.h @@ -220,6 +220,7 @@ struct FlowDebugInfo write_list(amts, get_val, delim); }; auto writeIntList = [&write_list](std::vector const& vals, char delim = ';') { + // NOLINTNEXTLINE(bugprone-return-const-ref-from-parameter) auto get_val = [](size_t const& v) -> size_t const& { return v; }; write_list(vals, get_val); }; diff --git a/include/xrpl/tx/paths/detail/Steps.h b/include/xrpl/tx/paths/detail/Steps.h index 4fa3b09d07..c3269505b1 100644 --- a/include/xrpl/tx/paths/detail/Steps.h +++ b/include/xrpl/tx/paths/detail/Steps.h @@ -429,8 +429,10 @@ toStrands( template struct StepImp : public Step { +private: explicit StepImp() = default; +public: std::pair rev(PaymentSandbox& sb, ApplyView& afView, @@ -470,6 +472,7 @@ struct StepImp : public Step { return get(lhs) == get(rhs); } + friend TDerived; }; /// @endcond diff --git a/src/libxrpl/ledger/ApplyStateTable.cpp b/src/libxrpl/ledger/ApplyStateTable.cpp index 9ebbca8ac5..8e1943499e 100644 --- a/src/libxrpl/ledger/ApplyStateTable.cpp +++ b/src/libxrpl/ledger/ApplyStateTable.cpp @@ -5,6 +5,8 @@ #include #include +#include + namespace xrpl { namespace detail { @@ -374,14 +376,14 @@ ApplyStateTable::erase(ReadView const& base, std::shared_ptr const& sle) { auto const iter = items_.find(sle->key()); if (iter == items_.end()) - LogicError("ApplyStateTable::erase: missing key"); + Throw("ApplyStateTable::erase: missing key"); auto& item = iter->second; if (item.second != sle) - LogicError("ApplyStateTable::erase: unknown SLE"); + Throw("ApplyStateTable::erase: unknown SLE"); switch (item.first) { case Action::erase: - LogicError("ApplyStateTable::erase: double erase"); + Throw("ApplyStateTable::erase: double erase"); break; case Action::insert: items_.erase(iter); @@ -405,7 +407,7 @@ ApplyStateTable::rawErase(ReadView const& base, std::shared_ptr const& sle) switch (item.first) { case Action::erase: - LogicError("ApplyStateTable::rawErase: double erase"); + Throw("ApplyStateTable::rawErase: double erase"); break; case Action::insert: items_.erase(result.first); @@ -436,11 +438,11 @@ ApplyStateTable::insert(ReadView const& base, std::shared_ptr const& sle) switch (item.first) { case Action::cache: - LogicError("ApplyStateTable::insert: already cached"); + Throw("ApplyStateTable::insert: already cached"); case Action::insert: - LogicError("ApplyStateTable::insert: already inserted"); + Throw("ApplyStateTable::insert: already inserted"); case Action::modify: - LogicError("ApplyStateTable::insert: already modified"); + Throw("ApplyStateTable::insert: already modified"); case Action::erase: break; } @@ -466,7 +468,7 @@ ApplyStateTable::replace(ReadView const& base, std::shared_ptr const& sle) switch (item.first) { case Action::erase: - LogicError("ApplyStateTable::replace: already erased"); + Throw("ApplyStateTable::replace: already erased"); case Action::cache: item.first = Action::modify; break; @@ -482,14 +484,14 @@ ApplyStateTable::update(ReadView const& base, std::shared_ptr const& sle) { auto const iter = items_.find(sle->key()); if (iter == items_.end()) - LogicError("ApplyStateTable::update: missing key"); + Throw("ApplyStateTable::update: missing key"); auto& item = iter->second; if (item.second != sle) - LogicError("ApplyStateTable::update: unknown SLE"); + Throw("ApplyStateTable::update: unknown SLE"); switch (item.first) { case Action::erase: - LogicError("ApplyStateTable::update: erased"); + Throw("ApplyStateTable::update: erased"); break; case Action::cache: item.first = Action::modify; diff --git a/src/libxrpl/ledger/ApplyView.cpp b/src/libxrpl/ledger/ApplyView.cpp index 476b635511..3ceddaa4dc 100644 --- a/src/libxrpl/ledger/ApplyView.cpp +++ b/src/libxrpl/ledger/ApplyView.cpp @@ -4,6 +4,7 @@ #include #include +#include #include namespace xrpl { @@ -40,10 +41,8 @@ findPreviousPage(ApplyView& view, Keylet const& directory, SLE::ref start) { node = view.peek(keylet::page(directory, page)); if (!node) - { // LCOV_EXCL_START - LogicError("Directory chain: root back-pointer broken."); - // LCOV_EXCL_STOP - } + Throw( + "Directory chain: root back-pointer broken."); // LCOV_EXCL_LINE } auto indexes = node->getFieldV256(sfIndexes); @@ -62,21 +61,20 @@ insertKey( if (preserveOrder) { if (std::find(indexes.begin(), indexes.end(), key) != indexes.end()) - LogicError("dirInsert: double insertion"); // LCOV_EXCL_LINE + Throw("dirInsert: double insertion"); // LCOV_EXCL_LINE indexes.push_back(key); } else { - // We can't be sure if this page is already sorted because - // it may be a legacy page we haven't yet touched. Take - // the time to sort it. + // We can't be sure if this page is already sorted because it may be a + // legacy page we haven't yet touched. Take the time to sort it. std::sort(indexes.begin(), indexes.end()); auto pos = std::lower_bound(indexes.begin(), indexes.end(), key); if (pos != indexes.end() && key == *pos) - LogicError("dirInsert: double insertion"); // LCOV_EXCL_LINE + Throw("dirInsert: double insertion"); // LCOV_EXCL_LINE indexes.insert(pos, key); } @@ -129,8 +127,7 @@ insertPage( node->setFieldH256(sfRootIndex, directory.key); node->setFieldV256(sfIndexes, indexes); - // Save some space by not specifying the value 0 since - // it's the default. + // Save some space by not specifying the value 0 since it's the default. if (page != 1) node->setFieldU64(sfIndexPrevious, page - 1); XRPL_ASSERT_PARTS(!nextPage, "xrpl::directory::insertPage", "nextPage has default value"); @@ -199,28 +196,24 @@ ApplyView::emptyDirDelete(Keylet const& directory) auto nextPage = node->getFieldU64(sfIndexNext); if (nextPage == rootPage && prevPage != rootPage) - LogicError("Directory chain: fwd link broken"); // LCOV_EXCL_LINE + Throw("Directory chain: fwd link broken"); // LCOV_EXCL_LINE if (prevPage == rootPage && nextPage != rootPage) - LogicError("Directory chain: rev link broken"); // LCOV_EXCL_LINE + Throw("Directory chain: rev link broken"); // LCOV_EXCL_LINE - // Older versions of the code would, in some cases, allow the last - // page to be empty. Remove such pages: + // Older versions of the code would, in some cases, allow the last page to + // be empty. Remove such pages: if (nextPage == prevPage && nextPage != rootPage) { auto last = peek(keylet::page(directory, nextPage)); if (!last) - { // LCOV_EXCL_START - LogicError("Directory chain: fwd link broken."); - // LCOV_EXCL_STOP - } + Throw("Directory chain: fwd link broken."); // LCOV_EXCL_LINE if (!last->getFieldV256(sfIndexes).empty()) return false; - // Update the first page's linked list and - // mark it as updated. + // Update the first page's linked list and mark it as updated. node->setFieldU64(sfIndexNext, rootPage); node->setFieldU64(sfIndexPrevious, rootPage); update(node); @@ -228,8 +221,7 @@ ApplyView::emptyDirDelete(Keylet const& directory) // And erase the empty last page: erase(last); - // Make sure our local values reflect the - // updated information: + // Make sure our local values reflect the updated information: nextPage = rootPage; prevPage = rootPage; } @@ -269,46 +261,33 @@ ApplyView::dirRemove(Keylet const& directory, std::uint64_t page, uint256 const& return true; } - // The current page is now empty; check if it can be - // deleted, and, if so, whether the entire directory - // can now be removed. + // The current page is now empty; check if it can be deleted, and, if so, + // whether the entire directory can now be removed. auto prevPage = node->getFieldU64(sfIndexPrevious); auto nextPage = node->getFieldU64(sfIndexNext); - // The first page is the directory's root node and is - // treated specially: it can never be deleted even if - // it is empty, unless we plan on removing the entire - // directory. + // The first page is the directory's root node and is treated specially: it + // can never be deleted even if it is empty, unless we plan on removing the + // entire directory. if (page == rootPage) { if (nextPage == page && prevPage != page) - { // LCOV_EXCL_START - LogicError("Directory chain: fwd link broken"); - // LCOV_EXCL_STOP - } + Throw("Directory chain: fwd link broken"); // LCOV_EXCL_LINE if (prevPage == page && nextPage != page) - { // LCOV_EXCL_START - LogicError("Directory chain: rev link broken"); - // LCOV_EXCL_STOP - } + Throw("Directory chain: rev link broken"); // LCOV_EXCL_LINE - // Older versions of the code would, in some cases, - // allow the last page to be empty. Remove such - // pages if we stumble on them: + // Older versions of the code would, in some cases, allow the last page + // to be empty. Remove such pages if we stumble on them: if (nextPage == prevPage && nextPage != page) { auto last = peek(keylet::page(directory, nextPage)); if (!last) - { // LCOV_EXCL_START - LogicError("Directory chain: fwd link broken."); - // LCOV_EXCL_STOP - } + Throw("Directory chain: fwd link broken."); // LCOV_EXCL_LINE if (last->getFieldV256(sfIndexes).empty()) { - // Update the first page's linked list and - // mark it as updated. + // Update the first page's linked list and mark it as updated. node->setFieldU64(sfIndexNext, page); node->setFieldU64(sfIndexPrevious, page); update(node); @@ -316,8 +295,7 @@ ApplyView::dirRemove(Keylet const& directory, std::uint64_t page, uint256 const& // And erase the empty last page: erase(last); - // Make sure our local values reflect the - // updated information: + // Make sure our local values reflect the updated information: nextPage = page; prevPage = page; } @@ -335,25 +313,24 @@ ApplyView::dirRemove(Keylet const& directory, std::uint64_t page, uint256 const& // This can never happen for nodes other than the root: if (nextPage == page) - LogicError("Directory chain: fwd link broken"); // LCOV_EXCL_LINE + Throw("Directory chain: fwd link broken"); // LCOV_EXCL_LINE if (prevPage == page) - LogicError("Directory chain: rev link broken"); // LCOV_EXCL_LINE + Throw("Directory chain: rev link broken"); // LCOV_EXCL_LINE - // This node isn't the root, so it can either be in the - // middle of the list, or at the end. Unlink it first - // and then check if that leaves the list with only a - // root: + // This node isn't the root, so it can either be in the middle of the list, + // or at the end. Unlink it first and then check if that leaves the list + // with only a root: auto prev = peek(keylet::page(directory, prevPage)); if (!prev) - LogicError("Directory chain: fwd link broken."); // LCOV_EXCL_LINE + Throw("Directory chain: fwd link broken."); // LCOV_EXCL_LINE // Fix previous to point to its new next. prev->setFieldU64(sfIndexNext, nextPage); update(prev); auto next = peek(keylet::page(directory, nextPage)); if (!next) - LogicError("Directory chain: rev link broken."); // LCOV_EXCL_LINE + Throw("Directory chain: rev link broken."); // LCOV_EXCL_LINE // Fix next to point to its new previous. next->setFieldU64(sfIndexPrevious, prevPage); update(next); @@ -361,13 +338,12 @@ ApplyView::dirRemove(Keylet const& directory, std::uint64_t page, uint256 const& // The page is no longer linked. Delete it. erase(node); - // Check whether the next page is the last page and, if - // so, whether it's empty. If it is, delete it. + // Check whether the next page is the last page and, if so, whether it's + // empty. If it is, delete it. if (nextPage != rootPage && next->getFieldU64(sfIndexNext) == rootPage && next->getFieldV256(sfIndexes).empty()) { - // Since next doesn't point to the root, it - // can't be pointing to prev. + // Since next doesn't point to the root, it can't be pointing to prev. erase(next); // The previous page is now the last page: @@ -377,18 +353,16 @@ ApplyView::dirRemove(Keylet const& directory, std::uint64_t page, uint256 const& // And the root points to the last page: auto root = peek(keylet::page(directory, rootPage)); if (!root) - { // LCOV_EXCL_START - LogicError("Directory chain: root link broken."); - // LCOV_EXCL_STOP - } + Throw("Directory chain: root link broken."); // LCOV_EXCL_LINE + root->setFieldU64(sfIndexPrevious, prevPage); update(root); nextPage = rootPage; } - // If we're not keeping the root, then check to see if - // it's left empty. If so, delete it as well. + // If we're not keeping the root, then check to see if it's left empty. + // If so, delete it as well. if (!keepRoot && nextPage == rootPage && prevPage == rootPage) { if (prev->getFieldV256(sfIndexes).empty()) diff --git a/src/libxrpl/ledger/Ledger.cpp b/src/libxrpl/ledger/Ledger.cpp index 299a82a1f2..78bdc76fef 100644 --- a/src/libxrpl/ledger/Ledger.cpp +++ b/src/libxrpl/ledger/Ledger.cpp @@ -12,6 +12,7 @@ #include #include +#include #include #include @@ -461,14 +462,14 @@ void Ledger::rawErase(std::shared_ptr const& sle) { if (!stateMap_.delItem(sle->key())) - LogicError("Ledger::rawErase: key not found"); + Throw("Ledger::rawErase: key not found"); } void Ledger::rawErase(uint256 const& key) { if (!stateMap_.delItem(key)) - LogicError("Ledger::rawErase: key not found"); + Throw("Ledger::rawErase: key not found"); } void @@ -478,7 +479,7 @@ Ledger::rawInsert(std::shared_ptr const& sle) sle->add(ss); if (!stateMap_.addGiveItem( SHAMapNodeType::tnACCOUNT_STATE, make_shamapitem(sle->key(), ss.slice()))) - LogicError("Ledger::rawInsert: key already exists"); + Throw("Ledger::rawInsert: key already exists"); } void @@ -488,7 +489,7 @@ Ledger::rawReplace(std::shared_ptr const& sle) sle->add(ss); if (!stateMap_.updateGiveItem( SHAMapNodeType::tnACCOUNT_STATE, make_shamapitem(sle->key(), ss.slice()))) - LogicError("Ledger::rawReplace: key not found"); + Throw("Ledger::rawReplace: key not found"); } void @@ -504,7 +505,7 @@ Ledger::rawTxInsert( s.addVL(txn->peekData()); s.addVL(metaData->peekData()); if (!txMap_.addGiveItem(SHAMapNodeType::tnTRANSACTION_MD, make_shamapitem(key, s.slice()))) - LogicError("duplicate_tx: " + to_string(key)); + Throw("duplicate_tx: " + to_string(key)); } uint256 @@ -522,7 +523,7 @@ Ledger::rawTxInsertWithHash( auto item = make_shamapitem(key, s.slice()); auto hash = sha512Half(HashPrefix::txNode, item->slice(), item->key()); if (!txMap_.addGiveItem(SHAMapNodeType::tnTRANSACTION_MD, std::move(item))) - LogicError("duplicate_tx: " + to_string(key)); + Throw("duplicate_tx: " + to_string(key)); return hash; } diff --git a/src/libxrpl/ledger/OpenView.cpp b/src/libxrpl/ledger/OpenView.cpp index b5e358053c..613fd2cddf 100644 --- a/src/libxrpl/ledger/OpenView.cpp +++ b/src/libxrpl/ledger/OpenView.cpp @@ -1,6 +1,8 @@ #include #include +#include + namespace xrpl { class OpenView::txs_iter_impl : public txs_type::iter_base @@ -247,7 +249,7 @@ OpenView::rawTxInsert( auto const result = txs_.emplace( std::piecewise_construct, std::forward_as_tuple(key), std::forward_as_tuple(txn, metaData)); if (!result.second) - LogicError("rawTxInsert: duplicate TX id: " + to_string(key)); + Throw("rawTxInsert: duplicate TX id: " + to_string(key)); } } // namespace xrpl diff --git a/src/libxrpl/ledger/RawStateTable.cpp b/src/libxrpl/ledger/RawStateTable.cpp index b411a25b00..9b13aa5e45 100644 --- a/src/libxrpl/ledger/RawStateTable.cpp +++ b/src/libxrpl/ledger/RawStateTable.cpp @@ -1,6 +1,8 @@ #include #include +#include + namespace xrpl { namespace detail { @@ -241,7 +243,7 @@ RawStateTable::erase(std::shared_ptr const& sle) switch (item.action) { case Action::erase: - LogicError("RawStateTable::erase: already erased"); + Throw("RawStateTable::erase: already erased"); break; case Action::insert: items_.erase(result.first); @@ -270,10 +272,10 @@ RawStateTable::insert(std::shared_ptr const& sle) item.sle = sle; break; case Action::insert: - LogicError("RawStateTable::insert: already inserted"); + Throw("RawStateTable::insert: already inserted"); break; case Action::replace: - LogicError("RawStateTable::insert: already exists"); + Throw("RawStateTable::insert: already exists"); break; } } @@ -291,7 +293,7 @@ RawStateTable::replace(std::shared_ptr const& sle) switch (item.action) { case Action::erase: - LogicError("RawStateTable::replace: was erased"); + Throw("RawStateTable::replace: was erased"); break; case Action::insert: case Action::replace: diff --git a/src/libxrpl/ledger/helpers/AccountRootHelpers.cpp b/src/libxrpl/ledger/helpers/AccountRootHelpers.cpp index 19c2a9d7a7..d6003eaf8c 100644 --- a/src/libxrpl/ledger/helpers/AccountRootHelpers.cpp +++ b/src/libxrpl/ledger/helpers/AccountRootHelpers.cpp @@ -8,6 +8,7 @@ #include #include +#include namespace xrpl { @@ -153,7 +154,7 @@ getPseudoAccountFields() if (!ar) { // LCOV_EXCL_START - LogicError( + Throw( "xrpl::getPseudoAccountFields : unable to find account root " "ledger format"); // LCOV_EXCL_STOP diff --git a/src/test/core/Config_test.cpp b/src/test/core/Config_test.cpp index 6392a75f80..464f8d266b 100644 --- a/src/test/core/Config_test.cpp +++ b/src/test/core/Config_test.cpp @@ -507,7 +507,7 @@ port_wss_admin { c.loadFromString(boost::str(configTemplate % validationSeed % token)); } - catch (std::runtime_error& e) + catch (std::runtime_error const& e) { error = e.what(); } @@ -528,7 +528,7 @@ port_wss_admin main )xrpldConfig"); } - catch (std::runtime_error& e) + catch (std::runtime_error const& e) { error = e.what(); } @@ -541,7 +541,7 @@ main c.loadFromString(R"xrpldConfig( )xrpldConfig"); } - catch (std::runtime_error& e) + catch (std::runtime_error const& e) { error = e.what(); } @@ -556,7 +556,7 @@ main 255 )xrpldConfig"); } - catch (std::runtime_error& e) + catch (std::runtime_error const& e) { error = e.what(); } @@ -571,7 +571,7 @@ main 10000 )xrpldConfig"); } - catch (std::runtime_error& e) + catch (std::runtime_error const& e) { error = e.what(); } @@ -598,7 +598,7 @@ main Config c; c.loadFromString(boost::str(cc % missingPath)); } - catch (std::runtime_error& e) + catch (std::runtime_error const& e) { error = e.what(); } @@ -617,7 +617,7 @@ main Config c; c.loadFromString(boost::str(cc % invalidFile.string())); } - catch (std::runtime_error& e) + catch (std::runtime_error const& e) { error = e.what(); } @@ -725,7 +725,7 @@ trust-these-validators.gov c.loadFromString(toLoad); fail(); } - catch (std::runtime_error& e) + catch (std::runtime_error const& e) { error = e.what(); } @@ -754,7 +754,7 @@ value = 2 c.loadFromString(toLoad); fail(); } - catch (std::runtime_error& e) + catch (std::runtime_error const& e) { error = e.what(); } @@ -802,7 +802,7 @@ trust-these-validators.gov c.loadFromString(toLoad); fail(); } - catch (std::runtime_error& e) + catch (std::runtime_error const& e) { error = e.what(); } @@ -948,7 +948,7 @@ trust-these-validators.gov c.loadFromString(boost::str(cc % vtg.validatorsFile())); fail(); } - catch (std::runtime_error& e) + catch (std::runtime_error const& e) { error = e.what(); } @@ -974,7 +974,7 @@ trust-these-validators.gov Config c2; c2.loadFromString(boost::str(cc % vtg.validatorsFile())); } - catch (std::runtime_error& e) + catch (std::runtime_error const& e) { error = e.what(); } @@ -1451,7 +1451,7 @@ r.ripple.com:51235 fail(); } } - catch (std::runtime_error&) + catch (std::runtime_error const&) { if (!shouldPass) { @@ -1477,7 +1477,7 @@ r.ripple.com:51235 c.loadFromString("[overlay]\nmax_unknown_time=" + value); return c.MAX_UNKNOWN_TIME; } - catch (std::runtime_error&) + catch (std::runtime_error const&) { return {}; } @@ -1511,7 +1511,7 @@ r.ripple.com:51235 c.loadFromString("[overlay]\nmax_diverged_time=" + value); return c.MAX_DIVERGED_TIME; } - catch (std::runtime_error&) + catch (std::runtime_error const&) { return {}; } diff --git a/src/test/csf/Scheduler.h b/src/test/csf/Scheduler.h index 61ec8f62ff..b92c4341b5 100644 --- a/src/test/csf/Scheduler.h +++ b/src/test/csf/Scheduler.h @@ -265,7 +265,7 @@ inline Scheduler::queue_type::~queue_type() auto e = &*iter; ++iter; e->~event(); - alloc_->deallocate(e, sizeof(e)); + alloc_->deallocate(e, sizeof(e)); // NOLINT(bugprone-sizeof-expression) } } diff --git a/src/test/jtx/TrustedPublisherServer.h b/src/test/jtx/TrustedPublisherServer.h index c9304426cf..806e60f92a 100644 --- a/src/test/jtx/TrustedPublisherServer.h +++ b/src/test/jtx/TrustedPublisherServer.h @@ -452,7 +452,7 @@ private: bool ssl; lambda(int id_, TrustedPublisherServer& self_, socket_type&& sock_, bool ssl_) - : id(id_), self(self_), sock(std::move(sock_)), work(sock_.get_executor()), ssl(ssl_) + : id(id_), self(self_), sock(std::move(sock_)), work(sock.get_executor()), ssl(ssl_) { } diff --git a/src/test/nodestore/TestBase.h b/src/test/nodestore/TestBase.h index 893e06579c..6f29457e85 100644 --- a/src/test/nodestore/TestBase.h +++ b/src/test/nodestore/TestBase.h @@ -75,9 +75,10 @@ public: return hotTRANSACTION_NODE; case 3: return hotUNKNOWN; + default: + // will never happen, but make static analysis tool happy. + return hotUNKNOWN; } - // will never happen, but make static analysis tool happy. - return hotUNKNOWN; }(); uint256 hash; diff --git a/src/test/nodestore/Timing_test.cpp b/src/test/nodestore/Timing_test.cpp index 39e8b59638..eb40a041f5 100644 --- a/src/test/nodestore/Timing_test.cpp +++ b/src/test/nodestore/Timing_test.cpp @@ -211,7 +211,7 @@ public: parallel_for(std::size_t const n, std::size_t number_of_threads, Args const&... args) { std::atomic c(0); - std::vector t; + std::vector t; t.reserve(number_of_threads); for (std::size_t id = 0; id < number_of_threads; ++id) t.emplace_back(*this, parallel_for_lambda(n, c), args...); @@ -224,7 +224,7 @@ public: parallel_for_id(std::size_t const n, std::size_t number_of_threads, Args const&... args) { std::atomic c(0); - std::vector t; + std::vector t; t.reserve(number_of_threads); for (std::size_t id = 0; id < number_of_threads; ++id) t.emplace_back(*this, parallel_for_lambda(n, c), id, args...); diff --git a/src/test/overlay/reduce_relay_test.cpp b/src/test/overlay/reduce_relay_test.cpp index bac70d35a6..8c96ad91af 100644 --- a/src/test/overlay/reduce_relay_test.cpp +++ b/src/test/overlay/reduce_relay_test.cpp @@ -1345,7 +1345,7 @@ vp_enable=0 { c.loadFromString(toLoad); } - catch (std::runtime_error& e) + catch (std::runtime_error const& e) { error = e.what(); } @@ -1389,7 +1389,7 @@ vp_base_squelch_max_selected_peers=2 { c2.loadFromString(toLoad); } - catch (std::runtime_error& e) + catch (std::runtime_error const& e) { error = e.what(); } diff --git a/src/test/protocol/STParsedJSON_test.cpp b/src/test/protocol/STParsedJSON_test.cpp index 1c86a90348..c9c2409748 100644 --- a/src/test/protocol/STParsedJSON_test.cpp +++ b/src/test/protocol/STParsedJSON_test.cpp @@ -2130,7 +2130,7 @@ class STParsedJSON_test : public beast::unit_test::suite STParsedJSONObject const parsed("test", faultyJson); BEAST_EXPECT(!parsed.object); } - catch (std::runtime_error& e) + catch (std::runtime_error const& e) { std::string const what(e.what()); unexpected(what.find("First level children of `Template`") != 0); diff --git a/src/xrpld/app/main/Application.h b/src/xrpld/app/main/Application.h index 45bd94adce..d0437be9a6 100644 --- a/src/xrpld/app/main/Application.h +++ b/src/xrpld/app/main/Application.h @@ -16,15 +16,6 @@ namespace xrpl { -namespace unl { -class Manager; -} // namespace unl -namespace Resource { -class Manager; -} // namespace Resource -namespace NodeStore { -class Database; -} // namespace NodeStore namespace perf { class PerfLog; } // namespace perf diff --git a/src/xrpld/app/misc/Transaction.h b/src/xrpld/app/misc/Transaction.h index fa126e6bb5..5fe8dcf4fa 100644 --- a/src/xrpld/app/misc/Transaction.h +++ b/src/xrpld/app/misc/Transaction.h @@ -21,7 +21,6 @@ namespace xrpl { // class Application; -class Database; class Rules; enum TransStatus { diff --git a/src/xrpld/app/misc/detail/WorkBase.h b/src/xrpld/app/misc/detail/WorkBase.h index 35f04efe00..825866ee9b 100644 --- a/src/xrpld/app/misc/detail/WorkBase.h +++ b/src/xrpld/app/misc/detail/WorkBase.h @@ -47,7 +47,7 @@ protected: endpoint_type lastEndpoint_; bool lastStatus_; -public: +private: WorkBase( std::string const& host, std::string const& path, @@ -56,6 +56,8 @@ public: endpoint_type const& lastEndpoint, bool lastStatus, callback_type cb); + +public: ~WorkBase(); Impl& @@ -91,6 +93,8 @@ public: private: void close(); + + friend Impl; }; //------------------------------------------------------------------------------ diff --git a/src/xrpld/overlay/Compression.h b/src/xrpld/overlay/Compression.h index e9f530035a..784e7c1607 100644 --- a/src/xrpld/overlay/Compression.h +++ b/src/xrpld/overlay/Compression.h @@ -49,7 +49,7 @@ decompress( // LCOV_EXCL_STOP } } - catch (...) + catch (...) // NOLINT(bugprone-empty-catch) { } return 0; @@ -88,7 +88,7 @@ compress( // LCOV_EXCL_STOP } } - catch (...) + catch (...) // NOLINT(bugprone-empty-catch) { } return 0; diff --git a/src/xrpld/rpc/detail/PathRequest.h b/src/xrpld/rpc/detail/PathRequest.h index f699ccb6f8..3c8f89f5fe 100644 --- a/src/xrpld/rpc/detail/PathRequest.h +++ b/src/xrpld/rpc/detail/PathRequest.h @@ -24,7 +24,7 @@ class AssetCache; class PathRequestManager; // Return values from parseJson <0 = invalid, >0 = valid -#define PFR_PJ_INVALID -1 +#define PFR_PJ_INVALID (-1) #define PFR_PJ_NOCHANGE 0 class PathRequest final : public InfoSubRequest, diff --git a/src/xrpld/rpc/detail/RPCCall.cpp b/src/xrpld/rpc/detail/RPCCall.cpp index 4396037f2e..e18fdb3266 100644 --- a/src/xrpld/rpc/detail/RPCCall.cpp +++ b/src/xrpld/rpc/detail/RPCCall.cpp @@ -1632,7 +1632,7 @@ rpcClient( // YYY We could have a command line flag for single line output for // scripts. YYY We would intercept output here and simplify it. } - catch (RequestNotParsable& e) + catch (RequestNotParsable const& e) { jvOutput = rpcError(rpcINVALID_PARAMS); jvOutput["error_what"] = e.what(); diff --git a/src/xrpld/rpc/detail/TransactionSign.cpp b/src/xrpld/rpc/detail/TransactionSign.cpp index d6909d555b..9a45b857cf 100644 --- a/src/xrpld/rpc/detail/TransactionSign.cpp +++ b/src/xrpld/rpc/detail/TransactionSign.cpp @@ -619,7 +619,7 @@ transactionPreProcessImpl( stTx = std::make_shared(std::move(parsed.object.value())); } - catch (STObject::FieldErr& err) + catch (STObject::FieldErr const& err) { return RPC::make_error(rpcINVALID_PARAMS, err.what()); } @@ -1291,7 +1291,7 @@ transactionSubmitMultiSigned( { stTx = std::make_shared(std::move(parsedTx_json.object.value())); } - catch (STObject::FieldErr& err) + catch (STObject::FieldErr const& err) { return RPC::make_error(rpcINVALID_PARAMS, err.what()); } diff --git a/src/xrpld/rpc/handlers/ledger/LedgerEntry.cpp b/src/xrpld/rpc/handlers/ledger/LedgerEntry.cpp index 1fa88ac34d..ec6eeeaf5a 100644 --- a/src/xrpld/rpc/handlers/ledger/LedgerEntry.cpp +++ b/src/xrpld/rpc/handlers/ledger/LedgerEntry.cpp @@ -897,7 +897,7 @@ doLedgerEntry(RPC::JsonContext& context) return RPC::make_param_error("No ledger_entry params provided."); } } - catch (Json::error& e) + catch (Json::error const& e) { if (context.apiVersion > 1u) { diff --git a/src/xrpld/rpc/handlers/subscribe/Subscribe.cpp b/src/xrpld/rpc/handlers/subscribe/Subscribe.cpp index 8b3e5a5e1f..e3b44f5792 100644 --- a/src/xrpld/rpc/handlers/subscribe/Subscribe.cpp +++ b/src/xrpld/rpc/handlers/subscribe/Subscribe.cpp @@ -65,7 +65,7 @@ doSubscribe(RPC::JsonContext& context) ispSub = context.netOps.addRpcSub(strUrl, std::dynamic_pointer_cast(rspSub)); } - catch (std::runtime_error& ex) + catch (std::runtime_error const& ex) { return RPC::make_param_error(ex.what()); }