Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: No ALL_CAPS #1760

Merged
merged 26 commits into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
244abf9
Add clang-tidy case checks to src
godexsoft Nov 25, 2024
d554256
Fix tests clang-tidy and compilation
godexsoft Nov 26, 2024
528bccf
Fix static constexpr
godexsoft Nov 26, 2024
c1f6fad
Wip fix src statics
godexsoft Nov 26, 2024
3a2a56a
Fix naming of statics in tests
godexsoft Nov 26, 2024
2a5cad5
Merge develop and small fixes
godexsoft Nov 26, 2024
3ffcbc8
Fix shadow
godexsoft Nov 26, 2024
db9c566
Disable linting logger statics
godexsoft Nov 26, 2024
3364fba
Disable linting gRPC fakes
godexsoft Nov 27, 2024
da04325
Enforce member function naming
godexsoft Nov 27, 2024
2cc769c
Add few more small fixes
godexsoft Nov 27, 2024
ec02066
Add rules for globals and ignore log
godexsoft Nov 27, 2024
ab03089
Setup acceptable style
godexsoft Nov 28, 2024
9dc59d5
Apply updated clang-tidy settings
godexsoft Nov 28, 2024
479e830
Logger statics better names
godexsoft Nov 28, 2024
201efa1
Fix shadow warnings
godexsoft Nov 28, 2024
f8150f3
Merge branch 'develop' into chore/no-all-caps
godexsoft Nov 28, 2024
ca6b8a8
Constexpr gets special treatment
godexsoft Nov 29, 2024
62779ad
Fixes for compilation
godexsoft Nov 29, 2024
402f81b
Re-run clang-tidy
godexsoft Nov 29, 2024
9ac42b9
Fix small issues reported by clang
godexsoft Nov 29, 2024
926a9f0
Merge branch 'develop' into chore/no-all-caps
godexsoft Dec 2, 2024
5a768b9
Fix typo
godexsoft Dec 2, 2024
4c94d26
Merge branch 'develop' into chore/no-all-caps
godexsoft Dec 26, 2024
04a6da8
Apply new clang-tidy rules
godexsoft Dec 26, 2024
ed29df5
Fix small issues
godexsoft Dec 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
34 changes: 34 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ Checks: '-*,
readability-else-after-return,
readability-implicit-bool-conversion,
readability-inconsistent-declaration-parameter-name,
readability-identifier-naming,
readability-make-member-function-const,
readability-misleading-indentation,
readability-non-const-parameter,
Expand All @@ -140,6 +141,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 @@ -43,7 +43,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")
;
// clang-format on
Expand Down
2 changes: 1 addition & 1 deletion src/app/CliArgs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,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
26 changes: 13 additions & 13 deletions src/app/ClioApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ namespace app {

namespace {

auto constexpr HealthCheckHTML = R"html(
auto constexpr kHEALTH_CHECK_HTML = R"html(
<!DOCTYPE html>
<html>
<head><title>Test page for Clio</title></head>
Expand Down Expand Up @@ -120,45 +120,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_.valueOr("server.__ng_web_server", false)) {
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_, ioc);
auto httpServer = web::ng::makeServer(config_, ioc);

if (not httpServer.has_value()) {
LOG(util::LogService::error()) << "Error creating web server: " << httpServer.error();
Expand Down Expand Up @@ -192,7 +192,7 @@ ClioApplication::run(bool const useNgWebServer)
web::ng::ConnectionMetadata&,
web::SubscriptionContextPtr,
boost::asio::yield_context) -> web::ng::Response {
return web::ng::Response{boost::beast::http::status::ok, HealthCheckHTML, request};
return web::ng::Response{boost::beast::http::status::ok, kHEALTH_CHECK_HTML, request};
}
);

Expand Down Expand Up @@ -243,7 +243,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
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 const& config)
makeBackend(util::Config 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.valueOr("read_only", false);
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 = {newMax, newMax};
if (!range_) {
range_ = {newMax, 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 = {min, max};
range_ = {min, 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
Loading