Add NOLINT for precondition-based get_state() access

get_state() requires callers to check has_state() first.
This is a documented precondition, not an unchecked access.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
J. Nick Koston
2026-02-27 17:25:52 -10:00
co-authored by Claude Opus 4.6
parent 4e1b7c440e
commit 529293b5be
2 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -69,7 +69,7 @@ optional<size_t> SelectCall::calculate_target_index_(const char *name) {
ESP_LOGW(TAG, "'%s' - No option set", name);
return {};
}
return this->index_.value();
return this->index_;
}
// SELECT_OP_NEXT or SELECT_OP_PREVIOUS
+1 -1
View File
@@ -252,7 +252,7 @@ void log_entity_unit_of_measurement(const char *tag, const char *prefix, const E
template<typename T> class StatefulEntityBase : public EntityBase {
public:
virtual bool has_state() const { return this->state_.has_value(); }
virtual const T &get_state() const { return *this->state_; }
virtual const T &get_state() const { return this->state_.value(); } // NOLINT(bugprone-unchecked-optional-access)
virtual T get_state_default(T default_value) const { return this->state_.value_or(default_value); }
void invalidate_state() { this->set_new_state({}); }