diff --git a/include/nlohmann/detail/view/iterator.hpp b/include/nlohmann/detail/view/iterator.hpp index 78f148609..dfeda4a34 100644 --- a/include/nlohmann/detail/view/iterator.hpp +++ b/include/nlohmann/detail/view/iterator.hpp @@ -183,7 +183,7 @@ class view_item private: iterator m_it; - std::string m_index{}; + std::string m_index{}; // NOLINT(readability-redundant-member-init) }; /// the range returned by basic_json_view::items() diff --git a/single_include/nlohmann/json_view.hpp b/single_include/nlohmann/json_view.hpp index 331d7eaad..6a655d300 100644 --- a/single_include/nlohmann/json_view.hpp +++ b/single_include/nlohmann/json_view.hpp @@ -1946,7 +1946,7 @@ class view_item private: iterator m_it; - std::string m_index{}; + std::string m_index{}; // NOLINT(readability-redundant-member-init) }; /// the range returned by basic_json_view::items() diff --git a/tests/src/unit-json_view.cpp b/tests/src/unit-json_view.cpp index c019eebd0..a8fea7d96 100644 --- a/tests/src/unit-json_view.cpp +++ b/tests/src/unit-json_view.cpp @@ -545,7 +545,7 @@ TEST_CASE("json_view element access and iteration") std::vector keys = {"", "x"}; for (std::size_t n = 1; n <= 40; ++n) { - keys.push_back(std::string(n, 'k')); + keys.emplace_back(n, 'k'); keys.push_back(std::string(n, 'k') + "x"); keys.push_back("x" + std::string(n, 'k')); } @@ -553,7 +553,7 @@ TEST_CASE("json_view element access and iteration") { text += (i != 0 ? ",\"" : "\"") + keys[i] + "\":" + std::to_string(i); } - text += ",\"esc\\u0061ped\":\"escaped key\"}"; + text += ",\"esc\\u0061ped\":\"escaped key\"}"; // NOLINT(modernize-raw-string-literal) const json_document d = json_document::parse(text); const json_view root = d.root(); for (std::size_t i = 0; i < keys.size(); ++i) @@ -623,7 +623,7 @@ TEST_CASE("json_view element access and iteration") } CHECK(v.contains("a") == j.contains("a")); CHECK(v.count("a") == j.count("a")); - CHECK((v.find("a") == v.end()) == (j.find("a") == j.end())); + CHECK((v.find("a") == v.end()) == (j.find("a") == j.end())); // NOLINT(readability-container-contains): find() is what is tested } // where basic_json has undefined behavior, the view answers safely