diff --git a/.clang-tidy b/.clang-tidy index 1b0fff5ce..339360b08 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -43,8 +43,10 @@ Checks: '*, -misc-non-private-member-variables-in-classes, -modernize-concat-nested-namespaces, -modernize-type-traits, + -modernize-use-constraints, -modernize-use-nodiscard, -modernize-use-trailing-return-type, + -performance-enum-size, -readability-function-cognitive-complexity, -readability-function-size, -readability-identifier-length, diff --git a/include/nlohmann/detail/input/lexer.hpp b/include/nlohmann/detail/input/lexer.hpp index 72e995108..50fc9df59 100644 --- a/include/nlohmann/detail/input/lexer.hpp +++ b/include/nlohmann/detail/input/lexer.hpp @@ -222,7 +222,7 @@ class lexer : public lexer_base for (auto range = ranges.begin(); range != ranges.end(); ++range) { get(); - if (JSON_HEDLEY_LIKELY(*range <= current && current <= *(++range))) + if (JSON_HEDLEY_LIKELY(*range <= current && current <= *(++range))) // NOLINT(bugprone-inc-dec-in-conditions) { add(current); } diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index f44b20163..2f9a63131 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -41,6 +41,7 @@ // SPDX-License-Identifier: MIT + #include // #include @@ -53,6 +54,7 @@ // SPDX-License-Identifier: MIT + // This file contains all macro definitions affecting or depending on the ABI #ifndef JSON_SKIP_LIBRARY_VERSION_CHECK @@ -154,6 +156,7 @@ // SPDX-License-Identifier: MIT + #include // transform #include // array #include // forward_list @@ -176,6 +179,7 @@ // SPDX-License-Identifier: MIT + #include // nullptr_t #include // exception #if JSON_DIAGNOSTICS @@ -195,6 +199,7 @@ // SPDX-License-Identifier: MIT + #include // array #include // size_t #include // uint8_t @@ -210,6 +215,7 @@ // SPDX-License-Identifier: MIT + #include // declval, pair // #include // __ _____ _____ _____ @@ -221,6 +227,7 @@ // SPDX-License-Identifier: MIT + #include // #include @@ -233,6 +240,7 @@ // SPDX-License-Identifier: MIT + // #include @@ -2924,6 +2932,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + // #include @@ -2998,6 +3007,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + #include // size_t // #include @@ -3040,6 +3050,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + #include // array #include // size_t #include // conditional, enable_if, false_type, integral_constant, is_constructible, is_integral, is_same, remove_cv, remove_reference, true_type @@ -3212,6 +3223,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + #include // numeric_limits #include // false_type, is_constructible, is_integral, is_same, true_type #include // declval @@ -3227,6 +3239,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + #include // random_access_iterator_tag // #include @@ -3294,6 +3307,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + // #include @@ -3313,6 +3327,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + // #include @@ -4130,6 +4145,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + #include // strlen #include // string #include // forward @@ -4515,6 +4531,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + // #include @@ -4538,6 +4555,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + // #include @@ -5043,6 +5061,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + #include // copy #include // begin, end #include // string @@ -5062,6 +5081,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + #include // size_t #include // input_iterator_tag #include // string, to_string @@ -5782,6 +5802,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + #include // uint8_t, uint64_t #include // tie #include // move @@ -5893,6 +5914,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + #include // uint8_t #include // size_t #include // hash @@ -6025,6 +6047,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + #include // generate_n #include // array #include // ldexp @@ -6050,6 +6073,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + #include // array #include // size_t #include // strlen @@ -6544,6 +6568,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + #include #include // string #include // move @@ -7275,6 +7300,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + #include // array #include // localeconv #include // size_t @@ -7492,7 +7518,7 @@ class lexer : public lexer_base for (auto range = ranges.begin(); range != ranges.end(); ++range) { get(); - if (JSON_HEDLEY_LIKELY(*range <= current && current <= *(++range))) + if (JSON_HEDLEY_LIKELY(*range <= current && current <= *(++range))) // NOLINT(bugprone-inc-dec-in-conditions) { add(current); } @@ -8913,6 +8939,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + #include // size_t #include // declval #include // string @@ -12064,6 +12091,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + #include // isfinite #include // uint8_t #include // function @@ -12580,6 +12608,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + // #include // #include @@ -12592,6 +12621,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + #include // ptrdiff_t #include // numeric_limits @@ -12750,6 +12780,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + #include // iterator, random_access_iterator_tag, bidirectional_iterator_tag, advance, next #include // conditional, is_const, remove_const @@ -13511,6 +13542,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + #include // ptrdiff_t #include // reverse_iterator #include // declval @@ -13679,6 +13711,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + #include // all_of #include // isdigit #include // errno, ERANGE @@ -14673,6 +14706,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + #include #include @@ -14764,6 +14798,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + #include // reverse #include // array #include // map @@ -14789,6 +14824,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + #include // copy #include // size_t #include // back_inserter @@ -16757,6 +16793,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + #include // reverse, remove, fill, find, none_of #include // array #include // localeconv, lconv @@ -16781,6 +16818,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + #include // array #include // signbit, isfinite #include // intN_t, uintN_t @@ -18875,6 +18913,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + #include // equal_to, less #include // initializer_list #include // input_iterator_tag, iterator_traits @@ -24412,6 +24451,7 @@ inline void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL& j1, nlohmann::NLOHMANN_BASIC // SPDX-License-Identifier: MIT + // restore clang diagnostic settings #if defined(__clang__) #pragma clang diagnostic pop @@ -24455,6 +24495,7 @@ inline void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL& j1, nlohmann::NLOHMANN_BASIC // SPDX-License-Identifier: MIT + #undef JSON_HEDLEY_ALWAYS_INLINE #undef JSON_HEDLEY_ARM_VERSION #undef JSON_HEDLEY_ARM_VERSION_CHECK @@ -24605,4 +24646,5 @@ inline void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL& j1, nlohmann::NLOHMANN_BASIC #undef JSON_HEDLEY_FALL_THROUGH + #endif // INCLUDE_NLOHMANN_JSON_HPP_ diff --git a/single_include/nlohmann/json_fwd.hpp b/single_include/nlohmann/json_fwd.hpp index 4940d1e9d..98070dfc9 100644 --- a/single_include/nlohmann/json_fwd.hpp +++ b/single_include/nlohmann/json_fwd.hpp @@ -24,6 +24,8 @@ // SPDX-FileCopyrightText: 2013-2022 Niels Lohmann // SPDX-License-Identifier: MIT + + // This file contains all macro definitions affecting or depending on the ABI #ifndef JSON_SKIP_LIBRARY_VERSION_CHECK @@ -115,6 +117,7 @@ } // namespace nlohmann #endif + /*! @brief namespace for Niels Lohmann @see https://github.com/nlohmann diff --git a/tests/src/fuzzer-parse_bjdata.cpp b/tests/src/fuzzer-parse_bjdata.cpp index 7f0b1b300..ef2f8fc39 100644 --- a/tests/src/fuzzer-parse_bjdata.cpp +++ b/tests/src/fuzzer-parse_bjdata.cpp @@ -45,7 +45,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) // step 2.1: round trip without adding size annotations to container types std::vector const vec2 = json::to_bjdata(j1, false, false); - // step 2.2: round trip with adding size annotations but without adding type annonations to container types + // step 2.2: round trip with adding size annotations but without adding type annotations to container types std::vector const vec3 = json::to_bjdata(j1, true, false); // step 2.3: round trip with adding size as well as type annotations to container types diff --git a/tests/src/fuzzer-parse_ubjson.cpp b/tests/src/fuzzer-parse_ubjson.cpp index 67261deb0..d19418eb0 100644 --- a/tests/src/fuzzer-parse_ubjson.cpp +++ b/tests/src/fuzzer-parse_ubjson.cpp @@ -45,7 +45,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) // step 2.1: round trip without adding size annotations to container types std::vector const vec2 = json::to_ubjson(j1, false, false); - // step 2.2: round trip with adding size annotations but without adding type annonations to container types + // step 2.2: round trip with adding size annotations but without adding type annotations to container types std::vector const vec3 = json::to_ubjson(j1, true, false); // step 2.3: round trip with adding size as well as type annotations to container types diff --git a/tests/src/unit-bjdata.cpp b/tests/src/unit-bjdata.cpp index 1aa3c22b0..919ddf84f 100644 --- a/tests/src/unit-bjdata.cpp +++ b/tests/src/unit-bjdata.cpp @@ -339,13 +339,13 @@ TEST_CASE("BJData") std::vector const numbers { -32769, - -100000, - -1000000, - -10000000, - -100000000, - -1000000000, - -2147483647 - 1, // https://stackoverflow.com/a/29356002/266378 - }; + -100000, + -1000000, + -10000000, + -100000000, + -1000000000, + -2147483647 - 1, // https://stackoverflow.com/a/29356002/266378 + }; for (const auto i : numbers) { CAPTURE(i) diff --git a/tests/src/unit-bson.cpp b/tests/src/unit-bson.cpp index 83a385a0a..31fc2cf05 100644 --- a/tests/src/unit-bson.cpp +++ b/tests/src/unit-bson.cpp @@ -562,7 +562,7 @@ TEST_CASE("BSON") } } - SECTION("Examples from http://bsonspec.org/faq.html") + SECTION("Examples from https://bsonspec.org/faq.html") { SECTION("Example 1") { diff --git a/tests/src/unit-cbor.cpp b/tests/src/unit-cbor.cpp index 1691bf541..0bf33e13d 100644 --- a/tests/src/unit-cbor.cpp +++ b/tests/src/unit-cbor.cpp @@ -241,13 +241,13 @@ TEST_CASE("CBOR") const std::vector numbers { -65537, - -100000, - -1000000, - -10000000, - -100000000, - -1000000000, - -4294967296, - }; + -100000, + -1000000, + -10000000, + -100000000, + -1000000000, + -4294967296, + }; for (const auto i : numbers) { CAPTURE(i) @@ -1962,7 +1962,7 @@ TEST_CASE("CBOR regressions") CHECK(false); } } - catch (const json::parse_error&) + catch (const json::parse_error&) // NOLINT(bugprone-empty-catch) { // parse errors are ok, because input may be random bytes } diff --git a/tests/src/unit-class_parser.cpp b/tests/src/unit-class_parser.cpp index b8bb65406..81f04eb1d 100644 --- a/tests/src/unit-class_parser.cpp +++ b/tests/src/unit-class_parser.cpp @@ -542,13 +542,13 @@ TEST_CASE("parser class") CHECK(parser_helper("9007199254740991").get() == 9007199254740991); } - SECTION("over the edge cases") // issue #178 - Integer conversion to unsigned (incorrect handling of 64 bit integers) + SECTION("over the edge cases") // issue #178 - Integer conversion to unsigned (incorrect handling of 64-bit integers) { // While RFC8259, Section 6 specifies a preference for support // for ranges in range of IEEE 754-2008 binary64 (double precision) - // this does not accommodate 64 bit integers without loss of accuracy. - // As 64 bit integers are now widely used in software, it is desirable - // to expand support to to the full 64 bit (signed and unsigned) range + // this does not accommodate 64-bit integers without loss of accuracy. + // As 64-bit integers are now widely used in software, it is desirable + // to expand support to the full 64 bit (signed and unsigned) range // i.e. -(2**63) -> (2**64)-1. // -(2**63) ** Note: compilers see negative literals as negated positive numbers (hence the -1)) @@ -822,7 +822,7 @@ TEST_CASE("parser class") CHECK(accept_helper("9007199254740991")); } - SECTION("over the edge cases") // issue #178 - Integer conversion to unsigned (incorrect handling of 64 bit integers) + SECTION("over the edge cases") // issue #178 - Integer conversion to unsigned (incorrect handling of 64-bit integers) { // While RFC8259, Section 6 specifies a preference for support // for ranges in range of IEEE 754-2008 binary64 (double precision) diff --git a/tests/src/unit-element_access2.cpp b/tests/src/unit-element_access2.cpp index 70d73f214..ef28df4d6 100644 --- a/tests/src/unit-element_access2.cpp +++ b/tests/src/unit-element_access2.cpp @@ -1521,9 +1521,9 @@ TEST_CASE_TEMPLATE("element access 2 (additional value() tests)", Json, nlohmann CHECK(j.value("foo", cpstr) == "bar"); CHECK(j.value("foo", castr) == "bar"); CHECK(j.value("foo", str) == "bar"); - // this test is in fact different than the one below, + // this test is in fact different from the one below, // because of 0 considering const char * overloads - // where as any other number does not + // whereas any other number does not CHECK(j.value("baz", 0) == 42); CHECK(j.value("baz", 47) == 42); CHECK(j.value("baz", integer) == 42); diff --git a/tests/src/unit-json_pointer.cpp b/tests/src/unit-json_pointer.cpp index 7cb718811..a045e55f3 100644 --- a/tests/src/unit-json_pointer.cpp +++ b/tests/src/unit-json_pointer.cpp @@ -123,8 +123,7 @@ TEST_CASE("JSON pointers") CHECK(j.contains(json::json_pointer("/a~1b"))); CHECK(j.contains(json::json_pointer("/m~0n"))); - // unescaped access - // access to nonexisting values yield object creation + // unescaped access to nonexisting values yield object creation CHECK(!j.contains(json::json_pointer("/a/b"))); CHECK_NOTHROW(j[json::json_pointer("/a/b")] = 42); CHECK(j.contains(json::json_pointer("/a/b"))); diff --git a/tests/src/unit-msgpack.cpp b/tests/src/unit-msgpack.cpp index fa1dac82c..ff4a25f4f 100644 --- a/tests/src/unit-msgpack.cpp +++ b/tests/src/unit-msgpack.cpp @@ -479,11 +479,11 @@ TEST_CASE("MessagePack") std::vector const numbers { -32769, - -65536, - -77777, - -1048576, - -2147483648LL, - }; + -65536, + -77777, + -1048576, + -2147483648LL, + }; for (auto i : numbers) { CAPTURE(i) @@ -1124,7 +1124,7 @@ TEST_CASE("MessagePack") // Checking against an expected vector byte by byte is // difficult, because no assumption on the order of key/value // pairs are made. We therefore only check the prefix (type and - // size and the overall size. The rest is then handled in the + // size) and the overall size. The rest is then handled in the // roundtrip check. CHECK(result.size() == 67); // 1 type, 2 size, 16*4 content CHECK(result[0] == 0xde); // map 16 @@ -1153,7 +1153,7 @@ TEST_CASE("MessagePack") // Checking against an expected vector byte by byte is // difficult, because no assumption on the order of key/value // pairs are made. We therefore only check the prefix (type and - // size and the overall size. The rest is then handled in the + // size) and the overall size. The rest is then handled in the // roundtrip check. CHECK(result.size() == 458757); // 1 type, 4 size, 65536*7 content CHECK(result[0] == 0xdf); // map 32 diff --git a/tests/src/unit-no-mem-leak-on-adl-serialize.cpp b/tests/src/unit-no-mem-leak-on-adl-serialize.cpp index a85592a83..5db7d1b1b 100644 --- a/tests/src/unit-no-mem-leak-on-adl-serialize.cpp +++ b/tests/src/unit-no-mem-leak-on-adl-serialize.cpp @@ -51,7 +51,7 @@ TEST_CASE("check_for_mem_leak_on_adl_to_json-1") const nlohmann::json j = Foo {1, 0}; std::cout << j.dump() << "\n"; } - catch (...) + catch (...) // NOLINT(bugprone-empty-catch) { // just ignore the exception in this POC } @@ -64,7 +64,7 @@ TEST_CASE("check_for_mem_leak_on_adl_to_json-2") const nlohmann::json j = Foo {1, 1}; std::cout << j.dump() << "\n"; } - catch (...) + catch (...) // NOLINT(bugprone-empty-catch) { // just ignore the exception in this POC } @@ -77,7 +77,7 @@ TEST_CASE("check_for_mem_leak_on_adl_to_json-2") const nlohmann::json j = Foo {1, 2}; std::cout << j.dump() << "\n"; } - catch (...) + catch (...) // NOLINT(bugprone-empty-catch) { // just ignore the exception in this POC } diff --git a/tests/src/unit-unicode1.cpp b/tests/src/unit-unicode1.cpp index 726a70d1c..8ed32a124 100644 --- a/tests/src/unit-unicode1.cpp +++ b/tests/src/unit-unicode1.cpp @@ -442,7 +442,7 @@ TEST_CASE("Markus Kuhn's UTF-8 decoder capability and stress test") SECTION("4.1 Examples of an overlong ASCII character") { - // With a safe UTF-8 decoder, all of the following five overlong + // With a safe UTF-8 decoder, all the following five overlong // representations of the ASCII character slash ("/") should be rejected // like a malformed UTF-8 sequence, for instance by substituting it with // a replacement character. If you see a slash below, you do not have a diff --git a/tests/thirdparty/fifo_map/fifo_map.hpp b/tests/thirdparty/fifo_map/fifo_map.hpp index 180d1768b..549b71bf9 100644 --- a/tests/thirdparty/fifo_map/fifo_map.hpp +++ b/tests/thirdparty/fifo_map/fifo_map.hpp @@ -393,7 +393,7 @@ template < } /// swaps the contents - void swap(fifo_map& other) + void swap(fifo_map& other) // NOLINT(cppcoreguidelines-noexcept-swap,performance-noexcept-swap) { std::swap(m_map, other.m_map); std::swap(m_compare, other.m_compare); @@ -520,7 +520,7 @@ template < namespace std // NOLINT(cert-dcl58-cpp,-warnings-as-errors) { template -inline void swap(nlohmann::fifo_map& m1, // NOLINT(cert-dcl58-cpp) +inline void swap(nlohmann::fifo_map& m1, // NOLINT(cert-dcl58-cpp,cppcoreguidelines-noexcept-swap,performance-noexcept-swap) nlohmann::fifo_map& m2) { m1.swap(m2);