Fix the clang-tidy findings in the tests and headers of the API stack

- make_move_iterator_if_mutable takes the iterator by const reference
  (performance-unnecessary-value-param).
- throw_patch_missing_member builds its message without a local that
  is unused with JSON_NOEXCEPTION (bugprone-unused-local-non-trivial-variable).
- Tests: NOLINT the copies that test the copy constructor and the
  constant mt19937 seed, NOLINT the deliberate "\xC3" "a" literal
  concatenation, use references for the const views in
  unit-throw_messages and return {} from its lambda.

A full clang-tidy 22 run over all 107 test translation units is clean.

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
Niels Lohmann committed 2026-10-16 11:04:30 +02:00
1 parent c759a73ced
commit cb9634301e
7 files changed
+23 -24

No files matched your search

+4 -5
View File
@@ -5795,8 +5795,7 @@ JSON_HEDLEY_NO_RETURN JSON_HEDLEY_NEVER_INLINE void throw_patch_missing_member(c
static_cast<void>(string_type);
static_cast<void>(val);
// context-sensitive error message
const std::string error_msg = (op == "op") ? std::string("operation") : concat("operation '", op, '\'');
JSON_THROW(parse_error::create(exception_id::patch_invalid_operation, 0, concat(error_msg, string_type ? " must have string member '" : " must have member '", member, "'"), &val));
JSON_THROW(parse_error::create(exception_id::patch_invalid_operation, 0, concat((op == "op") ? std::string("operation") : concat("operation '", op, '\''), string_type ? " must have string member '" : " must have member '", member, "'"), &val));
}
template<typename StringType, typename BasicJsonType>
@@ -7209,13 +7208,13 @@ namespace detail
// const (e.g., std::set): libstdc++ before GCC 5 defines the reference of a
// std::move_iterator as value_type&&, which cannot bind to a const element
template<typename Iterator>
std::move_iterator<Iterator> make_move_iterator_if_mutable_impl(Iterator it, std::true_type /*mutable*/)
std::move_iterator<Iterator> make_move_iterator_if_mutable_impl(const Iterator& it, std::true_type /*mutable*/)
{
return std::make_move_iterator(it);
}
template<typename Iterator>
Iterator make_move_iterator_if_mutable_impl(Iterator it, std::false_type /*mutable*/)
Iterator make_move_iterator_if_mutable_impl(const Iterator& it, std::false_type /*mutable*/)
{
return it;
}
@@ -7225,7 +7224,7 @@ using is_mutable_iterator = std::integral_constant < bool,
!std::is_const<typename std::remove_reference<decltype(*std::declval<Iterator&>())>::type>::value >;
template<typename Iterator>
auto make_move_iterator_if_mutable(Iterator it)
auto make_move_iterator_if_mutable(const Iterator& it)
-> decltype(make_move_iterator_if_mutable_impl(it, is_mutable_iterator<Iterator> {}))
{
return make_move_iterator_if_mutable_impl(it, is_mutable_iterator<Iterator> {});