diff --git a/include/nlohmann/detail/view/lookup.hpp b/include/nlohmann/detail/view/lookup.hpp index 8ec1c155b..11ad8c97f 100644 --- a/include/nlohmann/detail/view/lookup.hpp +++ b/include/nlohmann/detail/view/lookup.hpp @@ -127,7 +127,7 @@ template SizeType to_index(IntegerType idx) noexcept { const IntegerType zero = 0; - const auto result = static_cast(idx); + const auto result = static_cast(idx); // NOLINT(bugprone-signed-char-misuse,cert-str34-c): negative values are mapped below return (idx < zero || static_cast(result) != idx) ? (std::numeric_limits::max)() : result; } diff --git a/include/nlohmann/json_view.hpp b/include/nlohmann/json_view.hpp index 7076764dc..e95d35025 100644 --- a/include/nlohmann/json_view.hpp +++ b/include/nlohmann/json_view.hpp @@ -1062,7 +1062,7 @@ using ordered_json_view = basic_json_view; NLOHMANN_JSON_NAMESPACE_END // tuple protocol for the items of basic_json_view::items() (structured bindings) -namespace std // NOLINT(cert-dcl58-cpp) +namespace std // NOLINT(cert-dcl58-cpp,bugprone-std-namespace-modification) { #if defined(__clang__) @@ -1071,11 +1071,11 @@ namespace std // NOLINT(cert-dcl58-cpp) #pragma clang diagnostic ignored "-Wmismatched-tags" #endif template -class tuple_size<::nlohmann::detail::view::view_item> // NOLINT(cert-dcl58-cpp) +class tuple_size<::nlohmann::detail::view::view_item> // NOLINT(cert-dcl58-cpp,bugprone-std-namespace-modification) : public std::integral_constant {}; template -class tuple_element> // NOLINT(cert-dcl58-cpp) +class tuple_element> // NOLINT(cert-dcl58-cpp,bugprone-std-namespace-modification) { public: using type = decltype(std::declval<::nlohmann::detail::view::view_item>().template get()); diff --git a/tests/src/unit-json_view.cpp b/tests/src/unit-json_view.cpp index 2916e0559..82c68066d 100644 --- a/tests/src/unit-json_view.cpp +++ b/tests/src/unit-json_view.cpp @@ -750,7 +750,7 @@ TEST_CASE("json_view element access and iteration") }) { const std::string key(n, 'k'); - const json_document dk = json_document::parse("{\"" + key + "\":1,\"" + key + "x\":2,\"" + key + "\":3,\"" + key + "\":4}"); + const json_document dk = json_document::parse("{\"" + key + "\":1,\"" + key + "x\":2,\"" + key + "\":3,\"" + key + "\":4}"); // NOLINT(performance-inefficient-string-concatenation) CAPTURE(n) CHECK(dk.root()[key].materialize() == 1); CHECK(dk.root().at(key).materialize() == 1); @@ -983,8 +983,8 @@ TEST_CASE("json_view element access and iteration") pairs += std::string(key) + "=" + value.materialize().dump() + ";"; } CHECK(pairs == "a=1;b=[true,false];"); - static_assert(std::tuple_size::value == 2, ""); - static_assert(std::is_same::type, json_view>::value, ""); + static_assert(std::tuple_size::value == 2, "tuple_size of an item is 2"); + static_assert(std::is_same::type, json_view>::value, "the second element of an item is a view"); #endif } } @@ -1177,19 +1177,19 @@ TEST_CASE("json_view values") switch (i % 5) // NOLINT(hicpp-multiway-paths-covered) { case 0: - std::snprintf(buf.data(), buf.size(), "%.17g", d); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg) + static_cast(std::snprintf(buf.data(), buf.size(), "%.17g", d)); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg) break; case 1: - std::snprintf(buf.data(), buf.size(), "%.15g", d); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg) + static_cast(std::snprintf(buf.data(), buf.size(), "%.15g", d)); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg) break; case 2: - std::snprintf(buf.data(), buf.size(), "%.3e", d); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg) + static_cast(std::snprintf(buf.data(), buf.size(), "%.3e", d)); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg) break; case 3: - std::snprintf(buf.data(), buf.size(), "%.25g", d); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg) + static_cast(std::snprintf(buf.data(), buf.size(), "%.25g", d)); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg) break; default: - std::snprintf(buf.data(), buf.size(), "%.0f", d); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg) + static_cast(std::snprintf(buf.data(), buf.size(), "%.0f", d)); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg) break; } tokens.emplace_back(buf.data()); @@ -1232,7 +1232,7 @@ TEST_CASE("json_view values") const json j = json::parse(text); // user types with from_json, and other types, through basic_json - const record r = v.get(); + const auto r = v.get(); CHECK(r.name == "widget"); CHECK(r.count == 3); CHECK((v["pair"].get>() == j["pair"].get>()));