Fix Clang-Tidy warnings (#4047)

This commit is contained in:
Niels Lohmann 2023-06-08 18:46:48 +02:00 committed by GitHub
parent a0c1318830
commit ab06fc9951
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 24 additions and 22 deletions

View File

@ -38,6 +38,7 @@ Checks: '*,
-llvmlibc-*, -llvmlibc-*,
-misc-use-anonymous-namespace, -misc-use-anonymous-namespace,
-misc-confusable-identifiers, -misc-confusable-identifiers,
-misc-include-cleaner,
-misc-no-recursion, -misc-no-recursion,
-misc-non-private-member-variables-in-classes, -misc-non-private-member-variables-in-classes,
-modernize-concat-nested-namespaces, -modernize-concat-nested-namespaces,

View File

@ -69,10 +69,10 @@ template<typename IteratorType> class iteration_proxy_value
// older GCCs are a bit fussy and require explicit noexcept specifiers on defaulted functions // older GCCs are a bit fussy and require explicit noexcept specifiers on defaulted functions
iteration_proxy_value(iteration_proxy_value&&) iteration_proxy_value(iteration_proxy_value&&)
noexcept(std::is_nothrow_move_constructible<IteratorType>::value noexcept(std::is_nothrow_move_constructible<IteratorType>::value
&& std::is_nothrow_move_constructible<string_type>::value) = default; && std::is_nothrow_move_constructible<string_type>::value) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor)
iteration_proxy_value& operator=(iteration_proxy_value&&) iteration_proxy_value& operator=(iteration_proxy_value&&)
noexcept(std::is_nothrow_move_assignable<IteratorType>::value noexcept(std::is_nothrow_move_assignable<IteratorType>::value
&& std::is_nothrow_move_assignable<string_type>::value) = default; && std::is_nothrow_move_assignable<string_type>::value) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor)
~iteration_proxy_value() = default; ~iteration_proxy_value() = default;
/// dereference operator (needed for range-based for) /// dereference operator (needed for range-based for)

View File

