From 4eba9ee41afe4da53c11b51925278da0be20ad74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Metrich?= <45318189+FredM67@users.noreply.github.com> Date: Tue, 25 Aug 2026 17:36:00 +0200 Subject: [PATCH] [core] Fix false-positive readability-non-const-parameter in string_ref.h (#18758) --- esphome/core/string_ref.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/esphome/core/string_ref.h b/esphome/core/string_ref.h index 33459f48af..2c7ec914c7 100644 --- a/esphome/core/string_ref.h +++ b/esphome/core/string_ref.h @@ -239,7 +239,9 @@ template inline R parse_number(const StringRef &str, siz } // NOLINTEND(google-runtime-int) } // namespace internal -// NOLINTBEGIN(readability-identifier-naming,google-runtime-int) +// readability-non-const-parameter: `pos` is written through by internal::parse_number, one call +// frame away; the check only inspects these bodies, so it wrongly proposes `const size_t *`. +// NOLINTBEGIN(readability-identifier-naming,google-runtime-int,readability-non-const-parameter) inline int stoi(const StringRef &str, size_t *pos = nullptr, int base = 10) { return static_cast(internal::parse_number(str, pos, base, std::strtol)); } @@ -252,7 +254,7 @@ inline float stof(const StringRef &str, size_t *pos = nullptr) { inline double stod(const StringRef &str, size_t *pos = nullptr) { return internal::parse_number(str, pos, std::strtod); } -// NOLINTEND(readability-identifier-naming,google-runtime-int) +// NOLINTEND(readability-identifier-naming,google-runtime-int,readability-non-const-parameter) #ifdef USE_JSON // NOLINTNEXTLINE(readability-identifier-naming)