Fix CI: clang-tidy and JSON_NOEXCEPTION in the #3989 changes

ci_clang_tidy flagged nested conditional operators in the BON8 skip
code and in remove_incomplete_utf8_sequence()
(readability-avoid-nested-conditional-operator), and two branches with
the same body in recover_string() (bugprone-branch-clone). Use if
chains instead of the nested conditionals and merge the two branches
into one condition; the short-circuit order is unchanged.

ci_test_noexceptions aborted in the #3989 regression test: it compares
the first recovered error with the message of the exception that
from_cbor() and friends throw, and under JSON_NOEXCEPTION that call
aborts instead of throwing. Guard binary_error_message() and its uses
with #if !defined(JSON_NOEXCEPTION), as other tests in the suite do.

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
Niels Lohmann
2026-09-29 16:42:57 +02:00
parent 4bdf1b7e74
commit 792853d725
4 changed files with 53 additions and 18 deletions
@@ -4537,7 +4537,11 @@ class binary_reader
{
return false;
}
return skip_bon8_bytes((byte <= 0xDF) ? 0 : ((byte <= 0xEF) ? 1 : 2));
if (byte <= 0xDF)
{
return skip_bon8_bytes(0);
}
return skip_bon8_bytes((byte <= 0xEF) ? 1 : 2);
}
/*!