mirror of
https://github.com/esphome/esphome.git
synced 2026-02-08 00:31:58 +00:00
[ci] Add format_hex_pretty to heap-allocating helper lint check (#13178)
This commit is contained in:
@@ -18,9 +18,9 @@ char *format_bytes_to(char *buffer, const std::vector<uint8_t> &bytes) {
|
|||||||
|
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||||
std::string format_uid(const std::vector<uint8_t> &uid) { return format_hex_pretty(uid, '-', false); }
|
// Deprecated wrappers intentionally use heap-allocating version for backward compatibility
|
||||||
|
std::string format_uid(const std::vector<uint8_t> &uid) { return format_hex_pretty(uid, '-', false); } // NOLINT
|
||||||
std::string format_bytes(const std::vector<uint8_t> &bytes) { return format_hex_pretty(bytes, ' ', false); }
|
std::string format_bytes(const std::vector<uint8_t> &bytes) { return format_hex_pretty(bytes, ' ', false); } // NOLINT
|
||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
||||||
|
|
||||||
uint8_t guess_tag_type(uint8_t uid_length) {
|
uint8_t guess_tag_type(uint8_t uid_length) {
|
||||||
|
|||||||
@@ -220,7 +220,7 @@ void RC522::loop() {
|
|||||||
|
|
||||||
std::vector<uint8_t> rfid_uid(std::begin(uid_buffer_), std::begin(uid_buffer_) + uid_idx_);
|
std::vector<uint8_t> rfid_uid(std::begin(uid_buffer_), std::begin(uid_buffer_) + uid_idx_);
|
||||||
uid_idx_ = 0;
|
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_();
|
pcd_antenna_off_();
|
||||||
state_ = STATE_INIT; // scan again on next update
|
state_ = STATE_INIT; // scan again on next update
|
||||||
bool report = true;
|
bool report = true;
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ class MideaData {
|
|||||||
bool is_compliment(const MideaData &rhs) const;
|
bool is_compliment(const MideaData &rhs) const;
|
||||||
/// @deprecated Allocates heap memory. Use to_str() instead. Removed in 2026.7.0.
|
/// @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")
|
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"
|
/// 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);
|
static constexpr size_t TO_STR_BUFFER_SIZE = format_hex_pretty_size(6);
|
||||||
/// Format to buffer, returns pointer to buffer
|
/// Format to buffer, returns pointer to buffer
|
||||||
|
|||||||
@@ -683,6 +683,7 @@ def lint_trailing_whitespace(fname, match):
|
|||||||
# These return std::string and should be replaced with stack-based alternatives.
|
# These return std::string and should be replaced with stack-based alternatives.
|
||||||
HEAP_ALLOCATING_HELPERS = {
|
HEAP_ALLOCATING_HELPERS = {
|
||||||
"format_hex": "format_hex_to() with a stack buffer",
|
"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",
|
"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": "get_mac_address_into_buffer() with a stack buffer",
|
||||||
"get_mac_address_pretty": "get_mac_address_pretty_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
|
# Use negative lookahead to exclude _to/_into_buffer variants
|
||||||
# format_hex(?!_) ensures we don't match format_hex_to, format_hex_pretty_to, etc.
|
# 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.
|
# 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"[^\w]("
|
||||||
r"format_hex(?!_)|"
|
r"format_hex(?!_)|"
|
||||||
|
r"format_hex_pretty(?!_)|"
|
||||||
r"format_mac_address_pretty|"
|
r"format_mac_address_pretty|"
|
||||||
r"get_mac_address_pretty(?!_)|"
|
r"get_mac_address_pretty(?!_)|"
|
||||||
r"get_mac_address(?!_)|"
|
r"get_mac_address(?!_)|"
|
||||||
r"str_truncate|"
|
r"str_truncate|"
|
||||||
r"str_upper_case|"
|
r"str_upper_case|"
|
||||||
r"str_snake_case"
|
r"str_snake_case"
|
||||||
r")\s*\(",
|
r")\s*\(" + CPP_RE_EOL,
|
||||||
include=cpp_include,
|
include=cpp_include,
|
||||||
exclude=[
|
exclude=[
|
||||||
# The definitions themselves
|
# The definitions themselves
|
||||||
|
|||||||
Reference in New Issue
Block a user