🚨 fix Clang-Tidy warnings

This commit is contained in:
Niels Lohmann 2022-09-06 22:08:51 +02:00
parent eb27d70518
commit 1fb18d6e10
No known key found for this signature in database
GPG Key ID: 7F3CEA63AE251B69
5 changed files with 22 additions and 22 deletions

View File

@ -661,18 +661,18 @@ class binary_writer
}
else if (N <= (std::numeric_limits<std::uint16_t>::max)())
{
std::uint8_t output_type = use_ext
? 0xC8 // ext 16
: 0xC5; // bin 16
const std::uint8_t output_type = use_ext
? 0xC8 // ext 16
: 0xC5; // bin 16
oa->write_character(to_char_type(output_type));
write_number(static_cast<std::uint16_t>(N));
}
else if (N <= (std::numeric_limits<std::uint32_t>::max)())
{
std::uint8_t output_type = use_ext
? 0xC9 // ext 32
: 0xC6; // bin 32
const std::uint8_t output_type = use_ext
? 0xC9 // ext 32
: 0xC6; // bin 32
oa->write_character(to_char_type(output_type));
write_number(static_cast<std::uint32_t>(N));
@ -1258,8 +1258,8 @@ class binary_writer
*/
static std::size_t calc_bson_object_size(const typename BasicJsonType::object_t& value)
{
std::size_t document_size = std::accumulate(value.begin(), value.end(), static_cast<std::size_t>(0),
[](size_t result, const typename BasicJsonType::object_t::value_type & el)
const std::size_t document_size = std::accumulate(value.begin(), value.end(), static_cast<std::size_t>(0),
[](size_t result, const typename BasicJsonType::object_t::value_type & el)
{
return result += calc_bson_element_size(el.first, el.second);
});

View File

@ -15614,18 +15614,18 @@ class binary_writer
}
else if (N <= (std::numeric_limits<std::uint16_t>::max)())
{
std::uint8_t output_type = use_ext
? 0xC8 // ext 16
: 0xC5; // bin 16
const std::uint8_t output_type = use_ext
? 0xC8 // ext 16
: 0xC5; // bin 16
oa->write_character(to_char_type(output_type));
write_number(static_cast<std::uint16_t>(N));
}
else if (N <= (std::numeric_limits<std::uint32_t>::max)())
{
std::uint8_t output_type = use_ext
? 0xC9 // ext 32
: 0xC6; // bin 32
const std::uint8_t output_type = use_ext
? 0xC9 // ext 32
: 0xC6; // bin 32
oa->write_character(to_char_type(output_type));
write_number(static_cast<std::uint32_t>(N));
@ -16211,8 +16211,8 @@ class binary_writer
*/
static std::size_t calc_bson_object_size(const typename BasicJsonType::object_t& value)
{
std::size_t document_size = std::accumulate(value.begin(), value.end(), static_cast<std::size_t>(0),
[](size_t result, const typename BasicJsonType::object_t::value_type & el)
const std::size_t document_size = std::accumulate(value.begin(), value.end(), static_cast<std::size_t>(0),
[](size_t result, const typename BasicJsonType::object_t::value_type & el)
{
return result += calc_bson_element_size(el.first, el.second);
});

View File

@ -18,7 +18,7 @@ namespace utils
inline bool check_testsuite_downloaded()
{
std::unique_ptr<std::FILE, decltype(&std::fclose)> file(std::fopen(TEST_DATA_DIRECTORY "/README.md", "r"), &std::fclose);
const std::unique_ptr<std::FILE, decltype(&std::fclose)> file(std::fopen(TEST_DATA_DIRECTORY "/README.md", "r"), &std::fclose);
return file != nullptr;
}

View File

@ -32,7 +32,7 @@ TEST_CASE("JSON_ASSERT(x)")
assert_counter = 0;
CHECK(assert_counter == 0);
json::iterator it;
const json::iterator it;
json j;
// in case assertions do not abort execution, an exception is thrown

View File

@ -19,7 +19,7 @@ TEST_CASE("Binary Formats" * doctest::skip())
SECTION("canada.json")
{
const auto* filename = TEST_DATA_DIRECTORY "/nativejson-benchmark/canada.json";
json j = json::parse(std::ifstream(filename));
const json j = json::parse(std::ifstream(filename));
const auto json_size = j.dump().size();
const auto bjdata_1_size = json::to_bjdata(j).size();
@ -58,7 +58,7 @@ TEST_CASE("Binary Formats" * doctest::skip())
SECTION("twitter.json")
{
const auto* filename = TEST_DATA_DIRECTORY "/nativejson-benchmark/twitter.json";
json j = json::parse(std::ifstream(filename));
const json j = json::parse(std::ifstream(filename));
const auto json_size = j.dump().size();
const auto bjdata_1_size = json::to_bjdata(j).size();
@ -97,7 +97,7 @@ TEST_CASE("Binary Formats" * doctest::skip())
SECTION("citm_catalog.json")
{
const auto* filename = TEST_DATA_DIRECTORY "/nativejson-benchmark/citm_catalog.json";
json j = json::parse(std::ifstream(filename));
const json j = json::parse(std::ifstream(filename));
const auto json_size = j.dump().size();
const auto bjdata_1_size = json::to_bjdata(j).size();
@ -175,7 +175,7 @@ TEST_CASE("Binary Formats" * doctest::skip())
SECTION("sample.json")
{
const auto* filename = TEST_DATA_DIRECTORY "/json_testsuite/sample.json";
json j = json::parse(std::ifstream(filename));
const json j = json::parse(std::ifstream(filename));
const auto json_size = j.dump().size();
const auto bjdata_1_size = json::to_bjdata(j).size();