mirror of
https://github.com/Threnklyn/esphome-dev.git
synced 2026-06-06 04:48:27 +02:00
Avoid non-const globals and enable clang-tidy check (#1892)
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
namespace esphome {
|
||||
namespace mqtt {
|
||||
|
||||
static const char *TAG = "mqtt.custom";
|
||||
static const char *const TAG = "mqtt.custom";
|
||||
|
||||
bool CustomMQTTDevice::publish(const std::string &topic, const std::string &payload, uint8_t qos, bool retain) {
|
||||
return global_mqtt_client->publish(topic, payload, qos, retain);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
namespace esphome {
|
||||
namespace mqtt {
|
||||
|
||||
static const char *TAG = "mqtt.binary_sensor";
|
||||
static const char *const TAG = "mqtt.binary_sensor";
|
||||
|
||||
std::string MQTTBinarySensorComponent::component_type() const { return "binary_sensor"; }
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
namespace esphome {
|
||||
namespace mqtt {
|
||||
|
||||
static const char *TAG = "mqtt";
|
||||
static const char *const TAG = "mqtt";
|
||||
|
||||
MQTTClientComponent::MQTTClientComponent() {
|
||||
global_mqtt_client = this;
|
||||
@@ -560,7 +560,7 @@ void MQTTClientComponent::add_ssl_fingerprint(const std::array<uint8_t, SHA1_SIZ
|
||||
}
|
||||
#endif
|
||||
|
||||
MQTTClientComponent *global_mqtt_client = nullptr;
|
||||
MQTTClientComponent *global_mqtt_client = nullptr; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
|
||||
// MQTTMessageTrigger
|
||||
MQTTMessageTrigger::MQTTMessageTrigger(std::string topic) : topic_(std::move(topic)) {}
|
||||
|
||||
@@ -275,7 +275,7 @@ class MQTTClientComponent : public Component {
|
||||
optional<AsyncMqttClientDisconnectReason> disconnect_reason_{};
|
||||
};
|
||||
|
||||
extern MQTTClientComponent *global_mqtt_client;
|
||||
extern MQTTClientComponent *global_mqtt_client; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
|
||||
class MQTTMessageTrigger : public Trigger<std::string>, public Component {
|
||||
public:
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
namespace esphome {
|
||||
namespace mqtt {
|
||||
|
||||
static const char *TAG = "mqtt.climate";
|
||||
static const char *const TAG = "mqtt.climate";
|
||||
|
||||
using namespace esphome::climate;
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
namespace esphome {
|
||||
namespace mqtt {
|
||||
|
||||
static const char *TAG = "mqtt.component";
|
||||
static const char *const TAG = "mqtt.component";
|
||||
|
||||
void MQTTComponent::set_retain(bool retain) { this->retain_ = retain; }
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
namespace esphome {
|
||||
namespace mqtt {
|
||||
|
||||
static const char *TAG = "mqtt.cover";
|
||||
static const char *const TAG = "mqtt.cover";
|
||||
|
||||
using namespace esphome::cover;
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
namespace esphome {
|
||||
namespace mqtt {
|
||||
|
||||
static const char *TAG = "mqtt.fan";
|
||||
static const char *const TAG = "mqtt.fan";
|
||||
|
||||
using namespace esphome::fan;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
namespace esphome {
|
||||
namespace mqtt {
|
||||
|
||||
static const char *TAG = "mqtt.light";
|
||||
static const char *const TAG = "mqtt.light";
|
||||
|
||||
using namespace esphome::light;
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
namespace esphome {
|
||||
namespace mqtt {
|
||||
|
||||
static const char *TAG = "mqtt.sensor";
|
||||
static const char *const TAG = "mqtt.sensor";
|
||||
|
||||
using namespace esphome::sensor;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
namespace esphome {
|
||||
namespace mqtt {
|
||||
|
||||
static const char *TAG = "mqtt.switch";
|
||||
static const char *const TAG = "mqtt.switch";
|
||||
|
||||
using namespace esphome::switch_;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
namespace esphome {
|
||||
namespace mqtt {
|
||||
|
||||
static const char *TAG = "mqtt.text_sensor";
|
||||
static const char *const TAG = "mqtt.text_sensor";
|
||||
|
||||
using namespace esphome::text_sensor;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user