Repository navigation
Some clang-tidy fixes - #72869
Some clang-tidy fixes#72869
Conversation
|
This is an automated comment for commit e8018fb with description of existing statuses. It's updated for the latest CI running ❌ Click here to open a full report in a separate page
Successful checks
|
ec1b018 to
9133f43
Compare
| /// NOLINTBEGIN(modernize-macro-to-enum) | ||
| #define DATE_SECONDS_PER_DAY 86400 /// Number of seconds in a day, 60 * 60 * 24 | ||
|
|
||
| #define DATE_LUT_MIN_YEAR 1900 /// 1900 since majority of financial organizations consider 1900 as an initial year. |
There was a problem hiding this comment.
Out of curiosity, what's the issue with changing these to constexpr as well?
There was a problem hiding this comment.
In this case (and it is an exception in the codebase), it was mere laziness from my side. These constants are used in many places and one needs to find an appropriate data type. I'd be good with keeping it for now like this or fixing it in a follow-up (the PR is already quite big).
| /// NOLINTBEGIN(modernize-macro-to-enum) | ||
| #define MYSQLXX_DEFAULT_TIMEOUT 60 | ||
| #define MYSQLXX_DEFAULT_RW_TIMEOUT 1800 | ||
|
|
||
| /// Disable LOAD DATA LOCAL INFILE because it is insecure | ||
| #define MYSQLXX_DEFAULT_ENABLE_LOCAL_INFILE false | ||
| /// See https://dev.mysql.com/doc/c-api/5.7/en/c-api-auto-reconnect.html | ||
| /// NOLINTEND(modernize-macro-to-enum) |
There was a problem hiding this comment.
Out of curiosity, what's the issue with changing these to constexpr as well here and in other mysqlxx files?
There was a problem hiding this comment.
The MySQL stuff looks like copypasta of external code. We better don't mess with the code too much to make future upgrades easier.
| #pragma GCC diagnostic ignored "-Wmissing-field-initializers" | ||
| #pragma GCC diagnostic ignored "-Wshorten-64-to-32" | ||
| // NOLINTBEGIN(google-runtime-int,hicpp-use-nullptr,modernize-use-nullptr) | ||
| // NOLINTBEGIN(google-runtime-int,hicpp-use-nullptr,modernize-use-nullptr,modernize-macro-to-enum) |
There was a problem hiding this comment.
I guess, we should add this to HTMLCharacterReference.gperf and regenerate, otherwise it would be overwritten after the next regeneration
There was a problem hiding this comment.
Agree. But could I do this in the follow-up PR that also fixes DateLUTImpl.h?
| /// NOLINTBEGIN(modernize-macro-to-enum) | ||
|
|
There was a problem hiding this comment.
I guess, we should add this to tldLookup.gperf and regenerate, otherwise it would be overwritten after the next regeneration
Minor follow-up to #72869
This PR enables a few clang-tidy checks, most notably:
modernize-macro-to-enumprohibits defining magic constants as macros (#define X 123): this increases type safety by a little bitreadability-isolate-declaration: which forces one declaration per line, e.g.int x, y = 0is now disallowed (<-- and this example also shows the motivation for the check). All changed places in the code were okay, so the check effectively only makes the code a bit more "regular".modernize-use-constraints: which suggests C++20 concepts instead ofstd::enable_if. Don't know why exactly but the check did not complain about the (few)enable_ifs in the codebase. It makes sense to have the check enabled regardless.misc-confusable-identifiers: Complained only once about a template parameterIn(which can be confused withln, lol). Like before, it generally makes sense to have this check enabled.operator=(one of thecert-*checks, don't remember which exactly). That's a potential performance issue (at least on a micro-benchmark level). Found a few places.Besides that, I enabled a few checks
clang-analyzer-cplusplus.PlacementNew',clang-analyzer-unix.Malloc,linuxkernel-*,openmp-*not because they are particularly useful or even apply to our codebase (Linux, OpenMP) but because they didn't find anything and for reducing the number of disabled checks in .clang-tidy.Changelog category (leave one):