mirror of
https://github.com/esphome/esphome.git
synced 2025-09-26 15:12:21 +01:00
Activate some clang-tidy checks (#1884)
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "esphome/core/component.h"
|
||||
#include "esphome/core/automation.h"
|
||||
#include "esphome/components/text_sensor/text_sensor.h"
|
||||
@@ -10,7 +12,7 @@ namespace text_sensor {
|
||||
class TextSensorStateTrigger : public Trigger<std::string> {
|
||||
public:
|
||||
explicit TextSensorStateTrigger(TextSensor *parent) {
|
||||
parent->add_on_state_callback([this](std::string value) { this->trigger(value); });
|
||||
parent->add_on_state_callback([this](std::string value) { this->trigger(std::move(value)); });
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -9,7 +9,7 @@ static const char *TAG = "text_sensor";
|
||||
TextSensor::TextSensor() : TextSensor("") {}
|
||||
TextSensor::TextSensor(const std::string &name) : Nameable(name) {}
|
||||
|
||||
void TextSensor::publish_state(std::string state) {
|
||||
void TextSensor::publish_state(const std::string &state) {
|
||||
this->state = state;
|
||||
this->has_state_ = true;
|
||||
ESP_LOGD(TAG, "'%s': Sending state '%s'", this->name_.c_str(), state.c_str());
|
||||
|
@@ -7,13 +7,13 @@ namespace esphome {
|
||||
namespace text_sensor {
|
||||
|
||||
#define LOG_TEXT_SENSOR(prefix, type, obj) \
|
||||
if (obj != nullptr) { \
|
||||
ESP_LOGCONFIG(TAG, "%s%s '%s'", prefix, type, obj->get_name().c_str()); \
|
||||
if (!obj->get_icon().empty()) { \
|
||||
ESP_LOGCONFIG(TAG, "%s Icon: '%s'", prefix, obj->get_icon().c_str()); \
|
||||
if ((obj) != nullptr) { \
|
||||
ESP_LOGCONFIG(TAG, "%s%s '%s'", prefix, type, (obj)->get_name().c_str()); \
|
||||
if (!(obj)->get_icon().empty()) { \
|
||||
ESP_LOGCONFIG(TAG, "%s Icon: '%s'", prefix, (obj)->get_icon().c_str()); \
|
||||
} \
|
||||
if (!obj->unique_id().empty()) { \
|
||||
ESP_LOGV(TAG, "%s Unique ID: '%s'", prefix, obj->unique_id().c_str()); \
|
||||
if (!(obj)->unique_id().empty()) { \
|
||||
ESP_LOGV(TAG, "%s Unique ID: '%s'", prefix, (obj)->unique_id().c_str()); \
|
||||
} \
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ class TextSensor : public Nameable {
|
||||
explicit TextSensor();
|
||||
explicit TextSensor(const std::string &name);
|
||||
|
||||
void publish_state(std::string state);
|
||||
void publish_state(const std::string &state);
|
||||
|
||||
void set_icon(const std::string &icon);
|
||||
|
||||
|
Reference in New Issue
Block a user