Fix the cppcheck, clang-tidy and legacy-comparison CI failures

- to_json_tuple_impl() moved the element in both branches of a ternary;
  only one runs, but cppcheck reported accessMoved. Use if/else.
- The ABI tag test looked for "json_abi_bics", which misses when another
  tag comes first, as in json_abi_ldvcmp_bics; look for "_bics".
- readability-qualified-auto in the items() test.

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
Niels Lohmann committed 2026-09-24 07:20:18 +02:00
1 parent 574d98ad93
commit 1fa7c9a8e4
3 files changed
+19 -4

No files matched your search

+3 -2
View File
@@ -35,7 +35,8 @@ TEST_CASE("JSON_BRACE_INIT_COPY_SEMANTICS")
SECTION("the macro is part of the ABI tag")
{
const std::string ns = STRINGIZE(NLOHMANN_JSON_NAMESPACE);
CHECK(ns.find("json_abi_bics") != std::string::npos);
// other tags may come before it, e.g. json_abi_ldvcmp_bics
CHECK(ns.find("_bics") != std::string::npos);
}
SECTION("single-element brace initialization copies the element (#5074)")
@@ -156,7 +157,7 @@ TEST_CASE("JSON_BRACE_INIT_COPY_SEMANTICS")
SECTION("items()")
{
json j_obj = {{"key", 1}};
for (auto& el : j_obj.items())
for (const auto& el : j_obj.items())
{
json const j = el;
CHECK(j.dump() == "{\"key\":1}");