mirror of
https://github.com/nlohmann/json
synced 2024-11-24 04:40:13 +00:00
Suppress Clang-Tidy warnings (#4276)
This commit is contained in:
parent
6a064e026a
commit
c35d260c2f
@ -45,6 +45,7 @@ Checks: '*,
|
||||
-modernize-type-traits,
|
||||
-modernize-use-constraints,
|
||||
-modernize-use-nodiscard,
|
||||
-modernize-use-std-numbers,
|
||||
-modernize-use-trailing-return-type,
|
||||
-performance-enum-size,
|
||||
-readability-function-cognitive-complexity,
|
||||
|
@ -632,9 +632,9 @@ class json_sax_dom_callback_parser
|
||||
/// stack to model hierarchy of values
|
||||
std::vector<BasicJsonType*> ref_stack {};
|
||||
/// stack to manage which values to keep
|
||||
std::vector<bool> keep_stack {};
|
||||
std::vector<bool> keep_stack {}; // NOLINT(readability-redundant-member-init)
|
||||
/// stack to manage which object keys to keep
|
||||
std::vector<bool> key_keep_stack {};
|
||||
std::vector<bool> key_keep_stack {}; // NOLINT(readability-redundant-member-init)
|
||||
/// helper to hold the reference for the next object element
|
||||
BasicJsonType* object_element = nullptr;
|
||||
/// whether a syntax error occurred
|
||||
|
@ -4847,7 +4847,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
auto it = val.m_data.m_value.object->find(member);
|
||||
|
||||
// context-sensitive error message
|
||||
const auto error_msg = (op == "op") ? "operation" : detail::concat("operation '", op, '\'');
|
||||
const auto error_msg = (op == "op") ? "operation" : detail::concat("operation '", op, '\''); // NOLINT(bugprone-unused-local-non-trivial-variable)
|
||||
|
||||
// check if desired value is present
|
||||
if (JSON_HEDLEY_UNLIKELY(it == val.m_data.m_value.object->end()))
|
||||
|
@ -7271,9 +7271,9 @@ class json_sax_dom_callback_parser
|
||||
/// stack to model hierarchy of values
|
||||
std::vector<BasicJsonType*> ref_stack {};
|
||||
/// stack to manage which values to keep
|
||||
std::vector<bool> keep_stack {};
|
||||
std::vector<bool> keep_stack {}; // NOLINT(readability-redundant-member-init)
|
||||
/// stack to manage which object keys to keep
|
||||
std::vector<bool> key_keep_stack {};
|
||||
std::vector<bool> key_keep_stack {}; // NOLINT(readability-redundant-member-init)
|
||||
/// helper to hold the reference for the next object element
|
||||
BasicJsonType* object_element = nullptr;
|
||||
/// whether a syntax error occurred
|
||||
@ -24150,7 +24150,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
auto it = val.m_data.m_value.object->find(member);
|
||||
|
||||
// context-sensitive error message
|
||||
const auto error_msg = (op == "op") ? "operation" : detail::concat("operation '", op, '\'');
|
||||
const auto error_msg = (op == "op") ? "operation" : detail::concat("operation '", op, '\''); // NOLINT(bugprone-unused-local-non-trivial-variable)
|
||||
|
||||
// check if desired value is present
|
||||
if (JSON_HEDLEY_UNLIKELY(it == val.m_data.m_value.object->end()))
|
||||
|
@ -158,7 +158,7 @@ class alt_string
|
||||
}
|
||||
|
||||
private:
|
||||
std::string str_impl {};
|
||||
std::string str_impl {}; // NOLINT(readability-redundant-member-init)
|
||||
|
||||
friend bool operator<(const char* /*op1*/, const alt_string& /*op2*/) noexcept;
|
||||
};
|
||||
|
@ -124,7 +124,7 @@ class SaxEventLogger
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<std::string> events {};
|
||||
std::vector<std::string> events {}; // NOLINT(readability-redundant-member-init)
|
||||
bool errored = false;
|
||||
};
|
||||
|
||||
|
@ -55,7 +55,7 @@ struct alt_string_iter
|
||||
return *this;
|
||||
}
|
||||
|
||||
std::string impl{};
|
||||
std::string impl{}; // NOLINT(readability-redundant-member-init)
|
||||
};
|
||||
|
||||
struct alt_string_data
|
||||
@ -91,7 +91,7 @@ struct alt_string_data
|
||||
return *this;
|
||||
}
|
||||
|
||||
std::string impl{};
|
||||
std::string impl{}; // NOLINT(readability-redundant-member-init)
|
||||
};
|
||||
|
||||
void check_escaped(const char* original, const char* escaped = "", bool ensure_ascii = false);
|
||||
|
@ -125,7 +125,7 @@ struct SaxEventLogger : public nlohmann::json_sax<json>
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<std::string> events {};
|
||||
std::vector<std::string> events {}; // NOLINT(readability-redundant-member-init)
|
||||
};
|
||||
|
||||
struct SaxEventLoggerExitAfterStartObject : public SaxEventLogger
|
||||
|
@ -115,7 +115,7 @@ TEST_CASE("README" * doctest::skip())
|
||||
auto j3 = json::parse(R"({"happy": true, "pi": 3.141})");
|
||||
|
||||
// explicit conversion to string
|
||||
std::string const s = j.dump(); // {\"happy\":true,\"pi\":3.141}
|
||||
std::string const s = j.dump(); // NOLINT(bugprone-unused-local-non-trivial-variable) // {\"happy\":true,\"pi\":3.141}
|
||||
|
||||
// serialization with pretty printing
|
||||
// pass in the amount of spaces to indent
|
||||
@ -152,7 +152,7 @@ TEST_CASE("README" * doctest::skip())
|
||||
}
|
||||
|
||||
// getter/setter
|
||||
const auto tmp = j[0].get<std::string>();
|
||||
const auto tmp = j[0].get<std::string>(); // NOLINT(bugprone-unused-local-non-trivial-variable)
|
||||
j[1] = 42;
|
||||
bool foo{j.at(2)};
|
||||
CHECK(foo == true);
|
||||
@ -237,7 +237,7 @@ TEST_CASE("README" * doctest::skip())
|
||||
// strings
|
||||
std::string const s1 = "Hello, world!";
|
||||
json const js = s1;
|
||||
auto s2 = js.get<std::string>();
|
||||
auto s2 = js.get<std::string>(); // NOLINT(bugprone-unused-local-non-trivial-variable)
|
||||
|
||||
// Booleans
|
||||
bool const b1 = true;
|
||||
@ -253,7 +253,7 @@ TEST_CASE("README" * doctest::skip())
|
||||
|
||||
// etc.
|
||||
|
||||
std::string const vs = js.get<std::string>();
|
||||
std::string const vs = js.get<std::string>(); // NOLINT(bugprone-unused-local-non-trivial-variable)
|
||||
bool vb = jb.get<bool>();
|
||||
CHECK(vb == true);
|
||||
int vi = jn.get<int>();
|
||||
|
@ -90,8 +90,8 @@ struct Data
|
||||
: a(std::move(a_))
|
||||
, b(std::move(b_))
|
||||
{}
|
||||
std::string a{};
|
||||
std::string b{};
|
||||
std::string a{}; // NOLINT(readability-redundant-member-init)
|
||||
std::string b{}; // NOLINT(readability-redundant-member-init)
|
||||
};
|
||||
|
||||
void from_json(const json& j, Data& data);
|
||||
@ -218,7 +218,7 @@ class Foo
|
||||
class FooBar
|
||||
{
|
||||
public:
|
||||
Foo foo{};
|
||||
Foo foo{}; // NOLINT(readability-redundant-member-init)
|
||||
};
|
||||
|
||||
inline void from_json(const nlohmann::json& j, FooBar& fb)
|
||||
@ -240,7 +240,7 @@ struct for_3171_base // NOLINT(cppcoreguidelines-special-member-functions)
|
||||
j.at("str").get_to(str);
|
||||
}
|
||||
|
||||
std::string str{};
|
||||
std::string str{}; // NOLINT(readability-redundant-member-init)
|
||||
};
|
||||
|
||||
struct for_3171_derived : public for_3171_base
|
||||
@ -622,8 +622,8 @@ TEST_CASE("regression tests 2")
|
||||
// see https://github.com/nlohmann/json/pull/2181#issuecomment-653326060
|
||||
const json j{{"x", "test"}};
|
||||
const std::string defval = "default value";
|
||||
auto val = j.value("x", defval);
|
||||
auto val2 = j.value("y", defval);
|
||||
auto val = j.value("x", defval); // NOLINT(bugprone-unused-local-non-trivial-variable)
|
||||
auto val2 = j.value("y", defval); // NOLINT(bugprone-unused-local-non-trivial-variable)
|
||||
}
|
||||
|
||||
SECTION("issue #2293 - eof doesn't cause parsing to stop")
|
||||
|
@ -52,17 +52,17 @@ struct address
|
||||
|
||||
struct person
|
||||
{
|
||||
age m_age{};
|
||||
name m_name{};
|
||||
country m_country{};
|
||||
age m_age{}; // NOLINT(readability-redundant-member-init)
|
||||
name m_name{}; // NOLINT(readability-redundant-member-init)
|
||||
country m_country{}; // NOLINT(readability-redundant-member-init)
|
||||
person() = default;
|
||||
person(const age& a, name n, const country& c) : m_age(a), m_name(std::move(n)), m_country(c) {}
|
||||
};
|
||||
|
||||
struct contact
|
||||
{
|
||||
person m_person{};
|
||||
address m_address{};
|
||||
person m_person{}; // NOLINT(readability-redundant-member-init)
|
||||
address m_address{}; // NOLINT(readability-redundant-member-init)
|
||||
contact() = default;
|
||||
contact(person p, address a) : m_person(std::move(p)), m_address(std::move(a)) {}
|
||||
};
|
||||
@ -71,9 +71,9 @@ enum class book_id : std::uint64_t;
|
||||
|
||||
struct contact_book
|
||||
{
|
||||
name m_book_name{};
|
||||
name m_book_name{}; // NOLINT(readability-redundant-member-init)
|
||||
book_id m_book_id{};
|
||||
std::vector<contact> m_contacts{};
|
||||
std::vector<contact> m_contacts{}; // NOLINT(readability-redundant-member-init)
|
||||
contact_book() = default;
|
||||
contact_book(name n, book_id i, std::vector<contact> c) : m_book_name(std::move(n)), m_book_id(i), m_contacts(std::move(c)) {}
|
||||
};
|
||||
@ -343,7 +343,7 @@ namespace udt
|
||||
{
|
||||
struct legacy_type
|
||||
{
|
||||
std::string number{};
|
||||
std::string number{}; // NOLINT(readability-redundant-member-init)
|
||||
legacy_type() = default;
|
||||
legacy_type(std::string n) : number(std::move(n)) {}
|
||||
};
|
||||
@ -616,7 +616,7 @@ struct small_pod
|
||||
|
||||
struct non_pod
|
||||
{
|
||||
std::string s{};
|
||||
std::string s{}; // NOLINT(readability-redundant-member-init)
|
||||
non_pod() = default;
|
||||
non_pod(std::string S) : s(std::move(S)) {}
|
||||
};
|
||||
|
@ -18,7 +18,7 @@ namespace persons
|
||||
class person_with_private_data
|
||||
{
|
||||
private:
|
||||
std::string name{};
|
||||
std::string name{}; // NOLINT(readability-redundant-member-init)
|
||||
int age = 0;
|
||||
json metadata = nullptr;
|
||||
|
||||
@ -41,7 +41,7 @@ class person_with_private_data
|
||||
class person_with_private_data_2
|
||||
{
|
||||
private:
|
||||
std::string name{};
|
||||
std::string name{}; // NOLINT(readability-redundant-member-init)
|
||||
int age = 0;
|
||||
json metadata = nullptr;
|
||||
|
||||
@ -77,7 +77,7 @@ class person_with_private_data_2
|
||||
class person_without_private_data_1
|
||||
{
|
||||
public:
|
||||
std::string name{};
|
||||
std::string name{}; // NOLINT(readability-redundant-member-init)
|
||||
int age = 0;
|
||||
json metadata = nullptr;
|
||||
|
||||
@ -99,7 +99,7 @@ class person_without_private_data_1
|
||||
class person_without_private_data_2
|
||||
{
|
||||
public:
|
||||
std::string name{};
|
||||
std::string name{}; // NOLINT(readability-redundant-member-init)
|
||||
int age = 0;
|
||||
json metadata = nullptr;
|
||||
|
||||
@ -121,7 +121,7 @@ NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(person_without_private_data_2, age, name, met
|
||||
class person_without_private_data_3
|
||||
{
|
||||
public:
|
||||
std::string name{};
|
||||
std::string name{}; // NOLINT(readability-redundant-member-init)
|
||||
int age = 0;
|
||||
json metadata = nullptr;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user