diff --git a/.clang-tidy b/.clang-tidy index cf9b74e1..0646e861 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -105,6 +105,10 @@ CheckOptions: value: 'NULL' - key: performance-unnecessary-value-param.AllowedTypes value: 'absl::Status;absl::StatusOr;std::string_view' + - key: readability-implicit-bool-conversion.AllowIntegerConditions + value: '1' + - key: readability-implicit-bool-conversion.AllowPointerConditions + value: '1' - key: readability-function-cognitive-complexity.Threshold value: '25' - key: readability-braces-around-statements.ShortStatementLines diff --git a/mbo/container/any_scan.h b/mbo/container/any_scan.h index 036da653..8f2b12b9 100644 --- a/mbo/container/any_scan.h +++ b/mbo/container/any_scan.h @@ -353,7 +353,7 @@ class AnyScanImpl { // For MakAnyScan / MakeConstScan template requires(kAccessByRef) - explicit AnyScanImpl(MakeAnyScanData data) + explicit AnyScanImpl(const MakeAnyScanData& data) : funcs_{ .iter = [data = data] { @@ -374,7 +374,7 @@ class AnyScanImpl { !kAccessByRef // This is the ConvertingScan constructor && types::ConstructibleFrom> && types::ConstructibleFrom) - explicit AnyScanImpl(MakeAnyScanData data) + explicit AnyScanImpl(const MakeAnyScanData& data) : funcs_{ // NOTE: data must be copied here! .iter = diff --git a/mbo/hash/hash_differential_test.cc b/mbo/hash/hash_differential_test.cc index 76a8cf58..d371014c 100644 --- a/mbo/hash/hash_differential_test.cc +++ b/mbo/hash/hash_differential_test.cc @@ -31,7 +31,11 @@ namespace mbo::hash { namespace { -// NOLINTBEGIN(*-magic-numbers) +// readability-implicit-bool-conversion is suppressed rather than "fixed": inside +// the reference macros (XXH64 / XXH3_*) it misattributes a conversion to the gtest +// `<<` message chain, pointing at string literals like "len: " and proposing they +// be replaced with `true`. Nothing here converts anything to bool. +// NOLINTBEGIN(*-magic-numbers,readability-implicit-bool-conversion) TEST(DifferentialTest, Xxh64MatchesReference) { std::mt19937_64 rng(0xD1FF64U); // NOLINT(cert-msc51-cpp,cert-msc32-c,bugprone-random-generator-seed): reproducible @@ -89,7 +93,7 @@ TEST(DifferentialTest, Xxh3Hash128MatchesReference) { } } -// NOLINTEND(*-magic-numbers) +// NOLINTEND(*-magic-numbers,readability-implicit-bool-conversion) } // namespace } // namespace mbo::hash diff --git a/mbo/strings/numbers.h b/mbo/strings/numbers.h index f36588e9..346477bc 100644 --- a/mbo/strings/numbers.h +++ b/mbo/strings/numbers.h @@ -51,7 +51,7 @@ unsigned BigNumberLen(T v) { // We first check whether we can do even better by limiting us to 4 byte types. // We use a macro to let the compiler compute the actual length values. if constexpr (sizeof(v) <= 4) { -#define CHECK_CAP(cap) std::make_pair(cap, std::string_view(#cap).size() - 3) +#define CHECK_CAP(cap) std::pair(cap, std::string_view(#cap).size() - 3) constexpr auto kData = mbo::container::ToLimitedMap>({ CHECK_CAP(4'294'967'295ULL), CHECK_CAP(999'999'999ULL), @@ -68,7 +68,7 @@ unsigned BigNumberLen(T v) { #undef CHECK_CAP return kData.lower_bound(v)->second; } else { -#define CHECK_CAP(cap) std::make_pair(cap, std::string_view(#cap).size() - 3) +#define CHECK_CAP(cap) std::pair(cap, std::string_view(#cap).size() - 3) constexpr auto kData = mbo::container::ToLimitedMap>({ CHECK_CAP(18'446'744'073'709'551'615ULL), CHECK_CAP(9'999'999'999'999'999'999ULL),