From 456735126178f77cfaec294922391e669f8821b9 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sat, 10 Oct 2026 01:24:40 +0200 Subject: [PATCH] Fix clang-tidy 22 findings in unit-json_view_edit.cpp and edit.hpp Signed-off-by: Niels Lohmann (cherry picked from commit cd435ea5d3fbd4f67ef32f1a635937d766973054) --- include/nlohmann/detail/view/edit.hpp | 4 ++-- tests/src/unit-json_view_edit.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/nlohmann/detail/view/edit.hpp b/include/nlohmann/detail/view/edit.hpp index 7a9daa6bc..fb8d769f3 100644 --- a/include/nlohmann/detail/view/edit.hpp +++ b/include/nlohmann/detail/view/edit.hpp @@ -323,7 +323,7 @@ class editor node* w = h + 1; std::size_t erased = 0; bool kept = false; - for (node* r = h + 1, *end = h + h->next; r != end; r += 2) + for (const node* r = h + 1, *end = h + h->next; r != end; r += 2) { const bool match = key_equals(*r, key); if (match && (kept || !keep_first)) @@ -547,7 +547,7 @@ class editor const bool negative = k == value_t::number_integer && static_cast(bits) < 0; std::uint64_t magnitude = negative ? 0 - bits : bits; std::array buf{}; - char* p = buf.data() + buf.size(); + char* p = buf.data() + buf.size(); // NOLINT(misc-const-correctness): digits are written through p do { *--p = static_cast('0' + (magnitude % 10)); diff --git a/tests/src/unit-json_view_edit.cpp b/tests/src/unit-json_view_edit.cpp index 29be6bb1b..215afd6aa 100644 --- a/tests/src/unit-json_view_edit.cpp +++ b/tests/src/unit-json_view_edit.cpp @@ -265,7 +265,7 @@ void check_lookups(const ordered_json_editable_view& v) } else if (v.is_array()) { - for (std::size_t i = 0; i < v.size(); ++i) + for (std::size_t i = 0; i < v.size(); ++i) // NOLINT(modernize-loop-convert): both v[i] and v.at(i) are tested { check_lookups(v[i]); check_lookups(v.at(i));