From b5da694c9eedb5d8eccbfccfddc4f2815038bbdb Mon Sep 17 00:00:00 2001 From: Bart <11445373+bthomee@users.noreply.github.com> Date: Thu, 7 May 2026 14:35:09 -0400 Subject: [PATCH] Fix clang-tidy findings --- src/test/server/ServerStatus_test.cpp | 56 ++++++++++++--------------- 1 file changed, 25 insertions(+), 31 deletions(-) diff --git a/src/test/server/ServerStatus_test.cpp b/src/test/server/ServerStatus_test.cpp index dbb9ec1835..0db89dc7b5 100644 --- a/src/test/server/ServerStatus_test.cpp +++ b/src/test/server/ServerStatus_test.cpp @@ -536,16 +536,11 @@ class ServerStatus_test : public beast::unit_test::Suite, public beast::test::En doHTTPRequest(env, yield, secure, resp, ec, to_string(jr), auth); BEAST_EXPECT(resp.result() == boost::beast::http::status::forbidden); - // NOLINTNEXTLINE(bugprone-unchecked-optional-access) - auto const user = - env.app().config().section(Sections::kPORT_RPC).get(Keys::kUSER).value(); - auto const pass = - // NOLINTNEXTLINE(bugprone-unchecked-optional-access) - env.app() - .config() - .section(Sections::kPORT_RPC) - .get(Keys::kPASSWORD) - .value(); + auto const section = env.app().config().section(Sections::kPORT_RPC); + // NOLINTBEGIN(bugprone-unchecked-optional-access) + auto const user = section.get(Keys::kUSER).value(); + auto const pass = section.get(Keys::kPASSWORD).value(); + // NOLINTEND(bugprone-unchecked-optional-access) // try with the correct user/pass, but not encoded auth.set("Authorization", "Basic " + user + ":" + pass); @@ -572,12 +567,11 @@ class ServerStatus_test : public beast::unit_test::Suite, public beast::test::En return cfg; })}; - // NOLINTNEXTLINE(bugprone-unchecked-optional-access) - auto const port = - env.app().config()[Sections::kPORT_RPC].get(Keys::kPORT).value(); - - // NOLINTNEXTLINE(bugprone-unchecked-optional-access) - auto const ip = env.app().config()[Sections::kPORT_RPC].get(Keys::kIP).value(); + auto const section = env.app().config().section(Sections::kPORT_RPC); + // NOLINTBEGIN(bugprone-unchecked-optional-access) + auto const port = section.get(Keys::kPORT).value(); + auto const ip = section.get(Keys::kIP).value(); + // NOLINTEND(bugprone-unchecked-optional-access) boost::system::error_code ec; io_context& ios = getIoContext(); @@ -633,11 +627,11 @@ class ServerStatus_test : public beast::unit_test::Suite, public beast::test::En return cfg; })}; - // NOLINTNEXTLINE(bugprone-unchecked-optional-access) - auto const port = - env.app().config()[Sections::kPORT_WS].get(Keys::kPORT).value(); - // NOLINTNEXTLINE(bugprone-unchecked-optional-access) - auto const ip = env.app().config()[Sections::kPORT_WS].get(Keys::kIP).value(); + auto const section = env.app().config().section(Sections::kPORT_WS); + // NOLINTBEGIN(bugprone-unchecked-optional-access) + auto const port = section.get(Keys::kPORT).value(); + auto const ip = section.get(Keys::kIP).value(); + // NOLINTEND(bugprone-unchecked-optional-access) boost::beast::http::response resp; boost::system::error_code ec; doRequest(yield, makeWSUpgrade(ip, port), ip, port, true, resp, ec); @@ -654,11 +648,11 @@ class ServerStatus_test : public beast::unit_test::Suite, public beast::test::En using namespace test::jtx; Env env{*this}; - // NOLINTNEXTLINE(bugprone-unchecked-optional-access) - auto const port = - env.app().config()[Sections::kPORT_WS].get(Keys::kPORT).value(); - // NOLINTNEXTLINE(bugprone-unchecked-optional-access) - auto const ip = env.app().config()[Sections::kPORT_WS].get(Keys::kIP).value(); + auto const section = env.app().config().section(Sections::kPORT_WS); + // NOLINTBEGIN(bugprone-unchecked-optional-access) + auto const port = section.get(Keys::kPORT).value(); + auto const ip = section.get(Keys::kIP).value(); + // NOLINTEND(bugprone-unchecked-optional-access) boost::beast::http::response resp; boost::system::error_code ec; // body content is required here to avoid being @@ -678,11 +672,11 @@ class ServerStatus_test : public beast::unit_test::Suite, public beast::test::En using namespace boost::beast::http; Env env{*this}; - // NOLINTNEXTLINE(bugprone-unchecked-optional-access) - auto const port = - env.app().config()[Sections::kPORT_WS].get(Keys::kPORT).value(); - // NOLINTNEXTLINE(bugprone-unchecked-optional-access) - auto const ip = env.app().config()[Sections::kPORT_WS].get(Keys::kIP).value(); + auto const section = env.app().config().section(Sections::kPORT_WS); + // NOLINTBEGIN(bugprone-unchecked-optional-access) + auto const port = section.get(Keys::kPORT).value(); + auto const ip = section.get(Keys::kIP).value(); + // NOLINTEND(bugprone-unchecked-optional-access) boost::system::error_code ec; io_context& ios = getIoContext();