From 52af23fe7742f31fea622926d247dfeab1019801 Mon Sep 17 00:00:00 2001 From: Ayaz Salikhov Date: Wed, 17 Jun 2026 11:33:39 +0100 Subject: [PATCH] chore: Fixes after tidy v22 update (#3108) --- .github/workflows/clang-tidy.yml | 22 ++++++++++--------- src/cluster/Backend.hpp | 2 +- src/cluster/ClusterCommunicationService.cpp | 1 - src/data/BackendInterface.cpp | 4 ++-- src/data/cassandra/impl/ExecutionStrategy.hpp | 8 +++---- src/etl/ETLService.hpp | 10 ++++----- src/etl/impl/Extraction.cpp | 2 -- src/etl/impl/Monitor.cpp | 1 - src/rpc/common/Modifiers.hpp | 2 +- src/rpc/common/Validators.cpp | 1 - src/rpc/handlers/DepositAuthorized.cpp | 1 - src/rpc/handlers/LedgerData.cpp | 2 +- src/util/Atomic.hpp | 2 +- src/util/Coroutine.cpp | 1 - src/util/CoroutineGroup.hpp | 4 ++-- src/web/AdminVerificationStrategy.cpp | 1 - src/web/SubscriptionContext.hpp | 2 +- src/web/ng/SubscriptionContext.hpp | 2 +- tests/common/util/CallWithTimeout.cpp | 1 - tests/unit/app/CliArgsTests.cpp | 13 +++++------ tests/unit/cluster/ClioNodeTests.cpp | 1 - .../data/cassandra/ExecutionStrategyTests.cpp | 2 +- tests/unit/etl/AmendmentBlockHandlerTests.cpp | 1 - tests/unit/etl/MonitorTests.cpp | 1 - .../unit/etl/NetworkValidatedLedgersTests.cpp | 1 - tests/unit/etl/SubscriptionSourceTests.cpp | 1 - tests/unit/etl/SystemStateTests.cpp | 2 -- tests/unit/feed/ForwardFeedTests.cpp | 2 -- tests/unit/rpc/handlers/LedgerIndexTests.cpp | 1 - tests/unit/web/ServerTests.cpp | 4 ++-- 30 files changed, 39 insertions(+), 59 deletions(-) diff --git a/.github/workflows/clang-tidy.yml b/.github/workflows/clang-tidy.yml index 6e40c4805..bbb5f0139 100644 --- a/.github/workflows/clang-tidy.yml +++ b/.github/workflows/clang-tidy.yml @@ -28,9 +28,10 @@ env: BUILD_DIR: build BUILD_TYPE: Debug # Debug so that ASSERTS and such participate in clang-tidy check - OUTPUT_FILE: clang-tidy-output.txt - DIFF_FILE: clang-tidy-git-diff.txt - ISSUE_FILE: clang-tidy-issue.md + OUTPUT_FILE: /tmp/clang-tidy-output.txt + FILTERED_OUTPUT_FILE: /tmp/clang-tidy-filtered-output.txt + DIFF_FILE: /tmp/clang-tidy-git-diff.txt + ISSUE_FILE: /tmp/clang-tidy-issue.md COMPILER: clang @@ -154,21 +155,21 @@ jobs: run: | if [ -f "${OUTPUT_FILE}" ]; then # Extract lines containing 'error:', 'warning:', or 'note:' - grep -E '(error:|warning:|note:)' "${OUTPUT_FILE}" >filtered-output.txt || true + grep -E '(error:|warning:|note:)' "${OUTPUT_FILE}" >"${FILTERED_OUTPUT_FILE}" || true # If filtered output is empty, use original (might be a different error format) - if [ ! -s filtered-output.txt ]; then - cp "${OUTPUT_FILE}" filtered-output.txt + if [ ! -s "${FILTERED_OUTPUT_FILE}" ]; then + cp "${OUTPUT_FILE}" "${FILTERED_OUTPUT_FILE}" fi # Truncate if too large - head -c 60000 filtered-output.txt >>"${ISSUE_FILE}" - if [ "$(wc -c >"${ISSUE_FILE}" + if [ "$(wc -c <"${FILTERED_OUTPUT_FILE}")" -gt 60000 ]; then echo "" >>"${ISSUE_FILE}" echo "... (output truncated, see artifacts for full output)" >>"${ISSUE_FILE}" fi - rm filtered-output.txt + rm "${FILTERED_OUTPUT_FILE}" else echo "No output file found" >>"${ISSUE_FILE}" fi @@ -184,6 +185,7 @@ jobs: EOF - name: Create issue + id: create_issue if: ${{ steps.run_clang_tidy.outcome != 'success' && github.event_name != 'pull_request' }} uses: XRPLF/actions/create-issue@2b8bc36af85b88bca0dd7bfac2e2dc05f94ad712 with: @@ -212,7 +214,7 @@ jobs: branch: "clang_tidy/autofix" branch-suffix: timestamp delete-branch: true - title: "style: clang-tidy auto fixes" + title: "style: Apply clang-tidy auto fixes" body: > Fixes #${{ steps.create_issue.outputs.issue_number }}. diff --git a/src/cluster/Backend.hpp b/src/cluster/Backend.hpp index d83643b73..d82d3a3b9 100644 --- a/src/cluster/Backend.hpp +++ b/src/cluster/Backend.hpp @@ -119,7 +119,7 @@ public: * * @return The UUID of this node. */ - ClioNode::CUuid + [[nodiscard]] ClioNode::CUuid selfId() const; private: diff --git a/src/cluster/ClusterCommunicationService.cpp b/src/cluster/ClusterCommunicationService.cpp index 0ad1320f7..dc30bb0cb 100644 --- a/src/cluster/ClusterCommunicationService.cpp +++ b/src/cluster/ClusterCommunicationService.cpp @@ -7,7 +7,6 @@ #include "util/config/ConfigDefinition.hpp" #include -#include #include #include diff --git a/src/data/BackendInterface.cpp b/src/data/BackendInterface.cpp index 7f84df262..fa6839ce2 100644 --- a/src/data/BackendInterface.cpp +++ b/src/data/BackendInterface.cpp @@ -223,7 +223,7 @@ BackendInterface::fetchBookOffers( << " blob = " << ripple::strHex(objs[i]) << " ledgerSequence = " << ledgerSequence; ASSERT(!objs[i].empty(), "Ledger object can't be empty"); - page.offers.push_back({keys[i], objs[i]}); + page.offers.push_back({.key = keys[i], .blob = objs[i]}); } auto end = std::chrono::system_clock::now(); LOG(log_.debug()) << "Fetching " << std::to_string(keys.size()) << " offers took " @@ -328,7 +328,7 @@ BackendInterface::fetchLedgerPage( auto objects = fetchLedgerObjects(keys, ledgerSequence, yield); for (size_t i = 0; i < objects.size(); ++i) { if (!objects[i].empty()) { - page.objects.push_back({keys[i], std::move(objects[i])}); + page.objects.push_back({.key = keys[i], .blob = std::move(objects[i])}); } else if (!outOfOrder) { LOG(log_.error()) << "Deleted or non-existent object in successor table. key = " << ripple::strHex(keys[i]) << " - seq = " << ledgerSequence; diff --git a/src/data/cassandra/impl/ExecutionStrategy.hpp b/src/data/cassandra/impl/ExecutionStrategy.hpp index fb874c277..8251287aa 100644 --- a/src/data/cassandra/impl/ExecutionStrategy.hpp +++ b/src/data/cassandra/impl/ExecutionStrategy.hpp @@ -119,7 +119,7 @@ public: /** * @return true if outstanding read requests allowance is exhausted; false otherwise */ - bool + [[nodiscard]] bool isTooBusy() const { bool const result = numReadRequestsOutstanding_ >= maxReadRequestsOutstanding_; @@ -495,7 +495,7 @@ public: /** * @brief Get statistics about the backend. */ - boost::json::object + [[nodiscard]] boost::json::object stats() const { return counters_->report(); @@ -536,13 +536,13 @@ private: } } - bool + [[nodiscard]] bool canAddWriteRequest() const { return numWriteRequestsOutstanding_ < maxWriteRequestsOutstanding_; } - bool + [[nodiscard]] bool finishedAllWriteRequests() const { return numWriteRequestsOutstanding_ == 0; diff --git a/src/etl/ETLService.hpp b/src/etl/ETLService.hpp index 0303943bc..125922035 100644 --- a/src/etl/ETLService.hpp +++ b/src/etl/ETLService.hpp @@ -179,19 +179,19 @@ public: void stop() override; - boost::json::object + [[nodiscard]] boost::json::object getInfo() const override; - bool + [[nodiscard]] bool isAmendmentBlocked() const override; - bool + [[nodiscard]] bool isCorruptionDetected() const override; - std::optional + [[nodiscard]] std::optional getETLState() const override; - std::uint32_t + [[nodiscard]] std::uint32_t lastCloseAgeSeconds() const override; private: diff --git a/src/etl/impl/Extraction.cpp b/src/etl/impl/Extraction.cpp index cf29a3559..6a46493ea 100644 --- a/src/etl/impl/Extraction.cpp +++ b/src/etl/impl/Extraction.cpp @@ -18,10 +18,8 @@ #include #include -#include #include #include -#include #include #include #include diff --git a/src/etl/impl/Monitor.cpp b/src/etl/impl/Monitor.cpp index b89c3650e..229731dda 100644 --- a/src/etl/impl/Monitor.cpp +++ b/src/etl/impl/Monitor.cpp @@ -10,7 +10,6 @@ #include #include -#include #include #include #include diff --git a/src/rpc/common/Modifiers.hpp b/src/rpc/common/Modifiers.hpp index 33262cf67..739cd726a 100644 --- a/src/rpc/common/Modifiers.hpp +++ b/src/rpc/common/Modifiers.hpp @@ -109,7 +109,7 @@ struct ToNumber final { return {}; // ignore for non-string types auto const strInt = boost::json::value_to(value.as_object().at(key)); - if (strInt.find('.') != std::string::npos) + if (strInt.contains('.')) return Error{Status{RippledError::rpcINVALID_PARAMS}}; // maybe a float try { diff --git a/src/rpc/common/Validators.cpp b/src/rpc/common/Validators.cpp index cb83f2aa7..ec9ab077e 100644 --- a/src/rpc/common/Validators.cpp +++ b/src/rpc/common/Validators.cpp @@ -20,7 +20,6 @@ #include #include -#include #include #include #include diff --git a/src/rpc/handlers/DepositAuthorized.cpp b/src/rpc/handlers/DepositAuthorized.cpp index 15bb3ba23..c29354cbf 100644 --- a/src/rpc/handlers/DepositAuthorized.cpp +++ b/src/rpc/handlers/DepositAuthorized.cpp @@ -24,7 +24,6 @@ #include #include -#include #include #include diff --git a/src/rpc/handlers/LedgerData.cpp b/src/rpc/handlers/LedgerData.cpp index 6d4bee0b6..8753b936b 100644 --- a/src/rpc/handlers/LedgerData.cpp +++ b/src/rpc/handlers/LedgerData.cpp @@ -91,7 +91,7 @@ LedgerDataHandler::process(Input const& input, Context const& ctx) const for (size_t i = 0; i < objs.size(); ++i) { auto& obj = objs[i]; if (!obj.empty()) - results.push_back({keys[i], std::move(obj)}); + results.push_back({.key = keys[i], .blob = std::move(obj)}); } if (*(input.diffMarker) > lgrInfo.seq) diff --git a/src/util/Atomic.hpp b/src/util/Atomic.hpp index b2b155307..9062af5ed 100644 --- a/src/util/Atomic.hpp +++ b/src/util/Atomic.hpp @@ -76,7 +76,7 @@ public: * * @return The current value */ - ValueType + [[nodiscard]] ValueType value() const { return value_; diff --git a/src/util/Coroutine.cpp b/src/util/Coroutine.cpp index 067fb508e..a1d4c660b 100644 --- a/src/util/Coroutine.cpp +++ b/src/util/Coroutine.cpp @@ -7,7 +7,6 @@ #include #include -#include #include #include diff --git a/src/util/CoroutineGroup.hpp b/src/util/CoroutineGroup.hpp index a392957d6..0691eb859 100644 --- a/src/util/CoroutineGroup.hpp +++ b/src/util/CoroutineGroup.hpp @@ -79,7 +79,7 @@ public: * * @return size_t The number of coroutines in the group */ - size_t + [[nodiscard]] size_t size() const; /** @@ -87,7 +87,7 @@ public: * * @return true If the group is full false otherwise */ - bool + [[nodiscard]] bool isFull() const; private: diff --git a/src/web/AdminVerificationStrategy.cpp b/src/web/AdminVerificationStrategy.cpp index 382e6ac33..fdb1cd4c0 100644 --- a/src/web/AdminVerificationStrategy.cpp +++ b/src/web/AdminVerificationStrategy.cpp @@ -6,7 +6,6 @@ #include -#include #include #include #include diff --git a/src/web/SubscriptionContext.hpp b/src/web/SubscriptionContext.hpp index a95c81979..8f2716ad0 100644 --- a/src/web/SubscriptionContext.hpp +++ b/src/web/SubscriptionContext.hpp @@ -74,7 +74,7 @@ public: * * @return The API subversion. */ - uint32_t + [[nodiscard]] uint32_t apiSubversion() const override; }; diff --git a/src/web/ng/SubscriptionContext.hpp b/src/web/ng/SubscriptionContext.hpp index dc793b614..54be02377 100644 --- a/src/web/ng/SubscriptionContext.hpp +++ b/src/web/ng/SubscriptionContext.hpp @@ -103,7 +103,7 @@ public: * * @return The API subversion. */ - uint32_t + [[nodiscard]] uint32_t apiSubversion() const override; /** diff --git a/tests/common/util/CallWithTimeout.cpp b/tests/common/util/CallWithTimeout.cpp index 780518756..a31e11aa3 100644 --- a/tests/common/util/CallWithTimeout.cpp +++ b/tests/common/util/CallWithTimeout.cpp @@ -3,7 +3,6 @@ #include #include -#include #include #include #include diff --git a/tests/unit/app/CliArgsTests.cpp b/tests/unit/app/CliArgsTests.cpp index 611127bd4..77b617e60 100644 --- a/tests/unit/app/CliArgsTests.cpp +++ b/tests/unit/app/CliArgsTests.cpp @@ -209,14 +209,11 @@ TEST_F(CliArgsTestsWithTmpFile, Parse_ConfigDescriptionFileContent) inFile.close(); auto const fileContent = buffer.str(); - EXPECT_TRUE(fileContent.find("# Clio Config Description") != std::string::npos); - EXPECT_TRUE( - fileContent.find( - "This document provides a list of all available Clio configuration properties in " - "detail." - ) != std::string::npos - ); - EXPECT_TRUE(fileContent.find("## Configuration Details") != std::string::npos); + EXPECT_TRUE(fileContent.contains("# Clio Config Description")); + EXPECT_TRUE(fileContent.contains( + "This document provides a list of all available Clio configuration properties in detail." + )); + EXPECT_TRUE(fileContent.contains("## Configuration Details")); // all keys that exist in clio config should be listed in config description file for (auto const& key : getClioConfig()) diff --git a/tests/unit/cluster/ClioNodeTests.cpp b/tests/unit/cluster/ClioNodeTests.cpp index ea4e23c61..43e735298 100644 --- a/tests/unit/cluster/ClioNodeTests.cpp +++ b/tests/unit/cluster/ClioNodeTests.cpp @@ -15,7 +15,6 @@ #include #include -#include #include #include #include diff --git a/tests/unit/data/cassandra/ExecutionStrategyTests.cpp b/tests/unit/data/cassandra/ExecutionStrategyTests.cpp index bd26d9f09..7a8efc633 100644 --- a/tests/unit/data/cassandra/ExecutionStrategyTests.cpp +++ b/tests/unit/data/cassandra/ExecutionStrategyTests.cpp @@ -472,7 +472,7 @@ TEST_F(BackendCassandraExecutionStrategyTest, StatsCallsCountersReport) { auto strat = makeStrategy(); EXPECT_CALL(*counters_, report()); - strat.stats(); + [[maybe_unused]] auto _ = strat.stats(); } TEST_F(BackendCassandraExecutionStrategyTest, WriteEachAndCallSyncSucceeds) diff --git a/tests/unit/etl/AmendmentBlockHandlerTests.cpp b/tests/unit/etl/AmendmentBlockHandlerTests.cpp index c4fd37687..336dcf650 100644 --- a/tests/unit/etl/AmendmentBlockHandlerTests.cpp +++ b/tests/unit/etl/AmendmentBlockHandlerTests.cpp @@ -8,7 +8,6 @@ #include #include -#include #include using namespace etl::impl; diff --git a/tests/unit/etl/MonitorTests.cpp b/tests/unit/etl/MonitorTests.cpp index f88aa5bfb..bd3e556f9 100644 --- a/tests/unit/etl/MonitorTests.cpp +++ b/tests/unit/etl/MonitorTests.cpp @@ -11,7 +11,6 @@ #include #include -#include #include #include #include diff --git a/tests/unit/etl/NetworkValidatedLedgersTests.cpp b/tests/unit/etl/NetworkValidatedLedgersTests.cpp index 887434387..101cc18ad 100644 --- a/tests/unit/etl/NetworkValidatedLedgersTests.cpp +++ b/tests/unit/etl/NetworkValidatedLedgersTests.cpp @@ -6,7 +6,6 @@ #include #include -#include #include #include diff --git a/tests/unit/etl/SubscriptionSourceTests.cpp b/tests/unit/etl/SubscriptionSourceTests.cpp index 03f6db6c7..71c5bebcf 100644 --- a/tests/unit/etl/SubscriptionSourceTests.cpp +++ b/tests/unit/etl/SubscriptionSourceTests.cpp @@ -16,7 +16,6 @@ #include #include -#include #include #include #include diff --git a/tests/unit/etl/SystemStateTests.cpp b/tests/unit/etl/SystemStateTests.cpp index af99a5000..01367f45e 100644 --- a/tests/unit/etl/SystemStateTests.cpp +++ b/tests/unit/etl/SystemStateTests.cpp @@ -10,8 +10,6 @@ #include #include -#include - using namespace etl; using namespace util::config; diff --git a/tests/unit/feed/ForwardFeedTests.cpp b/tests/unit/feed/ForwardFeedTests.cpp index 0f149f5d3..d13fffad9 100644 --- a/tests/unit/feed/ForwardFeedTests.cpp +++ b/tests/unit/feed/ForwardFeedTests.cpp @@ -7,8 +7,6 @@ #include #include -#include - using namespace feed::impl; namespace json = boost::json; using namespace util::prometheus; diff --git a/tests/unit/rpc/handlers/LedgerIndexTests.cpp b/tests/unit/rpc/handlers/LedgerIndexTests.cpp index 2e530e5f6..b83f22bc4 100644 --- a/tests/unit/rpc/handlers/LedgerIndexTests.cpp +++ b/tests/unit/rpc/handlers/LedgerIndexTests.cpp @@ -12,7 +12,6 @@ #include #include -#include #include #include diff --git a/tests/unit/web/ServerTests.cpp b/tests/unit/web/ServerTests.cpp index 326b2be7f..544d2042c 100644 --- a/tests/unit/web/ServerTests.cpp +++ b/tests/unit/web/ServerTests.cpp @@ -712,7 +712,7 @@ TEST_F(WebServerTest, AdminErrorCfgTestBothAdminPasswordAndLocalAdminSet) boost::json::parse(jsonServerConfigWithBothAdminPasswordAndLocalAdmin) )}; - MockLedgerCache cache; + MockLedgerCache const cache; auto const result = web::makeHttpServer(serverConfig, ctx, dosGuardOverload, e, cache); EXPECT_FALSE(result.has_value()); } @@ -736,7 +736,7 @@ TEST_F(WebServerTest, AdminErrorCfgTestBothAdminPasswordAndLocalAdminFalse) boost::json::parse(jsonServerConfigWithNoAdminPasswordAndLocalAdminFalse) )}; - MockLedgerCache cache; + MockLedgerCache const cache; auto const result = web::makeHttpServer(serverConfig, ctx, dosGuardOverload, e, cache); EXPECT_FALSE(result.has_value()); }