Skip to content

Commit

Permalink
style: clang-tidy auto fixes (#1793)
Browse files Browse the repository at this point in the history
Fixes #1792.
  • Loading branch information
github-actions[bot] authored Dec 18, 2024
1 parent fc3e60f commit 64b50b4
Show file tree
Hide file tree
Showing 16 changed files with 42 additions and 49 deletions.
4 changes: 2 additions & 2 deletions src/app/CliArgs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ CliArgs::parse(int argc, char const* argv[])
if (parsed.count("migrate") != 0u) {
auto const opt = parsed["migrate"].as<std::string>();
if (opt == "status")
return Action{Action::Migrate{std::move(configPath), MigrateSubCmd::status()}};
return Action{Action::Migrate{std::move(configPath), MigrateSubCmd::migration(opt)}};
return Action{Action::Migrate{.configPath=std::move(configPath), .subCmd=MigrateSubCmd::status()}};
return Action{Action::Migrate{.configPath=std::move(configPath), .subCmd=MigrateSubCmd::migration(opt)}};
}

return Action{Action::Run{.configPath = std::move(configPath), .useNgWebServer = parsed.count("ng-web-server") != 0}
Expand Down
1 change: 0 additions & 1 deletion src/main/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include "migration/MigrationApplication.hpp"
#include "rpc/common/impl/HandlerProvider.hpp"
#include "util/TerminationHandler.hpp"
#include "util/config/Config.hpp"
#include "util/log/Logger.hpp"
#include "util/newconfig/ConfigDefinition.hpp"
#include "util/newconfig/ConfigFileJson.hpp"
Expand Down
6 changes: 3 additions & 3 deletions src/migration/cassandra/impl/FullTableScanner.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,14 @@ class FullTableScanner {
return {TokenRange{minValue, maxValue}};

// Safely calculate the range size using uint64_t to avoid overflow
uint64_t rangeSize = (static_cast<uint64_t>(maxValue) * 2) / numRanges_;
uint64_t const rangeSize = (static_cast<uint64_t>(maxValue) * 2) / numRanges_;

std::vector<TokenRange> ranges;
ranges.reserve(numRanges_);

for (std::int64_t i = 0; i < numRanges_; ++i) {
int64_t start = minValue + i * rangeSize;
int64_t end = (i == numRanges_ - 1) ? maxValue : start + static_cast<int64_t>(rangeSize) - 1;
int64_t const start = minValue + (i * rangeSize);
int64_t const end = (i == numRanges_ - 1) ? maxValue : start + static_cast<int64_t>(rangeSize) - 1;
ranges.emplace_back(start, end);
}

Expand Down
1 change: 0 additions & 1 deletion src/migration/cassandra/impl/ObjectsAdapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

#include "migration/cassandra/impl/ObjectsAdapter.hpp"

#include <boost/asio/spawn.hpp>
#include <xrpl/protocol/STLedgerEntry.h>
#include <xrpl/protocol/Serializer.h>

Expand Down
1 change: 0 additions & 1 deletion src/migration/cassandra/impl/TransactionsAdapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

#include "migration/cassandra/impl/TransactionsAdapter.hpp"

#include <boost/asio/spawn.hpp>
#include <xrpl/protocol/STTx.h>
#include <xrpl/protocol/Serializer.h>
#include <xrpl/protocol/TxMeta.h>
Expand Down
5 changes: 3 additions & 2 deletions src/migration/impl/MigrationManagerBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <memory>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

namespace migration::impl {
Expand All @@ -51,9 +52,9 @@ class MigrationManagerBase : public MigrationManagerInterface {
*/
explicit MigrationManagerBase(
std::shared_ptr<typename SupportedMigrators::BackendType> backend,
util::config::ObjectView const& config
util::config::ObjectView config
)
: migrators_{backend}, config_{config}
: migrators_{backend}, config_{std::move(config)}
{
}

Expand Down
2 changes: 1 addition & 1 deletion src/migration/impl/MigratorsRegister.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ class MigratorsRegister {
return "No Description";
} else {
// Fold expression to search through all types
std::string result = ([](std::string const& name) {
std::string const result = ([](std::string const& name) {
return std::string(getDescriptionIfMatch<MigratorType>(name));
}(name) + ...);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@
#include "util/newconfig/Types.hpp"

#include <TestGlobals.hpp>
#include <boost/json/parse.hpp>
#include <boost/json/value.hpp>
#include <fmt/core.h>
#include <algorithm>
#include <gtest/gtest.h>
#include <xrpl/basics/base_uint.h>

Expand Down Expand Up @@ -215,7 +213,7 @@ class MigrationCassandraManagerTxTableTest : public MigrationCassandraSimpleTest
Handle const handle{TestGlobals::instance().backendHost};
EXPECT_TRUE(handle.connect());

std::for_each(std::begin(TransactionsRawData), std::end(TransactionsRawData), [&](auto const& value) {
std::ranges::for_each(TransactionsRawData, [&](auto const& value) {
writeTxFromCSVString(TestGlobals::instance().backendKeyspace, value, handle);
});
}
Expand Down
6 changes: 3 additions & 3 deletions tests/integration/migration/cassandra/DBRawData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include <string>

// The raw data from transactions table in the database
std::
static std::
array<std::string, 100>
TransactionsRawData{
R"(0xaca0197e51c00f300fcfaed2ac427f1bc9ad65b9092fd792f0fde7725a8dbd2e,784222100,5622084,0x201c00000000f8e5110061250055c943558f6f66a8d5f408202f29b502b36492077c7a0e97bd64e21ccc39a662dfdcd90f567033c56f8f95ebffba7bf685d9e050e302cb4d3d7a32710bd3a9a50c85d57d6be624004f2a72624000000005f5a9e2e1e7220000000024004f2a732d00000008624000000005f5a9d88114bec82926f8d033c76995719f00024938323b2e30e1e1e5110080250055c9305505a613d090b2ba61e0c9d9321366f0e3b5c29d2e0daeaaaf394d3b32197be99d56f0be556f5ad63ef5db0f870222320fe8f7c174af79665272a272b65635b1496ae62f672b8ad0753b68747470733a2f2f6174746573746174696f6e2e74687265657872702e6465762f63757272656e63793a353632323036323a353138383230363a32f018e02030170000000000001f75041004011a0000000000000000000000000000000000000000021a0000000000000000000000004155440000000000e1e0203017000000001243acb4041008011a0000000000000000000000000000000000000000021a00000000000000000000000042524c0000000000e1e02030170000000000001cec041004011a0000000000000000000000000000000000000000021a0000000000000000000000004341440000000000e1e0203017000000000000c1ee041005011a0000000000000000000000000000000000000000021a0000000000000000000000004555520000000000e1e02030170000000000001024041004011a0000000000000000000000000000000000000000021a0000000000000000000000004742500000000000e1e0203017000000000006e059041004011a0000000000000000000000000000000000000000021a000000000000000000000000494e520000000000e1e020301700000000000c866d041004011a0000000000000000000000000000000000000000021a0000000000000000000000004a50590000000000e1e02030170000000000001cb1041001011a0000000000000000000000000000000000000000021a0000000000000000000000004b52570000000000e1e0203017000000000001a81f041004011a0000000000000000000000000000000000000000021a0000000000000000000000004d584e0000000000e1e020301700000000000059e3041004011a0000000000000000000000000000000000000000021a0000000000000000000000004d59520000000000e1f1e1e722000000002f672b8b0d340000000000000000753b68747470733a2f2f6174746573746174696f6e2e74687265657872702e6465762f63757272656e63793a353632323038323a353138383231303a32701c0863757272656e6379701d0874687265657872708214bec82926f8d033c76995719f00024938323b2e30f018e02030170000000000001f75041004011a0000000000000000000000000000000000000000021a0000000000000000000000004155440000000000e1e02030170000000000007794041004011a0000000000000000000000000000000000000000021a00000000000000000000000042524c0000000000e1e02030170000000000001cec041004011a0000000000000000000000000000000000000000021a0000000000000000000000004341440000000000e1e0203017000000000000c1b8041005011a0000000000000000000000000000000000000000021a0000000000000000000000004555520000000000e1e0203017000000000000a176041005011a0000000000000000000000000000000000000000021a0000000000000000000000004742500000000000e1e02030170000000000441993041005011a0000000000000000000000000000000000000000021a000000000000000000000000494e520000000000e1e02030170000000004e3f8b5041006011a0000000000000000000000000000000000000000021a0000000000000000000000004a50590000000000e1e02030170000000000001caa041001011a0000000000000000000000000000000000000000021a0000000000000000000000004b52570000000000e1e0203017000000000001a735041004011a0000000000000000000000000000000000000000021a0000000000000000000000004d584e0000000000e1e020301700000000000059e4041004011a0000000000000000000000000000000000000000021a0000000000000000000000004d59520000000000e1f1e1e1f1031000,0x12003324004f2a722f672b8b0d20330000000268400000000000000a7321ede3e86c3cdd6b936bf522f92cad97f6eccf235282cce0234c080e5e84939aa0597440e3fe33a0811be10647ef6c588e718d1caa7f22a81864c67413108da3866fc64af6bed734bc3c83e36e11004ba9ae4230fec1310be1efbef7e346b432961b6408753b68747470733a2f2f6174746573746174696f6e2e74687265657872702e6465762f63757272656e63793a353632323038323a353138383231303a32701c0863757272656e6379701d0874687265657872708114bec82926f8d033c76995719f00024938323b2e30f018e02030170000000000001f75041004011a0000000000000000000000000000000000000000021a0000000000000000000000004155440000000000e1e02030170000000000007794041004011a0000000000000000000000000000000000000000021a00000000000000000000000042524c0000000000e1e02030170000000000001cec041004011a0000000000000000000000000000000000000000021a0000000000000000000000004341440000000000e1e0203017000000000000c1b8041005011a0000000000000000000000000000000000000000021a0000000000000000000000004555520000000000e1e0203017000000000000a176041005011a0000000000000000000000000000000000000000021a0000000000000000000000004742500000000000e1e02030170000000000441993041005011a0000000000000000000000000000000000000000021a000000000000000000000000494e520000000000e1e02030170000000004e3f8b5041006011a0000000000000000000000000000000000000000021a0000000000000000000000004a50590000000000e1e02030170000000000001caa041001011a0000000000000000000000000000000000000000021a0000000000000000000000004b52570000000000e1e0203017000000000001a735041004011a0000000000000000000000000000000000000000021a0000000000000000000000004d584e0000000000e1e020301700000000000059e4041004011a0000000000000000000000000000000000000000021a0000000000000000000000004d59520000000000e1f1)",
Expand Down Expand Up @@ -127,7 +127,7 @@ std::
};

// The raw data from objects table in the database
std::
static std::
array<std::string, 100>
ObjectsRawData{
R"(0x1122b0820a28f4fc59e4692a45b89c38cb66c6d1a986b5e4a75385fb1d5446f7,5619393,0x110080220000000025003a03d02f66d574b03400000000000000005581974c22145a79022c95ce1c675235d7398ae565b50002bb42b050a9b91d0e23701c1020382a62402d23574e35295961607053701d0201238214e10af6934a7ee4a8424a3afc198e84ff9207da72f018e020301700000000000002e4041001011a0000000000000000000000004254430000000000021a0000000000000000000000004554480000000000e1f1)",
Expand Down Expand Up @@ -233,7 +233,7 @@ std::
};

// The raw data from ledgers table in the database
std::array<std::string, 50>
static std::array<std::string, 50>
LedgerHeaderRawData{

R"(5619393,0x0055bec1016344ab372c8d3040776a10f198f65c0444dfe35ff5e2dd922656fd2a3b18e9b069ef8532474cb70000000000000000000000000000000000000000000000000000000000000000d1de0f83a6858df52811e31fe97b8449a4dd55a7d9e0023fe5dc2b335e4c49e82ebe27e92ebe27f00a00707423e7704edf55a2936181f07ac87e3d521cebd8353b84024666f658d7aeef)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include "util/Assert.hpp"
#include "util/newconfig/ObjectView.hpp"

#include <boost/asio/io_context.hpp>
#include <boost/asio/spawn.hpp>

#include <memory>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ ExampleTransactionsMigrator::runMigration(
backend,
[&](ripple::STTx const& tx, ripple::TxMeta const&) {
{
std::lock_guard<std::mutex> lock(mtx);
std::lock_guard<std::mutex> const lock(mtx);
hashSet.insert(ripple::to_string(tx.getTransactionID()));
}
auto const json = tx.getJson(ripple::JsonOptions::none);
Expand Down
15 changes: 7 additions & 8 deletions tests/integration/util/CassandraDBHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,37 +22,36 @@
#include "data/cassandra/impl/Result.hpp"

#include <fmt/core.h>
#include <fmt/format.h>

#include <cstdint>
#include <string>

data::cassandra::ResultOrError
static data::cassandra::ResultOrError
writeTxFromCSVString(std::string const& space, std::string const& record, data::cassandra::Handle const& handler)
{
std::string statement = fmt::format(
std::string const statement = fmt::format(
"INSERT INTO {}.transactions (hash, date, ledger_sequence, metadata, transaction) VALUES ({})", space, record
);

return handler.execute(statement);
}

data::cassandra::ResultOrError
static data::cassandra::ResultOrError
writeObjectFromCSVString(std::string const& space, std::string const& record, data::cassandra::Handle const& handler)
{
std::string statement = fmt::format("INSERT INTO {}.objects (key, sequence, object) VALUES ({})", space, record);
std::string const statement = fmt::format("INSERT INTO {}.objects (key, sequence, object) VALUES ({})", space, record);

return handler.execute(statement);
}

data::cassandra::ResultOrError
static data::cassandra::ResultOrError
writeLedgerFromCSVString(std::string const& space, std::string const& record, data::cassandra::Handle const& handler)
{
std::string statement = fmt::format("INSERT INTO {}.ledgers (sequence, header) VALUES ({})", space, record);
std::string const statement = fmt::format("INSERT INTO {}.ledgers (sequence, header) VALUES ({})", space, record);
return handler.execute(statement);
}

data::cassandra::ResultOrError
static data::cassandra::ResultOrError
writeLedgerRange(
std::string const& space,
std::uint32_t minSeq,
Expand Down
10 changes: 5 additions & 5 deletions tests/unit/migration/MigrationManagerBaseTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ struct MigrationManagerBaseTest : public util::prometheus::WithMockPrometheus, p
MigrationManagerBaseTest()
{
auto mockBackendPtr = backend_.operator std::shared_ptr<MockMigrationBackend>();
TestMigratorRegister migratorRegister(mockBackendPtr);
TestMigratorRegister const migratorRegister(mockBackendPtr);
migrationManager = std::make_shared<TestCassandraMigrationManager>(mockBackendPtr, cfg.getObject("migration"));
}
};
Expand All @@ -67,13 +67,13 @@ TEST_F(MigrationManagerBaseTest, AllStatus)
auto const status = migrationManager->allMigratorsStatusPairs();
EXPECT_EQ(status.size(), 2);
EXPECT_TRUE(
std::find(
status.begin(), status.end(), std::make_tuple("SimpleTestMigrator", migration::MigratorStatus::Migrated)
std::ranges::find(
status, std::make_tuple("SimpleTestMigrator", migration::MigratorStatus::Migrated)
) != status.end()
);
EXPECT_TRUE(
std::find(
status.begin(), status.end(), std::make_tuple("SimpleTestMigrator2", migration::MigratorStatus::NotMigrated)
std::ranges::find(
status, std::make_tuple("SimpleTestMigrator2", migration::MigratorStatus::NotMigrated)
) != status.end()
);
}
Expand Down
1 change: 0 additions & 1 deletion tests/unit/migration/MigrationManagerFactoryTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include "util/newconfig/ConfigValue.hpp"
#include "util/newconfig/Types.hpp"

#include <boost/json/parse.hpp>
#include <gtest/gtest.h>

struct MigrationManagerFactoryTests : public NoLoggerFixture {};
Expand Down
28 changes: 14 additions & 14 deletions tests/unit/migration/MigratorRegisterTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@ TEST_F(MultipleMigratorRegisterTests, GetMigratorsStatusWhenError)
auto const status = migratorRegister->getMigratorsStatus();
EXPECT_EQ(status.size(), 2);
EXPECT_TRUE(
std::find(
status.begin(), status.end(), std::make_tuple("SimpleTestMigrator", migration::MigratorStatus::NotMigrated)
std::ranges::find(
status, std::make_tuple("SimpleTestMigrator", migration::MigratorStatus::NotMigrated)
) != status.end()
);
EXPECT_TRUE(
std::find(
status.begin(), status.end(), std::make_tuple("SimpleTestMigrator2", migration::MigratorStatus::NotMigrated)
std::ranges::find(
status, std::make_tuple("SimpleTestMigrator2", migration::MigratorStatus::NotMigrated)
) != status.end()
);
}
Expand All @@ -108,13 +108,13 @@ TEST_F(MultipleMigratorRegisterTests, GetMigratorsStatusWhenReturnInvalidStatus)
auto const status = migratorRegister->getMigratorsStatus();
EXPECT_EQ(status.size(), 2);
EXPECT_TRUE(
std::find(
status.begin(), status.end(), std::make_tuple("SimpleTestMigrator", migration::MigratorStatus::NotMigrated)
std::ranges::find(
status, std::make_tuple("SimpleTestMigrator", migration::MigratorStatus::NotMigrated)
) != status.end()
);
EXPECT_TRUE(
std::find(
status.begin(), status.end(), std::make_tuple("SimpleTestMigrator2", migration::MigratorStatus::NotMigrated)
std::ranges::find(
status, std::make_tuple("SimpleTestMigrator2", migration::MigratorStatus::NotMigrated)
) != status.end()
);
}
Expand All @@ -128,13 +128,13 @@ TEST_F(MultipleMigratorRegisterTests, GetMigratorsStatusWhenOneMigrated)
auto const status = migratorRegister->getMigratorsStatus();
EXPECT_EQ(status.size(), 2);
EXPECT_TRUE(
std::find(
status.begin(), status.end(), std::make_tuple("SimpleTestMigrator", migration::MigratorStatus::Migrated)
std::ranges::find(
status, std::make_tuple("SimpleTestMigrator", migration::MigratorStatus::Migrated)
) != status.end()
);
EXPECT_TRUE(
std::find(
status.begin(), status.end(), std::make_tuple("SimpleTestMigrator2", migration::MigratorStatus::NotMigrated)
std::ranges::find(
status, std::make_tuple("SimpleTestMigrator2", migration::MigratorStatus::NotMigrated)
) != status.end()
);
}
Expand Down Expand Up @@ -165,8 +165,8 @@ TEST_F(MultipleMigratorRegisterTests, Names)
{
auto names = migratorRegister->getMigratorNames();
EXPECT_EQ(names.size(), 2);
EXPECT_TRUE(std::find(names.begin(), names.end(), "SimpleTestMigrator") != names.end());
EXPECT_TRUE(std::find(names.begin(), names.end(), "SimpleTestMigrator2") != names.end());
EXPECT_TRUE(std::ranges::find(names, "SimpleTestMigrator") != names.end());
EXPECT_TRUE(std::ranges::find(names, "SimpleTestMigrator2") != names.end());
}

TEST_F(MultipleMigratorRegisterTests, Description)
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/migration/MigratorStatusTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ TEST(MigratiorStatus, FromString)

TEST(MigratiorStatus, Compare)
{
migration::MigratorStatus status1(migration::MigratorStatus::Migrated);
migration::MigratorStatus const status1(migration::MigratorStatus::Migrated);
migration::MigratorStatus status2(migration::MigratorStatus::Migrated);
EXPECT_TRUE(status1 == status2);
status2 = migration::MigratorStatus(migration::MigratorStatus::NotMigrated);
Expand Down

0 comments on commit 64b50b4

Please sign in to comment.