mirror of
https://github.com/esphome/esphome.git
synced 2026-02-08 00:31:58 +00:00
fix clang-tidy warnings
- Add NOLINT for intentional global mutable state - Simplify boolean return in parse_posix_tz - Add USE_TIME_TIMEZONE define for tests - Add NOLINT for Google Test SetUp/TearDown methods
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
namespace esphome::time {
|
||||
|
||||
// Global timezone - set once at startup, rarely changes
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables) - intentional mutable state
|
||||
static ParsedTimezone global_tz_{};
|
||||
|
||||
void set_global_tz(const ParsedTimezone &tz) { global_tz_ = tz; }
|
||||
@@ -430,12 +431,8 @@ bool parse_posix_tz(const char *tz_string, ParsedTimezone &result) {
|
||||
return false;
|
||||
}
|
||||
p++;
|
||||
if (!internal::parse_dst_rule(p, result.dst_end)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// has_dst() now returns true since dst_start.type was set by parse_dst_rule
|
||||
return true;
|
||||
return internal::parse_dst_rule(p, result.dst_end);
|
||||
}
|
||||
|
||||
bool epoch_to_local_tm(time_t utc_epoch, const ParsedTimezone &tz, struct tm *out_tm) {
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Tests for the POSIX TZ parser and ESPTime::strptime implementations
|
||||
// These custom parsers avoid pulling in scanf (~9.8KB on ESP32-IDF).
|
||||
|
||||
// Enable USE_TIME_TIMEZONE for tests
|
||||
#define USE_TIME_TIMEZONE
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <cstdlib>
|
||||
#include <ctime>
|
||||
@@ -752,6 +755,7 @@ TEST(PosixTzParser, EpochToLocalDstTransition) {
|
||||
|
||||
class LibcVerificationTest : public ::testing::TestWithParam<std::tuple<const char *, time_t>> {
|
||||
protected:
|
||||
// NOLINTNEXTLINE(readability-identifier-naming) - Google Test requires this name
|
||||
void SetUp() override {
|
||||
// Save current TZ
|
||||
const char *current_tz = getenv("TZ");
|
||||
@@ -759,6 +763,7 @@ class LibcVerificationTest : public ::testing::TestWithParam<std::tuple<const ch
|
||||
had_tz_ = current_tz != nullptr;
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(readability-identifier-naming) - Google Test requires this name
|
||||
void TearDown() override {
|
||||
// Restore TZ
|
||||
if (had_tz_) {
|
||||
|
||||
Reference in New Issue
Block a user