Add clang tidy (#864)

Fixes #863
This commit is contained in:
Sergey Kuznetsov
2023-10-03 10:43:54 +01:00
committed by GitHub
parent 69f5025a29
commit 4b53bef1f5
198 changed files with 2168 additions and 1288 deletions

View File

@@ -50,8 +50,10 @@ struct CacheLoaderTest : public MockBackendTest
{
work.reset();
for (auto& optThread : optThreads)
{
if (optThread.joinable())
optThread.join();
}
ctx.stop();
MockBackendTest::TearDown();
}
@@ -88,7 +90,7 @@ getLatestDiff()
TEST_F(CacheLoaderTest, FromCache)
{
MockBackend* rawBackendPtr = static_cast<MockBackend*>(mockBackendPtr.get());
MockBackend* rawBackendPtr = dynamic_cast<MockBackend*>(mockBackendPtr.get());
CacheLoader loader{cfg, ctx, mockBackendPtr, cache};
auto const diffs = getLatestDiff();
@@ -104,22 +106,19 @@ TEST_F(CacheLoaderTest, FromCache)
.WillByDefault(Invoke([&]() -> std::optional<ripple::uint256> {
// mock the result from doFetchSuccessorKey, be aware this function will be called from multiple threads
// for each thread, the last 2 items must be end flag and nullopt, otherwise it will loop forever
std::lock_guard<std::mutex> guard(keysMutex);
std::lock_guard<std::mutex> const guard(keysMutex);
threadKeysMap[std::this_thread::get_id()]++;
if (threadKeysMap[std::this_thread::get_id()] == keysSize - 1)
{
return lastKey;
}
else if (threadKeysMap[std::this_thread::get_id()] == keysSize)
if (threadKeysMap[std::this_thread::get_id()] == keysSize)
{
threadKeysMap[std::this_thread::get_id()] = 0;
return std::nullopt;
}
else
{
return ripple::uint256{INDEX1};
}
return ripple::uint256{INDEX1};
}));
EXPECT_CALL(*rawBackendPtr, doFetchSuccessorKey).Times(keysSize * loops);
@@ -135,7 +134,7 @@ TEST_F(CacheLoaderTest, FromCache)
bool cacheReady = false;
ON_CALL(cache, setFull).WillByDefault(Invoke([&]() {
{
std::lock_guard lk(m);
std::lock_guard const lk(m);
cacheReady = true;
}
cv.notify_one();

View File

@@ -94,7 +94,8 @@ TEST_F(ETLTransformerTest, StopsOnWriteConflict)
TEST_F(ETLTransformerTest, StopsOnEmptyFetchResponse)
{
MockBackend* rawBackendPtr = static_cast<MockBackend*>(mockBackendPtr.get());
MockBackend* rawBackendPtr = dynamic_cast<MockBackend*>(mockBackendPtr.get());
ASSERT_NE(rawBackendPtr, nullptr);
mockBackendPtr->cache().setFull(); // to avoid throwing exception in updateCache
auto const blob = hexStringToBinaryString(RAW_HEADER);
@@ -103,7 +104,7 @@ TEST_F(ETLTransformerTest, StopsOnEmptyFetchResponse)
ON_CALL(dataPipe_, popNext).WillByDefault([this, &response](auto) -> std::optional<FakeFetchResponse> {
if (state_.isStopping)
return std::nullopt;
return response;
return response; // NOLINT (performance-no-automatic-move)
});
ON_CALL(*rawBackendPtr, doFinishWrites).WillByDefault(Return(true));
@@ -129,7 +130,8 @@ TEST_F(ETLTransformerTest, StopsOnEmptyFetchResponse)
TEST_F(ETLTransformerTest, DoesNotPublishIfCanNotBuildNextLedger)
{
MockBackend* rawBackendPtr = static_cast<MockBackend*>(mockBackendPtr.get());
MockBackend* rawBackendPtr = dynamic_cast<MockBackend*>(mockBackendPtr.get());
ASSERT_NE(rawBackendPtr, nullptr);
mockBackendPtr->cache().setFull(); // to avoid throwing exception in updateCache
auto const blob = hexStringToBinaryString(RAW_HEADER);