🚨 fix warning

This commit is contained in:
Niels Lohmann 2024-01-28 10:54:18 +01:00
parent ef7c68ed3c
commit 30dc5182c3
No known key found for this signature in database
GPG Key ID: 7F3CEA63AE251B69
2 changed files with 7 additions and 7 deletions

View File

@ -115,7 +115,7 @@ TEST_CASE("README" * doctest::skip())
auto j3 = json::parse(R"({"happy": true, "pi": 3.141})"); auto j3 = json::parse(R"({"happy": true, "pi": 3.141})");
// explicit conversion to string // 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 // serialization with pretty printing
// pass in the amount of spaces to indent // pass in the amount of spaces to indent
@ -152,7 +152,7 @@ TEST_CASE("README" * doctest::skip())
} }
// getter/setter // getter/setter
const auto tmp = j[0].get<std::string>(); const auto tmp = j[0].get<std::string>(); // NOLINT(bugprone-unused-local-non-trivial-variable)
j[1] = 42; j[1] = 42;
bool foo{j.at(2)}; bool foo{j.at(2)};
CHECK(foo == true); CHECK(foo == true);
@ -237,7 +237,7 @@ TEST_CASE("README" * doctest::skip())
// strings // strings
std::string const s1 = "Hello, world!"; std::string const s1 = "Hello, world!";
json const js = s1; json const js = s1;
auto s2 = js.get<std::string>(); auto s2 = js.get<std::string>(); // NOLINT(bugprone-unused-local-non-trivial-variable)
// Booleans // Booleans
bool const b1 = true; bool const b1 = true;
@ -253,7 +253,7 @@ TEST_CASE("README" * doctest::skip())
// etc. // etc.
std::string const vs = js.get<std::string>(); std::string const vs = js.get<std::string>(); // NOLINT(bugprone-unused-local-non-trivial-variable)
bool vb = jb.get<bool>(); bool vb = jb.get<bool>();
CHECK(vb == true); CHECK(vb == true);
int vi = jn.get<int>(); int vi = jn.get<int>();

View File

@ -218,7 +218,7 @@ class Foo
class FooBar class FooBar
{ {
public: public:
Foo foo{}; Foo foo{}; // NOLINT(readability-redundant-member-init)
}; };
inline void from_json(const nlohmann::json& j, FooBar& fb) 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 // see https://github.com/nlohmann/json/pull/2181#issuecomment-653326060
const json j{{"x", "test"}}; const json j{{"x", "test"}};
const std::string defval = "default value"; const std::string defval = "default value";
auto val = j.value("x", defval); auto val = j.value("x", defval); // NOLINT(bugprone-unused-local-non-trivial-variable)
auto val2 = j.value("y", defval); auto val2 = j.value("y", defval); // NOLINT(bugprone-unused-local-non-trivial-variable)
} }
SECTION("issue #2293 - eof doesn't cause parsing to stop") SECTION("issue #2293 - eof doesn't cause parsing to stop")