diff --git a/esphome/components/nfc/nfc.cpp b/esphome/components/nfc/nfc.cpp index 82e86b936a6..f60d2671cd4 100644 --- a/esphome/components/nfc/nfc.cpp +++ b/esphome/components/nfc/nfc.cpp @@ -18,9 +18,9 @@ char *format_bytes_to(char *buffer, const std::vector &bytes) { #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wdeprecated-declarations" -std::string format_uid(const std::vector &uid) { return format_hex_pretty(uid, '-', false); } - -std::string format_bytes(const std::vector &bytes) { return format_hex_pretty(bytes, ' ', false); } +// Deprecated wrappers intentionally use heap-allocating version for backward compatibility +std::string format_uid(const std::vector &uid) { return format_hex_pretty(uid, '-', false); } // NOLINT +std::string format_bytes(const std::vector &bytes) { return format_hex_pretty(bytes, ' ', false); } // NOLINT #pragma GCC diagnostic pop uint8_t guess_tag_type(uint8_t uid_length) { diff --git a/esphome/components/rc522/rc522.cpp b/esphome/components/rc522/rc522.cpp index 470c50109e6..91fae7fa345 100644 --- a/esphome/components/rc522/rc522.cpp +++ b/esphome/components/rc522/rc522.cpp @@ -220,7 +220,7 @@ void RC522::loop() { std::vector rfid_uid(std::begin(uid_buffer_), std::begin(uid_buffer_) + uid_idx_); uid_idx_ = 0; - // ESP_LOGD(TAG, "Processing '%s'", format_hex_pretty(rfid_uid, '-', false).c_str()); + // ESP_LOGD(TAG, "Processing '%s'", format_hex_pretty(rfid_uid, '-', false).c_str()); // NOLINT pcd_antenna_off_(); state_ = STATE_INIT; // scan again on next update bool report = true; diff --git a/esphome/components/remote_base/midea_protocol.h b/esphome/components/remote_base/midea_protocol.h index c3030d565ee..ddefff867a3 100644 --- a/esphome/components/remote_base/midea_protocol.h +++ b/esphome/components/remote_base/midea_protocol.h @@ -31,7 +31,7 @@ class MideaData { bool is_compliment(const MideaData &rhs) const; /// @deprecated Allocates heap memory. Use to_str() instead. Removed in 2026.7.0. ESPDEPRECATED("Allocates heap memory. Use to_str() instead. Removed in 2026.7.0.", "2026.1.0") - std::string to_string() const { return format_hex_pretty(this->data_.data(), this->data_.size()); } + std::string to_string() const { return format_hex_pretty(this->data_.data(), this->data_.size()); } // NOLINT /// Buffer size for to_str(): 6 bytes = "AA.BB.CC.DD.EE.FF\0" static constexpr size_t TO_STR_BUFFER_SIZE = format_hex_pretty_size(6); /// Format to buffer, returns pointer to buffer diff --git a/script/ci-custom.py b/script/ci-custom.py index 1e2d07885e3..e63e61e0960 100755 --- a/script/ci-custom.py +++ b/script/ci-custom.py @@ -683,6 +683,7 @@ def lint_trailing_whitespace(fname, match): # These return std::string and should be replaced with stack-based alternatives. HEAP_ALLOCATING_HELPERS = { "format_hex": "format_hex_to() with a stack buffer", + "format_hex_pretty": "format_hex_pretty_to() with a stack buffer", "format_mac_address_pretty": "format_mac_addr_upper() with a stack buffer", "get_mac_address": "get_mac_address_into_buffer() with a stack buffer", "get_mac_address_pretty": "get_mac_address_pretty_into_buffer() with a stack buffer", @@ -696,15 +697,17 @@ HEAP_ALLOCATING_HELPERS = { # Use negative lookahead to exclude _to/_into_buffer variants # format_hex(?!_) ensures we don't match format_hex_to, format_hex_pretty_to, etc. # get_mac_address(?!_) ensures we don't match get_mac_address_into_buffer, etc. + # CPP_RE_EOL captures rest of line so NOLINT comments are detected r"[^\w](" r"format_hex(?!_)|" + r"format_hex_pretty(?!_)|" r"format_mac_address_pretty|" r"get_mac_address_pretty(?!_)|" r"get_mac_address(?!_)|" r"str_truncate|" r"str_upper_case|" r"str_snake_case" - r")\s*\(", + r")\s*\(" + CPP_RE_EOL, include=cpp_include, exclude=[ # The definitions themselves