From 6b301efc8c0e66e29b57491b5c26640cd8b3bb54 Mon Sep 17 00:00:00 2001 From: Alex Kremer Date: Mon, 9 Mar 2026 15:25:52 +0000 Subject: [PATCH] chore: Enable clang-tidy `bugprone-unused-local-non-trivial-variable` check (#6458) --- .clang-tidy | 4 ++-- src/test/app/Manifest_test.cpp | 1 - src/test/rpc/LedgerEntry_test.cpp | 12 ++++-------- src/test/rpc/Peers_test.cpp | 4 ++-- src/xrpld/app/consensus/RCLConsensus.cpp | 2 -- 5 files changed, 8 insertions(+), 15 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 26c7995631..8eefa5fe37 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -60,6 +60,7 @@ Checks: "-*, bugprone-unhandled-exception-at-new, bugprone-unique-ptr-array-mismatch, bugprone-unsafe-functions, + bugprone-unused-local-non-trivial-variable, bugprone-virtual-near-miss, cppcoreguidelines-no-suspend-with-lock, cppcoreguidelines-virtual-class-destructor, @@ -85,13 +86,12 @@ Checks: "-*, performance-trivially-destructible " # --- -# more checks that have some issues that need to be resolved: +# checks that have some issues that need to be resolved: # # bugprone-crtp-constructor-accessibility, # bugprone-inc-dec-in-conditions, # bugprone-reserved-identifier, # bugprone-move-forwarding-reference, -# bugprone-unused-local-non-trivial-variable, # bugprone-switch-missing-default-case, # bugprone-suspicious-stringview-data-usage, # bugprone-suspicious-missing-comma, diff --git a/src/test/app/Manifest_test.cpp b/src/test/app/Manifest_test.cpp index 294d5210d9..dfa67e350f 100644 --- a/src/test/app/Manifest_test.cpp +++ b/src/test/app/Manifest_test.cpp @@ -248,7 +248,6 @@ public: // save should store all trusted master keys to db std::vector s1; std::vector keys; - std::string cfgManifest; for (auto const& man : inManifests) s1.push_back(toBase58(TokenType::NodePublic, man->masterKey)); unl->load({}, s1, keys); diff --git a/src/test/rpc/LedgerEntry_test.cpp b/src/test/rpc/LedgerEntry_test.cpp index 9d274b3549..ffc4329109 100644 --- a/src/test/rpc/LedgerEntry_test.cpp +++ b/src/test/rpc/LedgerEntry_test.cpp @@ -2583,13 +2583,10 @@ class LedgerEntry_test : public beast::unit_test::suite env(check::create(env.master, alice, XRP(100))); env.close(); - std::string const ledgerHash{to_string(env.closed()->header().hash)}; - { - // Request a check. - Json::Value const jrr = env.rpc("ledger_entry", to_string(checkId.key))[jss::result]; - BEAST_EXPECT(jrr[jss::node][sfLedgerEntryType.jsonName] == jss::Check); - BEAST_EXPECT(jrr[jss::node][sfSendMax.jsonName] == "100000000"); - } + // Request a check. + Json::Value const jrr = env.rpc("ledger_entry", to_string(checkId.key))[jss::result]; + BEAST_EXPECT(jrr[jss::node][sfLedgerEntryType.jsonName] == jss::Check); + BEAST_EXPECT(jrr[jss::node][sfSendMax.jsonName] == "100000000"); } public: @@ -2753,7 +2750,6 @@ class LedgerEntry_XChain_test : public beast::unit_test::suite, scEnv(xchain_create_claim_id(scBob, jvb, reward, mcBob)); scEnv.close(); - std::string bridge_index; { // request the xchain_claim_id via RPC Json::Value jvParams; diff --git a/src/test/rpc/Peers_test.cpp b/src/test/rpc/Peers_test.cpp index 8e4e560f3e..d72ad6d878 100644 --- a/src/test/rpc/Peers_test.cpp +++ b/src/test/rpc/Peers_test.cpp @@ -53,8 +53,8 @@ class Peers_test : public beast::unit_test::suite continue; if (!BEAST_EXPECT((*it).isMember(jss::tag))) continue; - auto tag = (*it)[jss::tag].asString(); - BEAST_EXPECTS((*it)[jss::tag].asString() == nodes[key], key); + auto const tag = (*it)[jss::tag].asString(); + BEAST_EXPECTS(tag == nodes[key], key); } BEAST_EXPECT(peers.isMember(jss::peers) && peers[jss::peers].isNull()); } diff --git a/src/xrpld/app/consensus/RCLConsensus.cpp b/src/xrpld/app/consensus/RCLConsensus.cpp index 98dccc0089..91f24a650c 100644 --- a/src/xrpld/app/consensus/RCLConsensus.cpp +++ b/src/xrpld/app/consensus/RCLConsensus.cpp @@ -78,8 +78,6 @@ RCLConsensus::Adaptor::Adaptor( if (validatorKeys_.nodeID != beast::zero && validatorKeys_.keys) { - std::stringstream ss; - JLOG(j_.info()) << "Validator identity: " << toBase58(TokenType::NodePublic, validatorKeys_.keys->masterPublicKey);