🚨 fix warnings
This commit is contained in:
parent
0dcb01bc47
commit
bfd4c7c739
@ -5,6 +5,7 @@ Checks: '*,
|
||||
-cppcoreguidelines-avoid-non-const-global-variables,
|
||||
-cppcoreguidelines-macro-usage,
|
||||
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
|
||||
-cppcoreguidelines-pro-bounds-pointer-arithmetic,
|
||||
-cppcoreguidelines-pro-type-reinterpret-cast,
|
||||
-cppcoreguidelines-pro-type-union-access,
|
||||
-fuchsia-default-arguments-calls,
|
||||
|
||||
@ -618,7 +618,7 @@ inline void grisu2_digit_gen(char* buffer, int& length, int& decimal_exponent,
|
||||
|
||||
JSON_ASSERT(p1 > 0);
|
||||
|
||||
std::uint32_t pow10;
|
||||
std::uint32_t pow10{};
|
||||
const int k = find_largest_pow10(p1, pow10);
|
||||
|
||||
// 10^(k-1) <= p1 < 10^k, pow10 = 10^(k-1)
|
||||
|
||||
@ -180,7 +180,7 @@ class json_pointer
|
||||
|
||||
@since version 3.6.0
|
||||
*/
|
||||
friend json_pointer operator/(const json_pointer& ptr, std::string token)
|
||||
friend json_pointer operator/(const json_pointer& ptr, std::string token) // NOLINT(performance-unnecessary-value-param)
|
||||
{
|
||||
return json_pointer(ptr) /= std::move(token);
|
||||
}
|
||||
|
||||
@ -700,7 +700,7 @@ class serializer
|
||||
}
|
||||
|
||||
// use a pointer to fill the buffer
|
||||
auto* buffer_ptr = number_buffer.begin();
|
||||
auto buffer_ptr = number_buffer.begin();
|
||||
|
||||
const bool is_negative = std::is_same<NumberType, number_integer_t>::value && !(x >= 0); // see issue #755
|
||||
number_unsigned_t abs_value;
|
||||
|
||||
@ -2821,7 +2821,7 @@ class basic_json
|
||||
static ReferenceType get_ref_impl(ThisType& obj)
|
||||
{
|
||||
// delegate the call to get_ptr<>()
|
||||
auto ptr = obj.template get_ptr<typename std::add_pointer<ReferenceType>::type>();
|
||||
auto* ptr = obj.template get_ptr<typename std::add_pointer<ReferenceType>::type>();
|
||||
|
||||
if (JSON_HEDLEY_LIKELY(ptr != nullptr))
|
||||
{
|
||||
|
||||
@ -11834,7 +11834,7 @@ class json_pointer
|
||||
|
||||
@since version 3.6.0
|
||||
*/
|
||||
friend json_pointer operator/(const json_pointer& ptr, std::string token)
|
||||
friend json_pointer operator/(const json_pointer& ptr, std::string token) // NOLINT(performance-unnecessary-value-param)
|
||||
{
|
||||
return json_pointer(ptr) /= std::move(token);
|
||||
}
|
||||
@ -15071,7 +15071,7 @@ inline void grisu2_digit_gen(char* buffer, int& length, int& decimal_exponent,
|
||||
|
||||
JSON_ASSERT(p1 > 0);
|
||||
|
||||
std::uint32_t pow10;
|
||||
std::uint32_t pow10{};
|
||||
const int k = find_largest_pow10(p1, pow10);
|
||||
|
||||
// 10^(k-1) <= p1 < 10^k, pow10 = 10^(k-1)
|
||||
@ -16248,7 +16248,7 @@ class serializer
|
||||
}
|
||||
|
||||
// use a pointer to fill the buffer
|
||||
auto* buffer_ptr = number_buffer.begin();
|
||||
auto buffer_ptr = number_buffer.begin();
|
||||
|
||||
const bool is_negative = std::is_same<NumberType, number_integer_t>::value && !(x >= 0); // see issue #755
|
||||
number_unsigned_t abs_value;
|
||||
@ -19442,7 +19442,7 @@ class basic_json
|
||||
static ReferenceType get_ref_impl(ThisType& obj)
|
||||
{
|
||||
// delegate the call to get_ptr<>()
|
||||
auto ptr = obj.template get_ptr<typename std::add_pointer<ReferenceType>::type>();
|
||||
auto* ptr = obj.template get_ptr<typename std::add_pointer<ReferenceType>::type>();
|
||||
|
||||
if (JSON_HEDLEY_LIKELY(ptr != nullptr))
|
||||
{
|
||||
|
||||
@ -738,7 +738,7 @@ class SaxCountdown
|
||||
return events_left-- > 0;
|
||||
}
|
||||
|
||||
bool parse_error(std::size_t /*unused*/, const std::string& /*unused*/, const json::exception& /*unused*/)
|
||||
bool parse_error(std::size_t /*unused*/, const std::string& /*unused*/, const json::exception& /*unused*/) // NOLINT(readability-convert-member-functions-to-static)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -109,7 +109,7 @@ class SaxCountdown
|
||||
return events_left-- > 0;
|
||||
}
|
||||
|
||||
bool parse_error(std::size_t /*unused*/, const std::string& /*unused*/, const json::exception& /*unused*/)
|
||||
bool parse_error(std::size_t /*unused*/, const std::string& /*unused*/, const json::exception& /*unused*/) // NOLINT(readability-convert-member-functions-to-static)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1691,7 +1691,7 @@ TEST_CASE("parser class")
|
||||
|
||||
SECTION("from array")
|
||||
{
|
||||
uint8_t v[] = {'t', 'r', 'u', 'e'};
|
||||
uint8_t v[] = {'t', 'r', 'u', 'e'}; // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
|
||||
json j;
|
||||
json::parser(nlohmann::detail::input_adapter(std::begin(v), std::end(v))).parse(true, j);
|
||||
CHECK(j == json(true));
|
||||
|
||||
@ -436,7 +436,7 @@ TEST_CASE("constructors")
|
||||
|
||||
SECTION("char[]")
|
||||
{
|
||||
char s[] {"Hello world"};
|
||||
char s[] {"Hello world"}; // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
|
||||
json j(s);
|
||||
CHECK(j.type() == json::value_t::string);
|
||||
CHECK(j == j_reference);
|
||||
@ -1115,24 +1115,29 @@ TEST_CASE("constructors")
|
||||
{
|
||||
SECTION("string")
|
||||
{
|
||||
// This should break through any short string optimization in std::string
|
||||
std::string source(1024, '!');
|
||||
const char* source_addr = source.data();
|
||||
|
||||
SECTION("constructor with implicit types (array)")
|
||||
{
|
||||
// This should break through any short string optimization in std::string
|
||||
std::string source(1024, '!');
|
||||
const char* source_addr = source.data();
|
||||
json j = {std::move(source)};
|
||||
CHECK(j[0].get_ref<std::string const&>().data() == source_addr);
|
||||
}
|
||||
|
||||
SECTION("constructor with implicit types (object)")
|
||||
{
|
||||
// This should break through any short string optimization in std::string
|
||||
std::string source(1024, '!');
|
||||
const char* source_addr = source.data();
|
||||
json j = {{"key", std::move(source)}};
|
||||
CHECK(j["key"].get_ref<std::string const&>().data() == source_addr);
|
||||
}
|
||||
|
||||
SECTION("constructor with implicit types (object key)")
|
||||
{
|
||||
// This should break through any short string optimization in std::string
|
||||
std::string source(1024, '!');
|
||||
const char* source_addr = source.data();
|
||||
json j = {{std::move(source), 42}};
|
||||
CHECK(j.get_ref<json::object_t&>().begin()->first.data() == source_addr);
|
||||
}
|
||||
@ -1140,29 +1145,34 @@ TEST_CASE("constructors")
|
||||
|
||||
SECTION("array")
|
||||
{
|
||||
json::array_t source = {1, 2, 3};
|
||||
const json* source_addr = source.data();
|
||||
|
||||
SECTION("constructor with implicit types (array)")
|
||||
{
|
||||
json::array_t source = {1, 2, 3};
|
||||
const json* source_addr = source.data();
|
||||
json j {std::move(source)};
|
||||
CHECK(j[0].get_ref<json::array_t const&>().data() == source_addr);
|
||||
}
|
||||
|
||||
SECTION("constructor with implicit types (object)")
|
||||
{
|
||||
json::array_t source = {1, 2, 3};
|
||||
const json* source_addr = source.data();
|
||||
json j {{"key", std::move(source)}};
|
||||
CHECK(j["key"].get_ref<json::array_t const&>().data() == source_addr);
|
||||
}
|
||||
|
||||
SECTION("assignment with implicit types (array)")
|
||||
{
|
||||
json::array_t source = {1, 2, 3};
|
||||
const json* source_addr = source.data();
|
||||
json j = {std::move(source)};
|
||||
CHECK(j[0].get_ref<json::array_t const&>().data() == source_addr);
|
||||
}
|
||||
|
||||
SECTION("assignment with implicit types (object)")
|
||||
{
|
||||
json::array_t source = {1, 2, 3};
|
||||
const json* source_addr = source.data();
|
||||
json j = {{"key", std::move(source)}};
|
||||
CHECK(j["key"].get_ref<json::array_t const&>().data() == source_addr);
|
||||
}
|
||||
@ -1170,29 +1180,34 @@ TEST_CASE("constructors")
|
||||
|
||||
SECTION("object")
|
||||
{
|
||||
json::object_t source = {{"hello", "world"}};
|
||||
const json* source_addr = &source.at("hello");
|
||||
|
||||
SECTION("constructor with implicit types (array)")
|
||||
{
|
||||
json::object_t source = {{"hello", "world"}};
|
||||
const json* source_addr = &source.at("hello");
|
||||
json j {std::move(source)};
|
||||
CHECK(&(j[0].get_ref<json::object_t const&>().at("hello")) == source_addr);
|
||||
}
|
||||
|
||||
SECTION("constructor with implicit types (object)")
|
||||
{
|
||||
json::object_t source = {{"hello", "world"}};
|
||||
const json* source_addr = &source.at("hello");
|
||||
json j {{"key", std::move(source)}};
|
||||
CHECK(&(j["key"].get_ref<json::object_t const&>().at("hello")) == source_addr);
|
||||
}
|
||||
|
||||
SECTION("assignment with implicit types (array)")
|
||||
{
|
||||
json::object_t source = {{"hello", "world"}};
|
||||
const json* source_addr = &source.at("hello");
|
||||
json j = {std::move(source)};
|
||||
CHECK(&(j[0].get_ref<json::object_t const&>().at("hello")) == source_addr);
|
||||
}
|
||||
|
||||
SECTION("assignment with implicit types (object)")
|
||||
{
|
||||
json::object_t source = {{"hello", "world"}};
|
||||
const json* source_addr = &source.at("hello");
|
||||
json j = {{"key", std::move(source)}};
|
||||
CHECK(&(j["key"].get_ref<json::object_t const&>().at("hello")) == source_addr);
|
||||
}
|
||||
@ -1200,29 +1215,34 @@ TEST_CASE("constructors")
|
||||
|
||||
SECTION("json")
|
||||
{
|
||||
json source {1, 2, 3};
|
||||
const json* source_addr = &source[0];
|
||||
|
||||
SECTION("constructor with implicit types (array)")
|
||||
{
|
||||
json source {1, 2, 3};
|
||||
const json* source_addr = &source[0];
|
||||
json j {std::move(source), {}};
|
||||
CHECK(&j[0][0] == source_addr);
|
||||
}
|
||||
|
||||
SECTION("constructor with implicit types (object)")
|
||||
{
|
||||
json source {1, 2, 3};
|
||||
const json* source_addr = &source[0];
|
||||
json j {{"key", std::move(source)}};
|
||||
CHECK(&j["key"][0] == source_addr);
|
||||
}
|
||||
|
||||
SECTION("assignment with implicit types (array)")
|
||||
{
|
||||
json source {1, 2, 3};
|
||||
const json* source_addr = &source[0];
|
||||
json j = {std::move(source), {}};
|
||||
CHECK(&j[0][0] == source_addr);
|
||||
}
|
||||
|
||||
SECTION("assignment with implicit types (object)")
|
||||
{
|
||||
json source {1, 2, 3};
|
||||
const json* source_addr = &source[0];
|
||||
json j = {{"key", std::move(source)}};
|
||||
CHECK(&j["key"][0] == source_addr);
|
||||
}
|
||||
|
||||
@ -282,8 +282,8 @@ TEST_CASE("value conversion")
|
||||
|
||||
SECTION("built-in arrays")
|
||||
{
|
||||
const char str[] = "a string";
|
||||
const int nbs[] = {0, 1, 2};
|
||||
const char str[] = "a string"; // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
|
||||
const int nbs[] = {0, 1, 2}; // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
|
||||
|
||||
json j2 = nbs;
|
||||
json j3 = str;
|
||||
@ -387,8 +387,8 @@ TEST_CASE("value conversion")
|
||||
|
||||
SECTION("built-in arrays")
|
||||
{
|
||||
const int nbs[] = {0, 1, 2};
|
||||
int nbs2[] = {0, 0, 0};
|
||||
const int nbs[] = {0, 1, 2}; // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
|
||||
int nbs2[] = {0, 0, 0}; // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
|
||||
|
||||
json j2 = nbs;
|
||||
j2.get_to(nbs2);
|
||||
|
||||
@ -107,7 +107,7 @@ class SaxCountdown
|
||||
return events_left-- > 0;
|
||||
}
|
||||
|
||||
bool parse_error(std::size_t /*unused*/, const std::string& /*unused*/, const json::exception& /*unused*/)
|
||||
bool parse_error(std::size_t /*unused*/, const std::string& /*unused*/, const json::exception& /*unused*/) // NOLINT(readability-convert-member-functions-to-static)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -318,7 +318,7 @@ TEST_CASE("regression tests 2")
|
||||
SECTION("test case in issue #1445")
|
||||
{
|
||||
nlohmann::json dump_test;
|
||||
const int data[] =
|
||||
const std::array<int, 108> data =
|
||||
{
|
||||
109, 108, 103, 125, -122, -53, 115,
|
||||
18, 3, 0, 102, 19, 1, 15,
|
||||
@ -395,7 +395,7 @@ TEST_CASE("regression tests 2")
|
||||
|
||||
SECTION("string array")
|
||||
{
|
||||
const char input[] = { 'B', 0x00 };
|
||||
const std::array<char, 2> input = { 'B', 0x00 };
|
||||
json cbor = json::from_cbor(input, true, false);
|
||||
CHECK(cbor.is_discarded());
|
||||
}
|
||||
|
||||
@ -217,12 +217,12 @@ TEST_CASE("digit gen")
|
||||
CAPTURE(digits)
|
||||
CAPTURE(expected_exponent)
|
||||
|
||||
char buf[32];
|
||||
std::array<char, 32> buf{};
|
||||
int len = 0;
|
||||
int exponent = 0;
|
||||
nlohmann::detail::dtoa_impl::grisu2(buf, len, exponent, number);
|
||||
nlohmann::detail::dtoa_impl::grisu2(buf.data(), len, exponent, number);
|
||||
|
||||
CHECK(digits == std::string(buf, buf + len));
|
||||
CHECK(digits == std::string(buf.data(), buf.data() + len));
|
||||
CHECK(expected_exponent == exponent);
|
||||
};
|
||||
|
||||
|
||||
@ -106,7 +106,7 @@ class SaxCountdown
|
||||
return events_left-- > 0;
|
||||
}
|
||||
|
||||
bool parse_error(std::size_t /*unused*/, const std::string& /*unused*/, const json::exception& /*unused*/)
|
||||
bool parse_error(std::size_t /*unused*/, const std::string& /*unused*/, const json::exception& /*unused*/) // NOLINT(readability-convert-member-functions-to-static)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user