From 3bb3e0b9f98ff7851c8af8b5ce5a4272503f7b1c Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 22 Jan 2026 11:34:04 +0000 Subject: [PATCH] style: clang-tidy auto fixes (#2930) Fixes #2929. --- src/cluster/Backend.cpp | 7 --- src/cluster/ClusterCommunicationService.cpp | 14 ------ tests/unit/cluster/BackendTests.cpp | 18 +++----- .../ClusterCommunicationServiceTests.cpp | 2 +- tests/unit/cluster/MetricsTests.cpp | 44 ++++++++++++------- tests/unit/etl/ETLServiceTests.cpp | 2 +- tests/unit/etl/LoadingTests.cpp | 1 + tests/unit/etl/RegistryTests.cpp | 2 +- 8 files changed, 38 insertions(+), 52 deletions(-) diff --git a/src/cluster/Backend.cpp b/src/cluster/Backend.cpp index 78a50cd84..b4a88240a 100644 --- a/src/cluster/Backend.cpp +++ b/src/cluster/Backend.cpp @@ -23,15 +23,8 @@ #include "data/BackendInterface.hpp" #include "etl/WriterState.hpp" -#include -#include -#include -#include -#include #include -#include #include -#include #include #include #include diff --git a/src/cluster/ClusterCommunicationService.cpp b/src/cluster/ClusterCommunicationService.cpp index 79f89836e..0437f3cc6 100644 --- a/src/cluster/ClusterCommunicationService.cpp +++ b/src/cluster/ClusterCommunicationService.cpp @@ -22,20 +22,6 @@ #include "data/BackendInterface.hpp" #include "etl/WriterState.hpp" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - #include #include #include diff --git a/tests/unit/cluster/BackendTests.cpp b/tests/unit/cluster/BackendTests.cpp index 869ff1828..43fa3136e 100644 --- a/tests/unit/cluster/BackendTests.cpp +++ b/tests/unit/cluster/BackendTests.cpp @@ -26,13 +26,9 @@ #include #include -#include -#include -#include #include #include #include -#include #include #include @@ -91,7 +87,7 @@ TEST_F(ClusterBackendTest, SubscribeToNewState) EXPECT_CALL(callbackMock, Call) .Times(testing::AtLeast(1)) .WillRepeatedly([this](ClioNode::CUuid selfId, std::shared_ptr clusterData) { - SemaphoreReleaseGuard guard{semaphore}; + SemaphoreReleaseGuard const guard{semaphore}; ASSERT_TRUE(clusterData->has_value()); EXPECT_EQ(clusterData->value().size(), 1); auto const& nodeData = clusterData->value().front(); @@ -141,7 +137,7 @@ TEST_F(ClusterBackendTest, FetchClioNodesDataThrowsException) EXPECT_CALL(callbackMock, Call) .Times(testing::AtLeast(1)) .WillRepeatedly([this](ClioNode::CUuid, std::shared_ptr clusterData) { - SemaphoreReleaseGuard guard{semaphore}; + SemaphoreReleaseGuard const guard{semaphore}; ASSERT_FALSE(clusterData->has_value()); EXPECT_EQ(clusterData->error(), "Failed to fetch Clio nodes data"); }); @@ -181,7 +177,7 @@ TEST_F(ClusterBackendTest, FetchClioNodesDataReturnsDataWithOtherNodes) EXPECT_CALL(callbackMock, Call) .Times(testing::AtLeast(1)) .WillRepeatedly([&](ClioNode::CUuid selfId, std::shared_ptr clusterData) { - SemaphoreReleaseGuard guard{semaphore}; + SemaphoreReleaseGuard const guard{semaphore}; ASSERT_TRUE(clusterData->has_value()) << clusterData->error(); EXPECT_EQ(clusterData->value().size(), 2); EXPECT_EQ(selfId, clusterBackend.selfId()); @@ -231,7 +227,7 @@ TEST_F(ClusterBackendTest, FetchClioNodesDataReturnsOnlySelfData) EXPECT_CALL(callbackMock, Call) .Times(testing::AtLeast(1)) .WillRepeatedly([this](ClioNode::CUuid selfId, std::shared_ptr clusterData) { - SemaphoreReleaseGuard guard{semaphore}; + SemaphoreReleaseGuard const guard{semaphore}; ASSERT_TRUE(clusterData->has_value()); EXPECT_EQ(clusterData->value().size(), 1); auto const& nodeData = clusterData->value().front(); @@ -269,7 +265,7 @@ TEST_F(ClusterBackendTest, FetchClioNodesDataReturnsInvalidJson) EXPECT_CALL(callbackMock, Call) .Times(testing::AtLeast(1)) .WillRepeatedly([this, invalidJson](ClioNode::CUuid, std::shared_ptr clusterData) { - SemaphoreReleaseGuard guard{semaphore}; + SemaphoreReleaseGuard const guard{semaphore}; ASSERT_FALSE(clusterData->has_value()); EXPECT_THAT(clusterData->error(), testing::HasSubstr("Error parsing json from DB")); EXPECT_THAT(clusterData->error(), testing::HasSubstr(invalidJson)); @@ -307,7 +303,7 @@ TEST_F(ClusterBackendTest, FetchClioNodesDataReturnsValidJsonButCannotConvertToC EXPECT_CALL(callbackMock, Call) .Times(testing::AtLeast(1)) .WillRepeatedly([this](ClioNode::CUuid, std::shared_ptr clusterData) { - SemaphoreReleaseGuard guard{semaphore}; + SemaphoreReleaseGuard const guard{semaphore}; ASSERT_FALSE(clusterData->has_value()); EXPECT_THAT(clusterData->error(), testing::HasSubstr("Error converting json to ClioNode")); }); @@ -334,7 +330,7 @@ TEST_F(ClusterBackendTest, WriteNodeMessageWritesSelfDataWithRecentTimestampAndD EXPECT_CALL(*backend_, writeNodeMessage) .Times(testing::AtLeast(1)) .WillRepeatedly([&](boost::uuids::uuid const& uuid, std::string message) { - SemaphoreReleaseGuard guard{semaphore}; + SemaphoreReleaseGuard const guard{semaphore}; auto const afterWrite = std::chrono::system_clock::now(); EXPECT_EQ(uuid, *clusterBackend.selfId()); diff --git a/tests/unit/cluster/ClusterCommunicationServiceTests.cpp b/tests/unit/cluster/ClusterCommunicationServiceTests.cpp index 87d965145..4915e7e7d 100644 --- a/tests/unit/cluster/ClusterCommunicationServiceTests.cpp +++ b/tests/unit/cluster/ClusterCommunicationServiceTests.cpp @@ -72,7 +72,7 @@ struct ClusterCommunicationServiceTest : util::prometheus::WithPrometheus, MockB static std::string nodeToJson(ClioNode const& node) { - boost::json::value v = boost::json::value_from(node); + boost::json::value const v = boost::json::value_from(node); return boost::json::serialize(v); } diff --git a/tests/unit/cluster/MetricsTests.cpp b/tests/unit/cluster/MetricsTests.cpp index d747ddfcf..1baaeb27f 100644 --- a/tests/unit/cluster/MetricsTests.cpp +++ b/tests/unit/cluster/MetricsTests.cpp @@ -55,7 +55,7 @@ TEST_F(MetricsTest, InitializesMetricsOnConstruction) EXPECT_CALL(nodesInClusterMock, set(1)); EXPECT_CALL(isHealthyMock, set(1)); - Metrics metrics; + Metrics const metrics; } TEST_F(MetricsTest, OnNewStateWithValidClusterData) @@ -68,14 +68,18 @@ TEST_F(MetricsTest, OnNewStateWithValidClusterData) Metrics metrics; - ClioNode node1{.uuid = uuid1, .updateTime = std::chrono::system_clock::now(), .dbRole = ClioNode::DbRole::Writer}; - ClioNode node2{.uuid = uuid2, .updateTime = std::chrono::system_clock::now(), .dbRole = ClioNode::DbRole::ReadOnly}; - ClioNode node3{ + ClioNode const node1{ + .uuid = uuid1, .updateTime = std::chrono::system_clock::now(), .dbRole = ClioNode::DbRole::Writer + }; + ClioNode const node2{ + .uuid = uuid2, .updateTime = std::chrono::system_clock::now(), .dbRole = ClioNode::DbRole::ReadOnly + }; + ClioNode const node3{ .uuid = uuid3, .updateTime = std::chrono::system_clock::now(), .dbRole = ClioNode::DbRole::NotWriter }; - std::vector nodes = {node1, node2, node3}; - Backend::ClusterData clusterData = std::expected, std::string>(nodes); + std::vector const nodes = {node1, node2, node3}; + Backend::ClusterData const clusterData = std::expected, std::string>(nodes); auto sharedClusterData = std::make_shared(clusterData); EXPECT_CALL(isHealthyMock, set(1)); @@ -94,8 +98,8 @@ TEST_F(MetricsTest, OnNewStateWithEmptyClusterData) Metrics metrics; - std::vector nodes = {}; - Backend::ClusterData clusterData = std::expected, std::string>(nodes); + std::vector const nodes = {}; + Backend::ClusterData const clusterData = std::expected, std::string>(nodes); auto sharedClusterData = std::make_shared(clusterData); EXPECT_CALL(isHealthyMock, set(1)); @@ -114,7 +118,7 @@ TEST_F(MetricsTest, OnNewStateWithFailedClusterData) Metrics metrics; - Backend::ClusterData clusterData = + Backend::ClusterData const clusterData = std::expected, std::string>(std::unexpected("Connection failed")); auto sharedClusterData = std::make_shared(clusterData); @@ -134,10 +138,12 @@ TEST_F(MetricsTest, OnNewStateWithSingleNode) Metrics metrics; - ClioNode node1{.uuid = uuid1, .updateTime = std::chrono::system_clock::now(), .dbRole = ClioNode::DbRole::Writer}; + ClioNode const node1{ + .uuid = uuid1, .updateTime = std::chrono::system_clock::now(), .dbRole = ClioNode::DbRole::Writer + }; - std::vector nodes = {node1}; - Backend::ClusterData clusterData = std::expected, std::string>(nodes); + std::vector const nodes = {node1}; + Backend::ClusterData const clusterData = std::expected, std::string>(nodes); auto sharedClusterData = std::make_shared(clusterData); EXPECT_CALL(isHealthyMock, set(1)); @@ -156,7 +162,7 @@ TEST_F(MetricsTest, OnNewStateRecoveryFromFailure) Metrics metrics; - Backend::ClusterData clusterData1 = + Backend::ClusterData const clusterData1 = std::expected, std::string>(std::unexpected("Connection timeout")); auto sharedClusterData1 = std::make_shared(clusterData1); @@ -165,11 +171,15 @@ TEST_F(MetricsTest, OnNewStateRecoveryFromFailure) metrics.onNewState(uuid1, sharedClusterData1); - ClioNode node1{.uuid = uuid1, .updateTime = std::chrono::system_clock::now(), .dbRole = ClioNode::DbRole::Writer}; - ClioNode node2{.uuid = uuid2, .updateTime = std::chrono::system_clock::now(), .dbRole = ClioNode::DbRole::ReadOnly}; + ClioNode const node1{ + .uuid = uuid1, .updateTime = std::chrono::system_clock::now(), .dbRole = ClioNode::DbRole::Writer + }; + ClioNode const node2{ + .uuid = uuid2, .updateTime = std::chrono::system_clock::now(), .dbRole = ClioNode::DbRole::ReadOnly + }; - std::vector nodes = {node1, node2}; - Backend::ClusterData clusterData2 = std::expected, std::string>(nodes); + std::vector const nodes = {node1, node2}; + Backend::ClusterData const clusterData2 = std::expected, std::string>(nodes); auto sharedClusterData2 = std::make_shared(clusterData2); EXPECT_CALL(isHealthyMock, set(1)); diff --git a/tests/unit/etl/ETLServiceTests.cpp b/tests/unit/etl/ETLServiceTests.cpp index 91625600f..1b68b1dc6 100644 --- a/tests/unit/etl/ETLServiceTests.cpp +++ b/tests/unit/etl/ETLServiceTests.cpp @@ -898,7 +898,7 @@ TEST_F(ETLServiceTests, WriteCommandsAreSerializedOnStrand) // Set up expectations for the sequence of write commands // The signals should be processed in order: StartWriting, StopWriting, StartWriting { - testing::InSequence seq; + testing::InSequence const seq; // First StartWriting EXPECT_CALL(mockWriteSignalCommandCallback_, Call(etl::SystemState::WriteCommand::StartWriting)); diff --git a/tests/unit/etl/LoadingTests.cpp b/tests/unit/etl/LoadingTests.cpp index e65f77060..040828045 100644 --- a/tests/unit/etl/LoadingTests.cpp +++ b/tests/unit/etl/LoadingTests.cpp @@ -19,6 +19,7 @@ #include "data/Types.hpp" #include "etl/InitialLoadObserverInterface.hpp" +#include "etl/LoaderInterface.hpp" #include "etl/Models.hpp" #include "etl/RegistryInterface.hpp" #include "etl/SystemState.hpp" diff --git a/tests/unit/etl/RegistryTests.cpp b/tests/unit/etl/RegistryTests.cpp index 41382b873..440f09bfd 100644 --- a/tests/unit/etl/RegistryTests.cpp +++ b/tests/unit/etl/RegistryTests.cpp @@ -260,7 +260,7 @@ struct RegistryTest : util::prometheus::WithPrometheus { } protected: - etl::SystemState state_{}; + etl::SystemState state_; }; } // namespace