Skip to content

Commit

Permalink
chore: No ALL_CAPS (#1760)
Browse files Browse the repository at this point in the history
Fixes #1680
  • Loading branch information
godexsoft authored Jan 2, 2025
1 parent efe5d08 commit 820b32c
Show file tree
Hide file tree
Showing 361 changed files with 10,086 additions and 9,749 deletions.
34 changes: 34 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ Checks: '-*,
readability-enum-initial-value,
readability-implicit-bool-conversion,
readability-inconsistent-declaration-parameter-name,
readability-identifier-naming,
readability-make-member-function-const,
readability-math-missing-parentheses,
readability-misleading-indentation,
Expand All @@ -149,6 +150,39 @@ Checks: '-*,

CheckOptions:
readability-braces-around-statements.ShortStatementLines: 2
readability-identifier-naming.MacroDefinitionCase: UPPER_CASE
readability-identifier-naming.ClassCase: CamelCase
readability-identifier-naming.StructCase: CamelCase
readability-identifier-naming.UnionCase: CamelCase
readability-identifier-naming.EnumCase: CamelCase
readability-identifier-naming.EnumConstantCase: CamelCase
readability-identifier-naming.ScopedEnumConstantCase: CamelCase
readability-identifier-naming.GlobalConstantCase: UPPER_CASE
readability-identifier-naming.GlobalConstantPrefix: 'k'
readability-identifier-naming.GlobalVariableCase: CamelCase
readability-identifier-naming.GlobalVariablePrefix: 'g'
readability-identifier-naming.ConstexprFunctionCase: camelBack
readability-identifier-naming.ConstexprMethodCase: camelBack
readability-identifier-naming.ClassMethodCase: camelBack
readability-identifier-naming.ClassMemberCase: camelBack
readability-identifier-naming.ClassConstantCase: UPPER_CASE
readability-identifier-naming.ClassConstantPrefix: 'k'
readability-identifier-naming.StaticConstantCase: UPPER_CASE
readability-identifier-naming.StaticConstantPrefix: 'k'
readability-identifier-naming.StaticVariableCase: UPPER_CASE
readability-identifier-naming.StaticVariablePrefix: 'k'
readability-identifier-naming.ConstexprVariableCase: UPPER_CASE
readability-identifier-naming.ConstexprVariablePrefix: 'k'
readability-identifier-naming.LocalConstantCase: camelBack
readability-identifier-naming.LocalVariableCase: camelBack
readability-identifier-naming.TemplateParameterCase: CamelCase
readability-identifier-naming.ParameterCase: camelBack
readability-identifier-naming.FunctionCase: camelBack
readability-identifier-naming.MemberCase: camelBack
readability-identifier-naming.PrivateMemberSuffix: _
readability-identifier-naming.ProtectedMemberSuffix: _
readability-identifier-naming.PublicMemberSuffix: ''
readability-identifier-naming.FunctionIgnoredRegexp: '.*tag_invoke.*'
bugprone-unsafe-functions.ReportMoreUnsafeFunctions: true
bugprone-unused-return-value.CheckedReturnTypes: ::std::error_code;::std::error_condition;::std::errc
misc-include-cleaner.IgnoreHeaders: '.*/(detail|impl)/.*;.*(expected|unexpected).*;.*ranges_lower_bound\.h;time.h;stdlib.h'
Expand Down
6 changes: 3 additions & 3 deletions benchmarks/util/async/ExecutionContextBenchmarks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,10 @@ class TestAnyExecutionContextBatched {
static auto
generateData()
{
constexpr auto TOTAL = 10'000;
constexpr auto kTOTAL = 10'000;
std::vector<uint64_t> data;
data.reserve(TOTAL);
for (auto i = 0; i < TOTAL; ++i)
data.reserve(kTOTAL);
for (auto i = 0; i < kTOTAL; ++i)
data.push_back(util::Random::uniform(1, 100'000'000));

return data;
Expand Down
6 changes: 3 additions & 3 deletions cmake/Build.cpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@

namespace util::build {

static constexpr char versionString[] = "@CLIO_VERSION@";
static constexpr char versionString[] = "@CLIO_VERSION@"; // NOLINT(readability-identifier-naming)

std::string const&
getClioVersionString()
{
static std::string const value = versionString;
static std::string const value = versionString; // NOLINT(readability-identifier-naming)
return value;
}

std::string const&
getClioFullVersionString()
{
static std::string const value = "clio-" + getClioVersionString();
static std::string const value = "clio-" + getClioVersionString(); // NOLINT(readability-identifier-naming)
return value;
}

Expand Down
2 changes: 1 addition & 1 deletion src/app/CliArgs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ CliArgs::parse(int argc, char const* argv[])
description.add_options()
("help,h", "print help message and exit")
("version,v", "print version and exit")
("conf,c", po::value<std::string>()->default_value(defaultConfigPath), "configuration file")
("conf,c", po::value<std::string>()->default_value(kDEFAULT_CONFIG_PATH), "configuration file")
("ng-web-server,w", "Use ng-web-server")
("migrate", po::value<std::string>(), "start migration helper")
;
Expand Down
2 changes: 1 addition & 1 deletion src/app/CliArgs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class CliArgs {
/**
* @brief Default configuration path.
*/
static constexpr char defaultConfigPath[] = "/etc/opt/clio/config.json";
static constexpr char kDEFAULT_CONFIG_PATH[] = "/etc/opt/clio/config.json";

/**
* @brief An action parsed from the command line.
Expand Down
22 changes: 11 additions & 11 deletions src/app/ClioApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,45 +101,45 @@ ClioApplication::run(bool const useNgWebServer)
auto sweepHandler = web::dosguard::IntervalSweepHandler{config_, ioc, dosGuard};

// Interface to the database
auto backend = data::make_Backend(config_);
auto backend = data::makeBackend(config_);

// Manages clients subscribed to streams
auto subscriptions = feed::SubscriptionManager::make_SubscriptionManager(config_, backend);
auto subscriptions = feed::SubscriptionManager::makeSubscriptionManager(config_, backend);

// Tracks which ledgers have been validated by the network
auto ledgers = etl::NetworkValidatedLedgers::make_ValidatedLedgers();
auto ledgers = etl::NetworkValidatedLedgers::makeValidatedLedgers();

// Handles the connection to one or more rippled nodes.
// ETL uses the balancer to extract data.
// The server uses the balancer to forward RPCs to a rippled node.
// The balancer itself publishes to streams (transactions_proposed and accounts_proposed)
auto balancer = etl::LoadBalancer::make_LoadBalancer(config_, ioc, backend, subscriptions, ledgers);
auto balancer = etl::LoadBalancer::makeLoadBalancer(config_, ioc, backend, subscriptions, ledgers);

// ETL is responsible for writing and publishing to streams. In read-only mode, ETL only publishes
auto etl = etl::ETLService::make_ETLService(config_, ioc, backend, subscriptions, balancer, ledgers);
auto etl = etl::ETLService::makeETLService(config_, ioc, backend, subscriptions, balancer, ledgers);

auto workQueue = rpc::WorkQueue::make_WorkQueue(config_);
auto counters = rpc::Counters::make_Counters(workQueue);
auto workQueue = rpc::WorkQueue::makeWorkQueue(config_);
auto counters = rpc::Counters::makeCounters(workQueue);
auto const amendmentCenter = std::make_shared<data::AmendmentCenter const>(backend);
auto const handlerProvider = std::make_shared<rpc::impl::ProductionHandlerProvider const>(
config_, backend, subscriptions, balancer, etl, amendmentCenter, counters
);

using RPCEngineType = rpc::RPCEngine<etl::LoadBalancer, rpc::Counters>;
auto const rpcEngine =
RPCEngineType::make_RPCEngine(config_, backend, balancer, dosGuard, workQueue, counters, handlerProvider);
RPCEngineType::makeRPCEngine(config_, backend, balancer, dosGuard, workQueue, counters, handlerProvider);

if (useNgWebServer or config_.get<bool>("server.__ng_web_server")) {
web::ng::RPCServerHandler<RPCEngineType, etl::ETLService> handler{config_, backend, rpcEngine, etl};

auto expectedAdminVerifier = web::make_AdminVerificationStrategy(config_);
auto expectedAdminVerifier = web::makeAdminVerificationStrategy(config_);
if (not expectedAdminVerifier.has_value()) {
LOG(util::LogService::error()) << "Error creating admin verifier: " << expectedAdminVerifier.error();
return EXIT_FAILURE;
}
auto const adminVerifier = std::move(expectedAdminVerifier).value();

auto httpServer = web::ng::make_Server(config_, OnConnectCheck{dosGuard}, DisconnectHook{dosGuard}, ioc);
auto httpServer = web::ng::makeServer(config_, OnConnectCheck{dosGuard}, DisconnectHook{dosGuard}, ioc);

if (not httpServer.has_value()) {
LOG(util::LogService::error()) << "Error creating web server: " << httpServer.error();
Expand Down Expand Up @@ -170,7 +170,7 @@ ClioApplication::run(bool const useNgWebServer)
auto handler =
std::make_shared<web::RPCServerHandler<RPCEngineType, etl::ETLService>>(config_, backend, rpcEngine, etl);

auto const httpServer = web::make_HttpServer(config_, ioc, dosGuard, handler);
auto const httpServer = web::makeHttpServer(config_, ioc, dosGuard, handler);

// Blocks until stopped.
// When stopped, shared_ptrs fall out of scope
Expand Down
4 changes: 2 additions & 2 deletions src/app/WebHandlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,15 @@ HealthCheckHandler::operator()(
boost::asio::yield_context
)
{
static auto constexpr HealthCheckHTML = R"html(
static auto constexpr kHEALTH_CHECK_HTML = R"html(
<!DOCTYPE html>
<html>
<head><title>Test page for Clio</title></head>
<body><h1>Clio Test</h1><p>This page shows Clio http(s) connectivity is working.</p></body>
</html>
)html";

return web::ng::Response{boost::beast::http::status::ok, HealthCheckHTML, request};
return web::ng::Response{boost::beast::http::status::ok, kHEALTH_CHECK_HTML, request};
}

} // namespace app
4 changes: 2 additions & 2 deletions src/app/WebHandlers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,9 @@ class RequestHandler {
auto jsonResponse = boost::json::parse(response.message()).as_object();
jsonResponse["warning"] = "load";
if (jsonResponse.contains("warnings") && jsonResponse["warnings"].is_array()) {
jsonResponse["warnings"].as_array().push_back(rpc::makeWarning(rpc::warnRPC_RATE_LIMIT));
jsonResponse["warnings"].as_array().push_back(rpc::makeWarning(rpc::WarnRpcRateLimit));
} else {
jsonResponse["warnings"] = boost::json::array{rpc::makeWarning(rpc::warnRPC_RATE_LIMIT)};
jsonResponse["warnings"] = boost::json::array{rpc::makeWarning(rpc::WarnRpcRateLimit)};
}
response.setMessage(jsonResponse);
}
Expand Down
18 changes: 9 additions & 9 deletions src/data/AmendmentCenter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@
namespace {

std::unordered_set<std::string>&
SUPPORTED_AMENDMENTS()
supportedAmendments()
{
static std::unordered_set<std::string> amendments = {};
return amendments;
static std::unordered_set<std::string> kAMENDMENTS = {};
return kAMENDMENTS;
}

bool
Expand All @@ -72,8 +72,8 @@ namespace impl {

WritingAmendmentKey::WritingAmendmentKey(std::string amendmentName) : AmendmentKey{std::move(amendmentName)}
{
ASSERT(not SUPPORTED_AMENDMENTS().contains(name), "Attempt to register the same amendment twice");
SUPPORTED_AMENDMENTS().insert(name);
ASSERT(not supportedAmendments().contains(name), "Attempt to register the same amendment twice");
supportedAmendments().insert(name);
}

} // namespace impl
Expand All @@ -90,7 +90,7 @@ AmendmentKey::operator std::string_view() const

AmendmentKey::operator ripple::uint256() const
{
return Amendment::GetAmendmentId(name);
return Amendment::getAmendmentId(name);
}

AmendmentCenter::AmendmentCenter(std::shared_ptr<data::BackendInterface> const& backend) : backend_{backend}
Expand All @@ -103,9 +103,9 @@ AmendmentCenter::AmendmentCenter(std::shared_ptr<data::BackendInterface> const&
auto const& [name, support] = p;
return Amendment{
.name = name,
.feature = Amendment::GetAmendmentId(name),
.feature = Amendment::getAmendmentId(name),
.isSupportedByXRPL = support != ripple::AmendmentSupport::Unsupported,
.isSupportedByClio = rg::find(SUPPORTED_AMENDMENTS(), name) != rg::end(SUPPORTED_AMENDMENTS()),
.isSupportedByClio = rg::find(supportedAmendments(), name) != rg::end(supportedAmendments()),
.isRetired = support == ripple::AmendmentSupport::Retired
};
}),
Expand Down Expand Up @@ -180,7 +180,7 @@ AmendmentCenter::operator[](AmendmentKey const& key) const
}

ripple::uint256
Amendment::GetAmendmentId(std::string_view name)
Amendment::getAmendmentId(std::string_view name)
{
return ripple::sha512Half(ripple::Slice(name.data(), name.size()));
}
Expand Down
2 changes: 2 additions & 0 deletions src/data/AmendmentCenter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ struct Amendments {
// Most of the time it's going to be no changes at all.

/** @cond */
// NOLINTBEGIN(readability-identifier-naming)
REGISTER(OwnerPaysFee);
REGISTER(Flow);
REGISTER(FlowCross);
Expand Down Expand Up @@ -154,6 +155,7 @@ struct Amendments {
REGISTER(fix1512);
REGISTER(fix1523);
REGISTER(fix1528);
// NOLINTEND(readability-identifier-naming)
/** @endcond */
};

Expand Down
6 changes: 3 additions & 3 deletions src/data/BackendCounters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace data {

namespace {

std::vector<std::int64_t> const histogramBuckets{1, 2, 5, 10, 20, 50, 100, 200, 500, 700, 1000};
std::vector<std::int64_t> const kHISTOGRAM_BUCKETS{1, 2, 5, 10, 20, 50, 100, 200, 500, 700, 1000};

std::int64_t
durationInMillisecondsSince(std::chrono::steady_clock::time_point const startTime)
Expand Down Expand Up @@ -69,13 +69,13 @@ BackendCounters::BackendCounters()
, readDurationHistogram_(PrometheusService::histogramInt(
"backend_duration_milliseconds_histogram",
Labels({Label{"operation", "read"}}),
histogramBuckets,
kHISTOGRAM_BUCKETS,
"The duration of backend read operations including retries"
))
, writeDurationHistogram_(PrometheusService::histogramInt(
"backend_duration_milliseconds_histogram",
Labels({Label{"operation", "write"}}),
histogramBuckets,
kHISTOGRAM_BUCKETS,
"The duration of backend write operations including retries"
))
{
Expand Down
4 changes: 2 additions & 2 deletions src/data/BackendFactory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ namespace data {
* @return A shared_ptr<BackendInterface> with the selected implementation
*/
inline std::shared_ptr<BackendInterface>
make_Backend(util::config::ClioConfigDefinition const& config)
makeBackend(util::config::ClioConfigDefinition const& config)
{
static util::Logger const log{"Backend"};
static util::Logger const log{"Backend"}; // NOLINT(readability-identifier-naming)
LOG(log.info()) << "Constructing BackendInterface";

auto const readOnly = config.get<bool>("read_only");
Expand Down
20 changes: 10 additions & 10 deletions src/data/BackendInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ std::optional<LedgerRange>
BackendInterface::fetchLedgerRange() const
{
std::shared_lock const lck(rngMtx_);
return range;
return range_;
}

void
Expand All @@ -276,16 +276,16 @@ BackendInterface::updateRange(uint32_t newMax)
std::scoped_lock const lck(rngMtx_);

ASSERT(
!range || newMax >= range->maxSequence,
!range_ || newMax >= range_->maxSequence,
"Range shouldn't exist yet or newMax should be greater. newMax = {}, range->maxSequence = {}",
newMax,
range->maxSequence
range_->maxSequence
);

if (!range) {
range = {.minSequence = newMax, .maxSequence = newMax};
if (!range_) {
range_ = {.minSequence = newMax, .maxSequence = newMax};
} else {
range->maxSequence = newMax;
range_->maxSequence = newMax;
}
}

Expand All @@ -296,10 +296,10 @@ BackendInterface::setRange(uint32_t min, uint32_t max, bool force)

if (!force) {
ASSERT(min <= max, "Range min must be less than or equal to max");
ASSERT(not range.has_value(), "Range was already set");
ASSERT(not range_.has_value(), "Range was already set");
}

range = {.minSequence = min, .maxSequence = max};
range_ = {.minSequence = min, .maxSequence = max};
}

LedgerPage
Expand All @@ -320,10 +320,10 @@ BackendInterface::fetchLedgerPage(
ripple::uint256 const& curCursor = [&]() {
if (!keys.empty())
return keys.back();
return (cursor ? *cursor : firstKey);
return (cursor ? *cursor : kFIRST_KEY);
}();

std::uint32_t const seq = outOfOrder ? range->maxSequence : ledgerSequence;
std::uint32_t const seq = outOfOrder ? range_->maxSequence : ledgerSequence;
auto succ = fetchSuccessorKey(curCursor, seq, yield);

if (!succ) {
Expand Down
8 changes: 4 additions & 4 deletions src/data/BackendInterface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class DatabaseTimeout : public std::exception {
}
};

static constexpr std::size_t DEFAULT_WAIT_BETWEEN_RETRY = 500;
static constexpr std::size_t kDEFAULT_WAIT_BETWEEN_RETRY = 500;
/**
* @brief A helper function that catches DatabaseTimout exceptions and retries indefinitely.
*
Expand All @@ -76,9 +76,9 @@ static constexpr std::size_t DEFAULT_WAIT_BETWEEN_RETRY = 500;
*/
template <typename FnType>
auto
retryOnTimeout(FnType func, size_t waitMs = DEFAULT_WAIT_BETWEEN_RETRY)
retryOnTimeout(FnType func, size_t waitMs = kDEFAULT_WAIT_BETWEEN_RETRY)
{
static util::Logger const log{"Backend"};
static util::Logger const log{"Backend"}; // NOLINT(readability-identifier-naming)

while (true) {
try {
Expand Down Expand Up @@ -138,7 +138,7 @@ synchronousAndRetryOnTimeout(FnType&& func)
class BackendInterface {
protected:
mutable std::shared_mutex rngMtx_;
std::optional<LedgerRange> range;
std::optional<LedgerRange> range_;
LedgerCache cache_;
std::optional<etl::CorruptionDetector<LedgerCache>> corruptionDetector_;

Expand Down
Loading

0 comments on commit 820b32c

Please sign in to comment.