1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-04 11:02:19 +01:00

Force braces around multi-line statements (#3094)

Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
This commit is contained in:
Oxan van Leeuwen
2022-01-24 20:56:36 +01:00
committed by GitHub
parent 6b27f2d2cf
commit 80d03a631e
125 changed files with 770 additions and 504 deletions

View File

@@ -98,10 +98,11 @@ void LightCall::perform() {
// EFFECT
auto effect = this->effect_;
const char *effect_s;
if (effect == 0u)
if (effect == 0u) {
effect_s = "None";
else
} else {
effect_s = this->parent_->effects_[*this->effect_ - 1]->get_name().c_str();
}
if (this->publish_) {
ESP_LOGD(TAG, " Effect: '%s'", effect_s);
@@ -445,9 +446,10 @@ std::set<ColorMode> LightCall::get_suitable_color_modes_() {
};
auto key = KEY(has_white, has_ct, has_cwww, has_rgb);
for (auto &item : lookup_table)
for (auto &item : lookup_table) {
if (std::get<0>(item) == key)
return std::get<1>(item);
}
// This happens if there are conflicting flags given.
return {};

View File

@@ -145,10 +145,11 @@ void LightState::publish_state() { this->remote_values_callback_.call(); }
LightOutput *LightState::get_output() const { return this->output_; }
std::string LightState::get_effect_name() {
if (this->active_effect_index_ > 0)
if (this->active_effect_index_ > 0) {
return this->effects_[this->active_effect_index_ - 1]->get_name();
else
} else {
return "None";
}
}
void LightState::add_new_remote_values_callback(std::function<void()> &&send_callback) {
@@ -219,10 +220,11 @@ void LightState::start_effect_(uint32_t effect_index) {
effect->start_internal();
}
LightEffect *LightState::get_active_effect_() {
if (this->active_effect_index_ == 0)
if (this->active_effect_index_ == 0) {
return nullptr;
else
} else {
return this->effects_[this->active_effect_index_ - 1];
}
}
void LightState::stop_effect_() {
auto *effect = this->get_active_effect_();