Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix clang-tidy issues #21

Merged
merged 4 commits into from
Dec 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions components/apc_ups/apc_ups.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ void ApcUps::loop() {
}

if (this->state_ == STATE_POLL_DECODED) {
std::string mode;
switch (this->used_polling_commands_[this->last_polling_command_].identifier) {
case POLLING_Y:
this->publish_state_(this->smart_mode_, value_smart_mode_);
Expand Down Expand Up @@ -204,7 +203,6 @@ void ApcUps::loop() {
}

if (this->state_ == STATE_POLL_CHECKED) {
std::string fc;
char tmp[APC_UPS_READ_BUFFER_LENGTH];
sprintf(tmp, "%s", this->read_buffer_);
switch (this->used_polling_commands_[this->last_polling_command_].identifier) {
Expand Down Expand Up @@ -471,7 +469,7 @@ uint8_t ApcUps::check_incoming_length_(uint8_t length) {

// send next command used
uint8_t ApcUps::send_next_command_() {
if (this->command_queue_[this->command_queue_position_].length() != 0) {
if (!this->command_queue_[this->command_queue_position_].empty()) {
const char *command = this->command_queue_[this->command_queue_position_].c_str();
uint8_t byte_command[16];
uint8_t length = this->command_queue_[this->command_queue_position_].length();
Expand Down Expand Up @@ -515,7 +513,7 @@ void ApcUps::queue_command_(const char *command, uint8_t length) {
uint8_t next_position = command_queue_position_;
for (uint8_t i = 0; i < COMMAND_QUEUE_LENGTH; i++) {
uint8_t testposition = (next_position + i) % COMMAND_QUEUE_LENGTH;
if (command_queue_[testposition].length() == 0) {
if (command_queue_[testposition].empty()) {
command_queue_[testposition] = command;
ESP_LOGD(TAG, "Command queued successfully: %s with length %u at position %d", command,
command_queue_[testposition].length(), testposition);
Expand Down
4 changes: 2 additions & 2 deletions components/apc_ups/switch/apc_ups_switch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ static const char *const TAG = "apc_ups.switch";
void ApcUpsSwitch::dump_config() { LOG_SWITCH(TAG, "ApcUps Switch", this); }
void ApcUpsSwitch::write_state(bool state) {
if (state) {
if (this->on_command_.length() > 0) {
if (!this->on_command_.empty()) {
this->parent_->switch_command(this->on_command_);
}
} else {
if (this->off_command_.length() > 0) {
if (!this->off_command_.empty()) {
this->parent_->switch_command(this->off_command_);
}
}
Expand Down
Loading