From 30dc5182c3bbdc10e4776687867eefbda79933f3 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sun, 28 Jan 2024 10:54:18 +0100 Subject: [PATCH] :rotating_light: fix warning --- tests/src/unit-readme.cpp | 8 ++++---- tests/src/unit-regression2.cpp | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/src/unit-readme.cpp b/tests/src/unit-readme.cpp index f2a571aac..dc99073e2 100644 --- a/tests/src/unit-readme.cpp +++ b/tests/src/unit-readme.cpp @@ -115,7 +115,7 @@ TEST_CASE("README" * doctest::skip()) auto j3 = json::parse(R"({"happy": true, "pi": 3.141})"); // explicit conversion to string - std::string const s = j.dump(); // {\"happy\":true,\"pi\":3.141} + std::string const s = j.dump(); // NOLINT(bugprone-unused-local-non-trivial-variable) // {\"happy\":true,\"pi\":3.141} // serialization with pretty printing // pass in the amount of spaces to indent @@ -152,7 +152,7 @@ TEST_CASE("README" * doctest::skip()) } // getter/setter - const auto tmp = j[0].get(); + const auto tmp = j[0].get(); // NOLINT(bugprone-unused-local-non-trivial-variable) j[1] = 42; bool foo{j.at(2)}; CHECK(foo == true); @@ -237,7 +237,7 @@ TEST_CASE("README" * doctest::skip()) // strings std::string const s1 = "Hello, world!"; json const js = s1; - auto s2 = js.get(); + auto s2 = js.get(); // NOLINT(bugprone-unused-local-non-trivial-variable) // Booleans bool const b1 = true; @@ -253,7 +253,7 @@ TEST_CASE("README" * doctest::skip()) // etc. - std::string const vs = js.get(); + std::string const vs = js.get(); // NOLINT(bugprone-unused-local-non-trivial-variable) bool vb = jb.get(); CHECK(vb == true); int vi = jn.get(); diff --git a/tests/src/unit-regression2.cpp b/tests/src/unit-regression2.cpp index 59932d292..17624d3c6 100644 --- a/tests/src/unit-regression2.cpp +++ b/tests/src/unit-regression2.cpp @@ -218,7 +218,7 @@ class Foo class FooBar { public: - Foo foo{}; + Foo foo{}; // NOLINT(readability-redundant-member-init) }; inline void from_json(const nlohmann::json& j, FooBar& fb) @@ -622,8 +622,8 @@ TEST_CASE("regression tests 2") // see https://github.com/nlohmann/json/pull/2181#issuecomment-653326060 const json j{{"x", "test"}}; const std::string defval = "default value"; - auto val = j.value("x", defval); - auto val2 = j.value("y", defval); + auto val = j.value("x", defval); // NOLINT(bugprone-unused-local-non-trivial-variable) + auto val2 = j.value("y", defval); // NOLINT(bugprone-unused-local-non-trivial-variable) } SECTION("issue #2293 - eof doesn't cause parsing to stop")