From ab06fc99513676e55a518c5ef3f06f86ecd550ef Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Thu, 8 Jun 2023 18:46:48 +0200 Subject: [PATCH] Fix Clang-Tidy warnings (#4047) --- .clang-tidy | 1 + .../nlohmann/detail/iterators/iteration_proxy.hpp | 4 ++-- include/nlohmann/ordered_map.hpp | 10 +++++----- single_include/nlohmann/json.hpp | 14 +++++++------- tests/src/unit-algorithms.cpp | 1 + tests/src/unit-allocator.cpp | 2 +- tests/src/unit-readme.cpp | 4 ++-- tests/src/unit-unicode2.cpp | 2 +- tests/src/unit-unicode3.cpp | 2 +- tests/src/unit-unicode4.cpp | 2 +- tests/src/unit-unicode5.cpp | 2 +- tests/thirdparty/fifo_map/fifo_map.hpp | 2 +- 12 files changed, 24 insertions(+), 22 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index f0bb7b434..1b0fff5ce 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -38,6 +38,7 @@ Checks: '*, -llvmlibc-*, -misc-use-anonymous-namespace, -misc-confusable-identifiers, + -misc-include-cleaner, -misc-no-recursion, -misc-non-private-member-variables-in-classes, -modernize-concat-nested-namespaces, diff --git a/include/nlohmann/detail/iterators/iteration_proxy.hpp b/include/nlohmann/detail/iterators/iteration_proxy.hpp index 61b942000..33bfc36ba 100644 --- a/include/nlohmann/detail/iterators/iteration_proxy.hpp +++ b/include/nlohmann/detail/iterators/iteration_proxy.hpp @@ -69,10 +69,10 @@ template class iteration_proxy_value // older GCCs are a bit fussy and require explicit noexcept specifiers on defaulted functions iteration_proxy_value(iteration_proxy_value&&) noexcept(std::is_nothrow_move_constructible::value - && std::is_nothrow_move_constructible::value) = default; + && std::is_nothrow_move_constructible::value) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor) iteration_proxy_value& operator=(iteration_proxy_value&&) noexcept(std::is_nothrow_move_assignable::value - && std::is_nothrow_move_assignable::value) = default; + && std::is_nothrow_move_assignable::value) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor) ~iteration_proxy_value() = default; /// dereference operator (needed for range-based for) diff --git a/include/nlohmann/ordered_map.hpp b/include/nlohmann/ordered_map.hpp index 55c630d90..5d28cdf20 100644 --- a/include/nlohmann/ordered_map.hpp +++ b/include/nlohmann/ordered_map.hpp @@ -118,7 +118,7 @@ template , template::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) { @@ -146,7 +146,7 @@ template , template::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) { @@ -180,7 +180,7 @@ template , template::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) { @@ -271,7 +271,7 @@ template , template::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) { @@ -297,7 +297,7 @@ template , template::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) { diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 443a69fee..ddd3131dc 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -5151,10 +5151,10 @@ template class iteration_proxy_value // older GCCs are a bit fussy and require explicit noexcept specifiers on defaulted functions iteration_proxy_value(iteration_proxy_value&&) noexcept(std::is_nothrow_move_constructible::value - && std::is_nothrow_move_constructible::value) = default; + && std::is_nothrow_move_constructible::value) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor) iteration_proxy_value& operator=(iteration_proxy_value&&) noexcept(std::is_nothrow_move_assignable::value - && std::is_nothrow_move_assignable::value) = default; + && std::is_nothrow_move_assignable::value) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor) ~iteration_proxy_value() = default; /// dereference operator (needed for range-based for) @@ -19036,7 +19036,7 @@ template , template::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) { @@ -19064,7 +19064,7 @@ template , template::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) { @@ -19098,7 +19098,7 @@ template , template::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) { @@ -19189,7 +19189,7 @@ template , template::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) { @@ -19215,7 +19215,7 @@ template , template::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) { diff --git a/tests/src/unit-algorithms.cpp b/tests/src/unit-algorithms.cpp index f4b87f8fa..d5a997075 100644 --- a/tests/src/unit-algorithms.cpp +++ b/tests/src/unit-algorithms.cpp @@ -8,6 +8,7 @@ #include "doctest_compatibility.h" +#include #include using nlohmann::json; diff --git a/tests/src/unit-allocator.cpp b/tests/src/unit-allocator.cpp index f2e63552a..f9a25b24f 100644 --- a/tests/src/unit-allocator.cpp +++ b/tests/src/unit-allocator.cpp @@ -24,7 +24,7 @@ struct bad_allocator : std::allocator template bad_allocator(const bad_allocator& /*unused*/) { } template - void construct(T* /*unused*/, Args&& ... /*unused*/) + void construct(T* /*unused*/, Args&& ... /*unused*/) // NOLINT(cppcoreguidelines-missing-std-forward) { throw std::bad_alloc(); } diff --git a/tests/src/unit-readme.cpp b/tests/src/unit-readme.cpp index 504466d66..9ed343531 100644 --- a/tests/src/unit-readme.cpp +++ b/tests/src/unit-readme.cpp @@ -119,13 +119,13 @@ TEST_CASE("README" * doctest::skip()) // serialization with pretty printing // 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, // "pi": 3.141 // } - std::cout << std::setw(2) << j << std::endl; + std::cout << std::setw(2) << j << std::endl; // NOLINT(performance-avoid-endl) } { diff --git a/tests/src/unit-unicode2.cpp b/tests/src/unit-unicode2.cpp index 02eab6f95..290bbff94 100644 --- a/tests/src/unit-unicode2.cpp +++ b/tests/src/unit-unicode2.cpp @@ -123,7 +123,7 @@ void check_utf8string(bool success_expected, int byte1, int byte2 = -1, int byte { 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; diff --git a/tests/src/unit-unicode3.cpp b/tests/src/unit-unicode3.cpp index 80cff40ad..396081108 100644 --- a/tests/src/unit-unicode3.cpp +++ b/tests/src/unit-unicode3.cpp @@ -123,7 +123,7 @@ void check_utf8string(bool success_expected, int byte1, int byte2 = -1, int byte { 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; diff --git a/tests/src/unit-unicode4.cpp b/tests/src/unit-unicode4.cpp index 6992b3123..966a241e0 100644 --- a/tests/src/unit-unicode4.cpp +++ b/tests/src/unit-unicode4.cpp @@ -123,7 +123,7 @@ void check_utf8string(bool success_expected, int byte1, int byte2 = -1, int byte { 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; diff --git a/tests/src/unit-unicode5.cpp b/tests/src/unit-unicode5.cpp index be12f3ae3..c75f76701 100644 --- a/tests/src/unit-unicode5.cpp +++ b/tests/src/unit-unicode5.cpp @@ -123,7 +123,7 @@ void check_utf8string(bool success_expected, int byte1, int byte2 = -1, int byte { 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; diff --git a/tests/thirdparty/fifo_map/fifo_map.hpp b/tests/thirdparty/fifo_map/fifo_map.hpp index ea1ce084f..180d1768b 100644 --- a/tests/thirdparty/fifo_map/fifo_map.hpp +++ b/tests/thirdparty/fifo_map/fifo_map.hpp @@ -300,7 +300,7 @@ template < /// insert value template - std::pair insert( P&& value ) + std::pair insert( P&& value ) // NOLINT(cppcoreguidelines-missing-std-forward) { m_compare.add_key(value.first); return m_map.insert(value);