Avoid non-const globals and enable clang-tidy check (#1892)

This commit is contained in:
Stefan Agner
2021-06-10 22:19:44 +02:00
committed by GitHub
parent 360effcb72
commit 501f88ca86
376 changed files with 466 additions and 468 deletions
@@ -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"; }
+2 -2
View File
@@ -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)) {}
+1 -1
View File
@@ -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:
+1 -1
View File
@@ -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;
+1 -1
View File
@@ -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; }
+1 -1
View File
@@ -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;
+1 -1
View File
@@ -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;
+1 -1
View File
@@ -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;
+1 -1
View File
@@ -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;
+1 -1
View File
@@ -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_;
+1 -1
View File
@@ -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;