@ -118,7 +118,7 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
template<class KeyType, detail::enable_if_t< template<class KeyType, detail::enable_if_t<
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0> detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
T & at(KeyType && key) T & at(KeyType && key) // NOLINT(cppcoreguidelines-missing-std-forward)
{ {
for (auto it = this->begin(); it != this->end(); ++it) for (auto it = this->begin(); it != this->end(); ++it)
{ {
@ -146,7 +146,7 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
template<class KeyType, detail::enable_if_t< template<class KeyType, detail::enable_if_t<
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0> detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
const T & at(KeyType && key) const const T & at(KeyType && key) const // NOLINT(cppcoreguidelines-missing-std-forward)
{ {
for (auto it = this->begin(); it != this->end(); ++it) for (auto it = this->begin(); it != this->end(); ++it)
{ {
@ -180,7 +180,7 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
template<class KeyType, detail::enable_if_t< template<class KeyType, detail::enable_if_t<
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0> detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
size_type erase(KeyType && key) size_type erase(KeyType && key) // NOLINT(cppcoreguidelines-missing-std-forward)
{ {
for (auto it = this->begin(); it != this->end(); ++it) for (auto it = this->begin(); it != this->end(); ++it)
{ {
@ -271,7 +271,7 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
template<class KeyType, detail::enable_if_t< template<class KeyType, detail::enable_if_t<
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0> detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
size_type count(KeyType && key) const size_type count(KeyType && key) const // NOLINT(cppcoreguidelines-missing-std-forward)
{ {
for (auto it = this->begin(); it != this->end(); ++it) for (auto it = this->begin(); it != this->end(); ++it)
{ {
@ -297,7 +297,7 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
template<class KeyType, detail::enable_if_t< template<class KeyType, detail::enable_if_t<
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0> detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
iterator find(KeyType && key) iterator find(KeyType && key) // NOLINT(cppcoreguidelines-missing-std-forward)
{ {
for (auto it = this->begin(); it != this->end(); ++it) for (auto it = this->begin(); it != this->end(); ++it)
{ {

View File

@ -5151,10 +5151,10 @@ template<typename IteratorType> class iteration_proxy_value
// older GCCs are a bit fussy and require explicit noexcept specifiers on defaulted functions // older GCCs are a bit fussy and require explicit noexcept specifiers on defaulted functions
iteration_proxy_value(iteration_proxy_value&&) iteration_proxy_value(iteration_proxy_value&&)
noexcept(std::is_nothrow_move_constructible<IteratorType>::value noexcept(std::is_nothrow_move_constructible<IteratorType>::value
&& std::is_nothrow_move_constructible<string_type>::value) = default; && std::is_nothrow_move_constructible<string_type>::value) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor)
iteration_proxy_value& operator=(iteration_proxy_value&&) iteration_proxy_value& operator=(iteration_proxy_value&&)
noexcept(std::is_nothrow_move_assignable<IteratorType>::value noexcept(std::is_nothrow_move_assignable<IteratorType>::value
&& std::is_nothrow_move_assignable<string_type>::value) = default; && std::is_nothrow_move_assignable<string_type>::value) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor)
~iteration_proxy_value() = default; ~iteration_proxy_value() = default;
/// dereference operator (needed for range-based for) /// dereference operator (needed for range-based for)
@ -19036,7 +19036,7 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
template<class KeyType, detail::enable_if_t< template<class KeyType, detail::enable_if_t<
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0> detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
T & at(KeyType && key) T & at(KeyType && key) // NOLINT(cppcoreguidelines-missing-std-forward)
{ {
for (auto it = this->begin(); it != this->end(); ++it) for (auto it = this->begin(); it != this->end(); ++it)
{ {
@ -19064,7 +19064,7 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
template<class KeyType, detail::enable_if_t< template<class KeyType, detail::enable_if_t<
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0> detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
const T & at(KeyType && key) const const T & at(KeyType && key) const // NOLINT(cppcoreguidelines-missing-std-forward)
{ {
for (auto it = this->begin(); it != this->end(); ++it) for (auto it = this->begin(); it != this->end(); ++it)
{ {
@ -19098,7 +19098,7 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
template<class KeyType, detail::enable_if_t< template<class KeyType, detail::enable_if_t<
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0> detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
size_type erase(KeyType && key) size_type erase(KeyType && key) // NOLINT(cppcoreguidelines-missing-std-forward)
{ {
for (auto it = this->begin(); it != this->end(); ++it) for (auto it = this->begin(); it != this->end(); ++it)
{ {
@ -19189,7 +19189,7 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
template<class KeyType, detail::enable_if_t< template<class KeyType, detail::enable_if_t<
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0> detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
size_type count(KeyType && key) const size_type count(KeyType && key) const // NOLINT(cppcoreguidelines-missing-std-forward)
{ {
for (auto it = this->begin(); it != this->end(); ++it) for (auto it = this->begin(); it != this->end(); ++it)
{ {
@ -19215,7 +19215,7 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
template<class KeyType, detail::enable_if_t< template<class KeyType, detail::enable_if_t<
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0> detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
iterator find(KeyType && key) iterator find(KeyType && key) // NOLINT(cppcoreguidelines-missing-std-forward)
{ {
for (auto it = this->begin(); it != this->end(); ++it) for (auto it = this->begin(); it != this->end(); ++it)
{ {

View File

@ -8,6 +8,7 @@
#include "doctest_compatibility.h" #include "doctest_compatibility.h"
#include <algorithm>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using nlohmann::json; using nlohmann::json;

View File

@ -24,7 +24,7 @@ struct bad_allocator : std::allocator<T>
template<class U> bad_allocator(const bad_allocator<U>& /*unused*/) { } template<class U> bad_allocator(const bad_allocator<U>& /*unused*/) { }
template<class... Args> template<class... Args>
void construct(T* /*unused*/, Args&& ... /*unused*/) void construct(T* /*unused*/, Args&& ... /*unused*/) // NOLINT(cppcoreguidelines-missing-std-forward)
{ {
throw std::bad_alloc(); throw std::bad_alloc();
} }

View File

@ -119,13 +119,13 @@ TEST_CASE("README" * doctest::skip())
// serialization with pretty printing // serialization with pretty printing
// pass in the amount of spaces to indent // pass in the amount of spaces to indent
std::cout << j.dump(4) << std::endl; std::cout << j.dump(4) << std::endl; // NOLINT(performance-avoid-endl)
// { // {
// "happy": true, // "happy": true,
// "pi": 3.141 // "pi": 3.141
// } // }
std::cout << std::setw(2) << j << std::endl; std::cout << std::setw(2) << j << std::endl; // NOLINT(performance-avoid-endl)
} }
{ {

View File

@ -123,7 +123,7 @@ void check_utf8string(bool success_expected, int byte1, int byte2 = -1, int byte
{ {
if (++calls % 100000 == 0) if (++calls % 100000 == 0)
{ {
std::cout << calls << " of 455355 UTF-8 strings checked" << std::endl; std::cout << calls << " of 455355 UTF-8 strings checked" << std::endl; // NOLINT(performance-avoid-endl)
} }
static std::string json_string; static std::string json_string;

View File

@ -123,7 +123,7 @@ void check_utf8string(bool success_expected, int byte1, int byte2 = -1, int byte
{ {
if (++calls % 100000 == 0) if (++calls % 100000 == 0)
{ {
std::cout << calls << " of 1641521 UTF-8 strings checked" << std::endl; std::cout << calls << " of 1641521 UTF-8 strings checked" << std::endl; // NOLINT(performance-avoid-endl)
} }
static std::string json_string; static std::string json_string;

View File

@ -123,7 +123,7 @@ void check_utf8string(bool success_expected, int byte1, int byte2 = -1, int byte
{ {
if (++calls % 100000 == 0) if (++calls % 100000 == 0)
{ {
std::cout << calls << " of 5517507 UTF-8 strings checked" << std::endl; std::cout << calls << " of 5517507 UTF-8 strings checked" << std::endl; // NOLINT(performance-avoid-endl)
} }
static std::string json_string; static std::string json_string;

View File

@ -123,7 +123,7 @@ void check_utf8string(bool success_expected, int byte1, int byte2 = -1, int byte
{ {
if (++calls % 100000 == 0) if (++calls % 100000 == 0)
{ {
std::cout << calls << " of 1246225 UTF-8 strings checked" << std::endl; std::cout << calls << " of 1246225 UTF-8 strings checked" << std::endl; // NOLINT(performance-avoid-endl)
} }
static std::string json_string; static std::string json_string;

View File

@ -300,7 +300,7 @@ template <
/// insert value /// insert value
template<class P> template<class P>
std::pair<iterator, bool> insert( P&& value ) std::pair<iterator, bool> insert( P&& value ) // NOLINT(cppcoreguidelines-missing-std-forward)
{ {
m_compare.add_key(value.first); m_compare.add_key(value.first);
return m_map.insert(value); return m_map.insert(value);