mirror of
https://github.com/nlohmann/json.git
synced 2026-10-01 04:00:31 +00:00
Fix stale and malformed NOLINT comments
json_sax.hpp named "-warnings-as-errors" in the NOLINT list on the two JSON_ASSERT(false) lines; that is the suffix clang-tidy appends to a diagnostic tag under WarningsAsErrors, not a check name, and every other JSON_ASSERT(false) omits it. unit-capacity.cpp carried 30 "// NOLINT(misc-const-correctness)" comments on "json j = ...;" declarations that are all used with non-const members afterwards, so the check has nothing to report there. unit-constructor2.cpp used a blanket "// NOLINT: access after move is OK here" on a use-after-move that hides every check on the line; naming bugprone-use-after-move and hicpp-invalid-access-moved keeps the intent once those checks are re-enabled (#5724). Signed-off-by: Niels Lohmann <mail@nlohmann.me> #5725 item 10
This commit is contained in:
@@ -440,7 +440,7 @@ class json_sax_dom_parser
|
||||
}
|
||||
default: // LCOV_EXCL_LINE
|
||||
// Handle all possible types discretely, default handler should never be reached.
|
||||
JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert,-warnings-as-errors) LCOV_EXCL_LINE
|
||||
JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -891,7 +891,7 @@ class json_sax_dom_callback_parser
|
||||
}
|
||||
default: // LCOV_EXCL_LINE
|
||||
// Handle all possible types discretely, default handler should never be reached.
|
||||
JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert,-warnings-as-errors) LCOV_EXCL_LINE
|
||||
JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11857,7 +11857,7 @@ class json_sax_dom_parser
|
||||
}
|
||||
default: // LCOV_EXCL_LINE
|
||||
// Handle all possible types discretely, default handler should never be reached.
|
||||
JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert,-warnings-as-errors) LCOV_EXCL_LINE
|
||||
JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12308,7 +12308,7 @@ class json_sax_dom_callback_parser
|
||||
}
|
||||
default: // LCOV_EXCL_LINE
|
||||
// Handle all possible types discretely, default handler should never be reached.
|
||||
JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert,-warnings-as-errors) LCOV_EXCL_LINE
|
||||
JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+30
-30
@@ -17,7 +17,7 @@ TEST_CASE("capacity")
|
||||
{
|
||||
SECTION("boolean")
|
||||
{
|
||||
json j = true; // NOLINT(misc-const-correctness)
|
||||
json j = true;
|
||||
const json j_const = true;
|
||||
|
||||
SECTION("result of empty")
|
||||
@@ -35,7 +35,7 @@ TEST_CASE("capacity")
|
||||
|
||||
SECTION("string")
|
||||
{
|
||||
json j = "hello world"; // NOLINT(misc-const-correctness)
|
||||
json j = "hello world";
|
||||
const json j_const = "hello world";
|
||||
|
||||
SECTION("result of empty")
|
||||
@@ -55,7 +55,7 @@ TEST_CASE("capacity")
|
||||
{
|
||||
SECTION("empty array")
|
||||
{
|
||||
json j = json::array(); // NOLINT(misc-const-correctness)
|
||||
json j = json::array();
|
||||
const json j_const = json::array();
|
||||
|
||||
SECTION("result of empty")
|
||||
@@ -73,7 +73,7 @@ TEST_CASE("capacity")
|
||||
|
||||
SECTION("filled array")
|
||||
{
|
||||
json j = {1, 2, 3}; // NOLINT(misc-const-correctness)
|
||||
json j = {1, 2, 3};
|
||||
const json j_const = {1, 2, 3};
|
||||
|
||||
SECTION("result of empty")
|
||||
@@ -94,7 +94,7 @@ TEST_CASE("capacity")
|
||||
{
|
||||
SECTION("empty object")
|
||||
{
|
||||
json j = json::object(); // NOLINT(misc-const-correctness)
|
||||
json j = json::object();
|
||||
const json j_const = json::object();
|
||||
|
||||
SECTION("result of empty")
|
||||
@@ -112,7 +112,7 @@ TEST_CASE("capacity")
|
||||
|
||||
SECTION("filled object")
|
||||
{
|
||||
json j = {{"one", 1}, {"two", 2}, {"three", 3}}; // NOLINT(misc-const-correctness)
|
||||
json j = {{"one", 1}, {"two", 2}, {"three", 3}};
|
||||
const json j_const = {{"one", 1}, {"two", 2}, {"three", 3}};
|
||||
|
||||
SECTION("result of empty")
|
||||
@@ -131,7 +131,7 @@ TEST_CASE("capacity")
|
||||
|
||||
SECTION("number (integer)")
|
||||
{
|
||||
json j = -23; // NOLINT(misc-const-correctness)
|
||||
json j = -23;
|
||||
const json j_const = -23;
|
||||
|
||||
SECTION("result of empty")
|
||||
@@ -149,7 +149,7 @@ TEST_CASE("capacity")
|
||||
|
||||
SECTION("number (unsigned)")
|
||||
{
|
||||
json j = 23u; // NOLINT(misc-const-correctness)
|
||||
json j = 23u;
|
||||
const json j_const = 23u;
|
||||
|
||||
SECTION("result of empty")
|
||||
@@ -167,7 +167,7 @@ TEST_CASE("capacity")
|
||||
|
||||
SECTION("number (float)")
|
||||
{
|
||||
json j = 23.42; // NOLINT(misc-const-correctness)
|
||||
json j = 23.42;
|
||||
const json j_const = 23.42;
|
||||
|
||||
SECTION("result of empty")
|
||||
@@ -185,7 +185,7 @@ TEST_CASE("capacity")
|
||||
|
||||
SECTION("null")
|
||||
{
|
||||
json j = nullptr; // NOLINT(misc-const-correctness)
|
||||
json j = nullptr;
|
||||
const json j_const = nullptr;
|
||||
|
||||
SECTION("result of empty")
|
||||
@@ -206,7 +206,7 @@ TEST_CASE("capacity")
|
||||
{
|
||||
SECTION("boolean")
|
||||
{
|
||||
json j = true; // NOLINT(misc-const-correctness)
|
||||
json j = true;
|
||||
const json j_const = true;
|
||||
|
||||
SECTION("result of size")
|
||||
@@ -226,7 +226,7 @@ TEST_CASE("capacity")
|
||||
|
||||
SECTION("string")
|
||||
{
|
||||
json j = "hello world"; // NOLINT(misc-const-correctness)
|
||||
json j = "hello world";
|
||||
const json j_const = "hello world";
|
||||
|
||||
SECTION("result of size")
|
||||
@@ -248,7 +248,7 @@ TEST_CASE("capacity")
|
||||
{
|
||||
SECTION("empty array")
|
||||
{
|
||||
json j = json::array(); // NOLINT(misc-const-correctness)
|
||||
json j = json::array();
|
||||
const json j_const = json::array();
|
||||
|
||||
SECTION("result of size")
|
||||
@@ -268,7 +268,7 @@ TEST_CASE("capacity")
|
||||
|
||||
SECTION("filled array")
|
||||
{
|
||||
json j = {1, 2, 3}; // NOLINT(misc-const-correctness)
|
||||
json j = {1, 2, 3};
|
||||
const json j_const = {1, 2, 3};
|
||||
|
||||
SECTION("result of size")
|
||||
@@ -291,7 +291,7 @@ TEST_CASE("capacity")
|
||||
{
|
||||
SECTION("empty object")
|
||||
{
|
||||
json j = json::object(); // NOLINT(misc-const-correctness)
|
||||
json j = json::object();
|
||||
const json j_const = json::object();
|
||||
|
||||
SECTION("result of size")
|
||||
@@ -311,7 +311,7 @@ TEST_CASE("capacity")
|
||||
|
||||
SECTION("filled object")
|
||||
{
|
||||
json j = {{"one", 1}, {"two", 2}, {"three", 3}}; // NOLINT(misc-const-correctness)
|
||||
json j = {{"one", 1}, {"two", 2}, {"three", 3}};
|
||||
const json j_const = {{"one", 1}, {"two", 2}, {"three", 3}};
|
||||
|
||||
SECTION("result of size")
|
||||
@@ -332,7 +332,7 @@ TEST_CASE("capacity")
|
||||
|
||||
SECTION("number (integer)")
|
||||
{
|
||||
json j = -23; // NOLINT(misc-const-correctness)
|
||||
json j = -23;
|
||||
const json j_const = -23;
|
||||
|
||||
SECTION("result of size")
|
||||
@@ -352,7 +352,7 @@ TEST_CASE("capacity")
|
||||
|
||||
SECTION("number (unsigned)")
|
||||
{
|
||||
json j = 23u; // NOLINT(misc-const-correctness)
|
||||
json j = 23u;
|
||||
const json j_const = 23u;
|
||||
|
||||
SECTION("result of size")
|
||||
@@ -372,7 +372,7 @@ TEST_CASE("capacity")
|
||||
|
||||
SECTION("number (float)")
|
||||
{
|
||||
json j = 23.42; // NOLINT(misc-const-correctness)
|
||||
json j = 23.42;
|
||||
const json j_const = 23.42;
|
||||
|
||||
SECTION("result of size")
|
||||
@@ -392,7 +392,7 @@ TEST_CASE("capacity")
|
||||
|
||||
SECTION("null")
|
||||
{
|
||||
json j = nullptr; // NOLINT(misc-const-correctness)
|
||||
json j = nullptr;
|
||||
const json j_const = nullptr;
|
||||
|
||||
SECTION("result of size")
|
||||
@@ -415,7 +415,7 @@ TEST_CASE("capacity")
|
||||
{
|
||||
SECTION("boolean")
|
||||
{
|
||||
json j = true; // NOLINT(misc-const-correctness)
|
||||
json j = true;
|
||||
const json j_const = true;
|
||||
|
||||
SECTION("result of max_size")
|
||||
@@ -427,7 +427,7 @@ TEST_CASE("capacity")
|
||||
|
||||
SECTION("string")
|
||||
{
|
||||
json j = "hello world"; // NOLINT(misc-const-correctness)
|
||||
json j = "hello world";
|
||||
const json j_const = "hello world";
|
||||
|
||||
SECTION("result of max_size")
|
||||
@@ -441,7 +441,7 @@ TEST_CASE("capacity")
|
||||
{
|
||||
SECTION("empty array")
|
||||
{
|
||||
json j = json::array(); // NOLINT(misc-const-correctness)
|
||||
json j = json::array();
|
||||
const json j_const = json::array();
|
||||
|
||||
SECTION("result of max_size")
|
||||
@@ -453,7 +453,7 @@ TEST_CASE("capacity")
|
||||
|
||||
SECTION("filled array")
|
||||
{
|
||||
json j = {1, 2, 3}; // NOLINT(misc-const-correctness)
|
||||
json j = {1, 2, 3};
|
||||
const json j_const = {1, 2, 3};
|
||||
|
||||
SECTION("result of max_size")
|
||||
@@ -468,7 +468,7 @@ TEST_CASE("capacity")
|
||||
{
|
||||
SECTION("empty object")
|
||||
{
|
||||
json j = json::object(); // NOLINT(misc-const-correctness)
|
||||
json j = json::object();
|
||||
const json j_const = json::object();
|
||||
|
||||
SECTION("result of max_size")
|
||||
@@ -480,7 +480,7 @@ TEST_CASE("capacity")
|
||||
|
||||
SECTION("filled object")
|
||||
{
|
||||
json j = {{"one", 1}, {"two", 2}, {"three", 3}}; // NOLINT(misc-const-correctness)
|
||||
json j = {{"one", 1}, {"two", 2}, {"three", 3}};
|
||||
const json j_const = {{"one", 1}, {"two", 2}, {"three", 3}};
|
||||
|
||||
SECTION("result of max_size")
|
||||
@@ -493,7 +493,7 @@ TEST_CASE("capacity")
|
||||
|
||||
SECTION("number (integer)")
|
||||
{
|
||||
json j = -23; // NOLINT(misc-const-correctness)
|
||||
json j = -23;
|
||||
const json j_const = -23;
|
||||
|
||||
SECTION("result of max_size")
|
||||
@@ -505,7 +505,7 @@ TEST_CASE("capacity")
|
||||
|
||||
SECTION("number (unsigned)")
|
||||
{
|
||||
json j = 23u; // NOLINT(misc-const-correctness)
|
||||
json j = 23u;
|
||||
const json j_const = 23u;
|
||||
|
||||
SECTION("result of max_size")
|
||||
@@ -517,7 +517,7 @@ TEST_CASE("capacity")
|
||||
|
||||
SECTION("number (float)")
|
||||
{
|
||||
json j = 23.42; // NOLINT(misc-const-correctness)
|
||||
json j = 23.42;
|
||||
const json j_const = 23.42;
|
||||
|
||||
SECTION("result of max_size")
|
||||
@@ -529,7 +529,7 @@ TEST_CASE("capacity")
|
||||
|
||||
SECTION("null")
|
||||
{
|
||||
json j = nullptr; // NOLINT(misc-const-correctness)
|
||||
json j = nullptr;
|
||||
const json j_const = nullptr;
|
||||
|
||||
SECTION("result of max_size")
|
||||
|
||||
@@ -85,7 +85,7 @@ TEST_CASE("other constructors and destructor")
|
||||
CHECK(j.type() == json::value_t::object);
|
||||
const json k(std::move(j));
|
||||
CHECK(k.type() == json::value_t::object);
|
||||
CHECK(j.type() == json::value_t::null); // NOLINT: access after move is OK here
|
||||
CHECK(j.type() == json::value_t::null); // NOLINT(bugprone-use-after-move,hicpp-invalid-access-moved) access after move is OK here
|
||||
}
|
||||
|
||||
SECTION("copy assignment")
|
||||
|
||||
Reference in New Issue
Block a user