fix clang tidy warnings and add nolint for certain occaisons

This commit is contained in:
Kunal Tyagi 2022-06-26 11:37:23 +09:00
parent 47c3eb785e
commit 5f822d863f

View File

@ -37,7 +37,9 @@ using nlohmann::json;
namespace persons namespace persons
{ {
#define PERSON_CLASS_BODY(ClassName, Visibility) \ #define PERSON_CLASS_BODY(ClassName, Visibility) \
/* NOLINTNEXTLINE(bugprone-macro-parentheses) */ \
Visibility: \ Visibility: \
/* NOLINTNEXTLINE(readability-redundant-string-init): collides with -Weffc++ */ \
std::string name = ""; \ std::string name = ""; \
int age = 0; \ int age = 0; \
json metadata = nullptr; \ json metadata = nullptr; \
@ -96,6 +98,7 @@ namespace persons
y == other.y && \ y == other.y && \
z == other.z; \ z == other.z; \
} \ } \
/* NOLINTNEXTLINE(bugprone-macro-parentheses) */ \
Visibility: \ Visibility: \
int a = 0; \ int a = 0; \
int b = 0; \ int b = 0; \
@ -242,11 +245,11 @@ TEST_CASE_TEMPLATE("Serialization/deserialization via NLOHMANN_DEFINE_TYPE_INTRU
std::string json_string; std::string json_string;
if (std::is_same<json_t, nlohmann::ordered_json>::value) if (std::is_same<json_t, nlohmann::ordered_json>::value)
{ {
json_string = "{\"age\":1,\"name\":\"Erik\",\"metadata\":{\"haircuts\":2}}"; json_string = R"str({"age":1,"name":"Erik","metadata":{"haircuts":2}})str";
} }
else else
{ {
json_string = "{\"age\":1,\"metadata\":{\"haircuts\":2},\"name\":\"Erik\"}"; json_string = R"str({"age":1,"metadata":{"haircuts":2},"name":"Erik"})str";
} }
CHECK(json_t(p1).dump() == json_string); CHECK(json_t(p1).dump() == json_string);
@ -286,11 +289,11 @@ TEST_CASE_TEMPLATE("Serialization/deserialization via NLOHMANN_DEFINE_TYPE_INTRU
std::string json_string; std::string json_string;
if (std::is_same<json_t, nlohmann::ordered_json>::value) if (std::is_same<json_t, nlohmann::ordered_json>::value)
{ {
json_string = "{\"age\":0,\"name\":\"\",\"metadata\":null}"; json_string = R"str({"age":0,"name":"","metadata":null})str";
} }
else else
{ {
json_string = "{\"age\":0,\"metadata\":null,\"name\":\"\"}"; json_string = R"str({"age":0,"metadata":null,"name":""})str";
} }
CHECK(json_t(p0).dump() == json_string); CHECK(json_t(p0).dump() == json_string);
@ -298,11 +301,11 @@ TEST_CASE_TEMPLATE("Serialization/deserialization via NLOHMANN_DEFINE_TYPE_INTRU
T p1("Erik", 1, {{"haircuts", 2}}); T p1("Erik", 1, {{"haircuts", 2}});
if (std::is_same<json_t, nlohmann::ordered_json>::value) if (std::is_same<json_t, nlohmann::ordered_json>::value)
{ {
json_string = "{\"age\":1,\"name\":\"Erik\",\"metadata\":{\"haircuts\":2}}"; json_string = R"str({"age":1,"name":"Erik","metadata":{"haircuts":2}})str";
} }
else else
{ {
json_string = "{\"age\":1,\"metadata\":{\"haircuts\":2},\"name\":\"Erik\"}"; json_string = R"str({"age":1,"metadata":{"haircuts":2},"name":"Erik"})str";
} }
CHECK(json_t(p1).dump() == json_string); CHECK(json_t(p1).dump() == json_string);