Skip to content

Commit

Permalink
Enable modernize-use-integer-sign-comparison check (#4581)
Browse files Browse the repository at this point in the history
Signed-off-by: Niels Lohmann <[email protected]>
  • Loading branch information
nlohmann authored Jan 2, 2025
1 parent 4f64d8d commit f038ac4
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 10 deletions.
1 change: 0 additions & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ Checks: '*,
-modernize-type-traits,
-modernize-use-constraints,
-modernize-use-designated-initializers,
-modernize-use-integer-sign-comparison,
-modernize-use-nodiscard,
-modernize-use-ranges,
-modernize-use-std-numbers,
Expand Down
2 changes: 1 addition & 1 deletion tests/src/unit-alt-string.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class alt_string
public:
using value_type = std::string::value_type;

static constexpr auto npos = static_cast<std::size_t>(-1);
static constexpr auto npos = (std::numeric_limits<std::size_t>::max)();

alt_string(const char* str): str_impl(str) {}
alt_string(const char* str, std::size_t count): str_impl(str, count) {}
Expand Down
4 changes: 2 additions & 2 deletions tests/src/unit-class_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class SaxEventLogger

bool start_object(std::size_t elements)
{
if (elements == static_cast<std::size_t>(-1))
if (elements == (std::numeric_limits<std::size_t>::max)())
{
events.emplace_back("start_object()");
}
Expand All @@ -100,7 +100,7 @@ class SaxEventLogger

bool start_array(std::size_t elements)
{
if (elements == static_cast<std::size_t>(-1))
if (elements == (std::numeric_limits<std::size_t>::max)())
{
events.emplace_back("start_array()");
}
Expand Down
4 changes: 2 additions & 2 deletions tests/src/unit-class_parser_diagnostic_positions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class SaxEventLogger

bool start_object(std::size_t elements)
{
if (elements == static_cast<std::size_t>(-1))
if (elements == (std::numeric_limits<std::size_t>::max)())
{
events.emplace_back("start_object()");
}
Expand All @@ -105,7 +105,7 @@ class SaxEventLogger

bool start_array(std::size_t elements)
{
if (elements == static_cast<std::size_t>(-1))
if (elements == (std::numeric_limits<std::size_t>::max)())
{
events.emplace_back("start_array()");
}
Expand Down
8 changes: 4 additions & 4 deletions tests/src/unit-deserialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ struct SaxEventLogger : public nlohmann::json_sax<json>

bool start_object(std::size_t elements) override
{
if (elements == static_cast<std::size_t>(-1))
if (elements == (std::numeric_limits<std::size_t>::max)())
{
events.emplace_back("start_object()");
}
Expand All @@ -101,7 +101,7 @@ struct SaxEventLogger : public nlohmann::json_sax<json>

bool start_array(std::size_t elements) override
{
if (elements == static_cast<std::size_t>(-1))
if (elements == (std::numeric_limits<std::size_t>::max)())
{
events.emplace_back("start_array()");
}
Expand Down Expand Up @@ -131,7 +131,7 @@ struct SaxEventLoggerExitAfterStartObject : public SaxEventLogger
{
bool start_object(std::size_t elements) override
{
if (elements == static_cast<std::size_t>(-1))
if (elements == (std::numeric_limits<std::size_t>::max)())
{
events.emplace_back("start_object()");
}
Expand All @@ -156,7 +156,7 @@ struct SaxEventLoggerExitAfterStartArray : public SaxEventLogger
{
bool start_array(std::size_t elements) override
{
if (elements == static_cast<std::size_t>(-1))
if (elements == (std::numeric_limits<std::size_t>::max)())
{
events.emplace_back("start_array()");
}
Expand Down

0 comments on commit f038ac4

Please sign in to comment.