fix(telemetry): address clang-tidy CI failures on phase9

- MetricsRegistry.cpp: concatenate nested namespaces, add missing
  direct includes (Journal.h, string, string_view, cstdint), suppress
  readability-convert-member-functions-to-static in #else stubs by
  referencing enabled_ member, void unused instanceId parameter.
- MetricsRegistry test: add missing direct includes (Log.h, Journal.h,
  uint256.h, io_context.hpp, optional, stdexcept, string), make
  throwUnimplemented() static, add [[nodiscard]] to getOpenLedger/
  isStopping/getTrapTxID overrides, make const-eligible registry const.
- PerfLogImp.cpp: add braces around if/else body per
  readability-braces-around-statements.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Pratik Mankawde
2026-05-13 18:13:19 +01:00
parent 3131d99029
commit 3c13d788fd
3 changed files with 36 additions and 11 deletions

View File

@@ -19,10 +19,19 @@
#include <xrpld/telemetry/MetricsRegistry.h>
#include <xrpl/basics/Log.h>
#include <xrpl/beast/utility/Journal.h>
#include <xrpl/core/ServiceRegistry.h>
#include <xrpl/protocol/uint256.h>
#include <boost/asio/io_context.hpp>
#include <gtest/gtest.h>
#include <optional>
#include <stdexcept>
#include <string>
using namespace xrpl;
namespace {
@@ -37,8 +46,8 @@ namespace {
*/
class MockServiceRegistry : public ServiceRegistry
{
[[noreturn]] void
throwUnimplemented() const
[[noreturn]] static void
throwUnimplemented()
{
throw std::logic_error("MockServiceRegistry: method not implemented");
}
@@ -195,12 +204,12 @@ public:
{
throwUnimplemented();
}
OpenLedger&
[[nodiscard]] OpenLedger&
getOpenLedger() override
{
throwUnimplemented();
}
OpenLedger const&
[[nodiscard]] OpenLedger const&
getOpenLedger() const override
{
throwUnimplemented();
@@ -250,7 +259,7 @@ public:
{
return nullptr;
}
bool
[[nodiscard]] bool
isStopping() const override
{
return false;
@@ -270,7 +279,7 @@ public:
{
throwUnimplemented();
}
std::optional<uint256> const&
[[nodiscard]] std::optional<uint256> const&
getTrapTxID() const override
{
static std::optional<uint256> const empty;
@@ -301,7 +310,7 @@ protected:
TEST_F(MetricsRegistryTest, disabled_construction)
{
// Construct with enabled=false; should be a no-op.
telemetry::MetricsRegistry registry(false, mockApp_, j_);
telemetry::MetricsRegistry const registry(false, mockApp_, j_);
EXPECT_FALSE(registry.isEnabled());
}