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
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
376 changed files with 466 additions and 468 deletions

View file

@ -18,7 +18,6 @@ Checks: >-
-cppcoreguidelines-avoid-c-arrays, -cppcoreguidelines-avoid-c-arrays,
-cppcoreguidelines-avoid-goto, -cppcoreguidelines-avoid-goto,
-cppcoreguidelines-avoid-magic-numbers, -cppcoreguidelines-avoid-magic-numbers,
-cppcoreguidelines-avoid-non-const-global-variables,
-cppcoreguidelines-init-variables, -cppcoreguidelines-init-variables,
-cppcoreguidelines-macro-usage, -cppcoreguidelines-macro-usage,
-cppcoreguidelines-narrowing-conversions, -cppcoreguidelines-narrowing-conversions,

View file

@ -4,7 +4,7 @@
namespace esphome { namespace esphome {
namespace a4988 { namespace a4988 {
static const char *TAG = "a4988.stepper"; static const char *const TAG = "a4988.stepper";
void A4988::setup() { void A4988::setup() {
ESP_LOGCONFIG(TAG, "Setting up A4988..."); ESP_LOGCONFIG(TAG, "Setting up A4988...");

View file

@ -9,15 +9,15 @@
namespace esphome { namespace esphome {
namespace ac_dimmer { namespace ac_dimmer {
static const char *TAG = "ac_dimmer"; static const char *const TAG = "ac_dimmer";
// Global array to store dimmer objects // Global array to store dimmer objects
static AcDimmerDataStore *all_dimmers[32]; static AcDimmerDataStore *all_dimmers[32]; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
/// Time in microseconds the gate should be held high /// Time in microseconds the gate should be held high
/// 10µs should be long enough for most triacs /// 10µs should be long enough for most triacs
/// For reference: BT136 datasheet says 2µs nominal (page 7) /// For reference: BT136 datasheet says 2µs nominal (page 7)
static uint32_t GATE_ENABLE_TIME = 10; static const uint32_t GATE_ENABLE_TIME = 10;
/// Function called from timer interrupt /// Function called from timer interrupt
/// Input is current time in microseconds (micros()) /// Input is current time in microseconds (micros())

View file

@ -4,7 +4,7 @@
namespace esphome { namespace esphome {
namespace adalight { namespace adalight {
static const char *TAG = "adalight_light_effect"; static const char *const TAG = "adalight_light_effect";
static const uint32_t ADALIGHT_ACK_INTERVAL = 1000; static const uint32_t ADALIGHT_ACK_INTERVAL = 1000;
static const uint32_t ADALIGHT_RECEIVE_TIMEOUT = 1000; static const uint32_t ADALIGHT_RECEIVE_TIMEOUT = 1000;

View file

@ -8,7 +8,7 @@ ADC_MODE(ADC_VCC)
namespace esphome { namespace esphome {
namespace adc { namespace adc {
static const char *TAG = "adc"; static const char *const TAG = "adc";
#ifdef ARDUINO_ARCH_ESP32 #ifdef ARDUINO_ARCH_ESP32
void ADCSensor::set_attenuation(adc_attenuation_t attenuation) { this->attenuation_ = attenuation; } void ADCSensor::set_attenuation(adc_attenuation_t attenuation) { this->attenuation_ = attenuation; }

View file

@ -4,7 +4,7 @@
namespace esphome { namespace esphome {
namespace addressable_light { namespace addressable_light {
static const char *TAG = "addressable_light.display"; static const char *const TAG = "addressable_light.display";
int AddressableLightDisplay::get_width_internal() { return this->width_; } int AddressableLightDisplay::get_width_internal() { return this->width_; }
int AddressableLightDisplay::get_height_internal() { return this->height_; } int AddressableLightDisplay::get_height_internal() { return this->height_; }

View file

@ -4,7 +4,7 @@
namespace esphome { namespace esphome {
namespace ade7953 { namespace ade7953 {
static const char *TAG = "ade7953"; static const char *const TAG = "ade7953";
void ADE7953::dump_config() { void ADE7953::dump_config() {
ESP_LOGCONFIG(TAG, "ADE7953:"); ESP_LOGCONFIG(TAG, "ADE7953:");

View file

@ -4,7 +4,7 @@
namespace esphome { namespace esphome {
namespace ads1115 { namespace ads1115 {
static const char *TAG = "ads1115"; static const char *const TAG = "ads1115";
static const uint8_t ADS1115_REGISTER_CONVERSION = 0x00; static const uint8_t ADS1115_REGISTER_CONVERSION = 0x00;
static const uint8_t ADS1115_REGISTER_CONFIG = 0x01; static const uint8_t ADS1115_REGISTER_CONFIG = 0x01;

View file

@ -18,7 +18,7 @@
namespace esphome { namespace esphome {
namespace aht10 { namespace aht10 {
static const char *TAG = "aht10"; static const char *const TAG = "aht10";
static const uint8_t AHT10_CALIBRATE_CMD[] = {0xE1}; static const uint8_t AHT10_CALIBRATE_CMD[] = {0xE1};
static const uint8_t AHT10_MEASURE_CMD[] = {0xAC, 0x33, 0x00}; static const uint8_t AHT10_MEASURE_CMD[] = {0xAC, 0x33, 0x00};
static const uint8_t AHT10_DEFAULT_DELAY = 5; // ms, for calibration and temperature measurement static const uint8_t AHT10_DEFAULT_DELAY = 5; // ms, for calibration and temperature measurement

View file

@ -9,7 +9,7 @@
namespace esphome { namespace esphome {
namespace am2320 { namespace am2320 {
static const char *TAG = "am2320"; static const char *const TAG = "am2320";
// ---=== Calc CRC16 ===--- // ---=== Calc CRC16 ===---
uint16_t crc_16(uint8_t *ptr, uint8_t length) { uint16_t crc_16(uint8_t *ptr, uint8_t length) {

View file

@ -4,7 +4,7 @@
namespace esphome { namespace esphome {
namespace apds9960 { namespace apds9960 {
static const char *TAG = "apds9960"; static const char *const TAG = "apds9960";
#define APDS9960_ERROR_CHECK(func) \ #define APDS9960_ERROR_CHECK(func) \
if (!(func)) { \ if (!(func)) { \

View file

@ -16,7 +16,7 @@
namespace esphome { namespace esphome {
namespace api { namespace api {
static const char *TAG = "api.connection"; static const char *const TAG = "api.connection";
APIConnection::APIConnection(AsyncClient *client, APIServer *parent) APIConnection::APIConnection(AsyncClient *client, APIServer *parent)
: client_(client), parent_(parent), initial_state_iterator_(parent, this), list_entities_iterator_(parent, this) { : client_(client), parent_(parent), initial_state_iterator_(parent, this), list_entities_iterator_(parent, this) {

View file

@ -6,7 +6,7 @@
namespace esphome { namespace esphome {
namespace api { namespace api {
static const char *TAG = "api.service"; static const char *const TAG = "api.service";
bool APIServerConnectionBase::send_hello_response(const HelloResponse &msg) { bool APIServerConnectionBase::send_hello_response(const HelloResponse &msg) {
ESP_LOGVV(TAG, "send_hello_response: %s", msg.dump().c_str()); ESP_LOGVV(TAG, "send_hello_response: %s", msg.dump().c_str());

View file

@ -15,7 +15,7 @@
namespace esphome { namespace esphome {
namespace api { namespace api {
static const char *TAG = "api"; static const char *const TAG = "api";
// APIServer // APIServer
void APIServer::setup() { void APIServer::setup() {
@ -199,7 +199,7 @@ void APIServer::on_climate_update(climate::Climate *obj) {
float APIServer::get_setup_priority() const { return setup_priority::AFTER_WIFI; } float APIServer::get_setup_priority() const { return setup_priority::AFTER_WIFI; }
void APIServer::set_port(uint16_t port) { this->port_ = port; } void APIServer::set_port(uint16_t port) { this->port_ = port; }
APIServer *global_api_server = nullptr; APIServer *global_api_server = nullptr; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
void APIServer::set_password(const std::string &password) { this->password_ = password; } void APIServer::set_password(const std::string &password) { this->password_ = password; }
void APIServer::send_homeassistant_service_call(const HomeassistantServiceResponse &call) { void APIServer::send_homeassistant_service_call(const HomeassistantServiceResponse &call) {

View file

@ -91,7 +91,7 @@ class APIServer : public Component, public Controller {
std::vector<UserServiceDescriptor *> user_services_; std::vector<UserServiceDescriptor *> user_services_;
}; };
extern APIServer *global_api_server; extern APIServer *global_api_server; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
template<typename... Ts> class APIConnectedCondition : public Condition<Ts...> { template<typename... Ts> class APIConnectedCondition : public Condition<Ts...> {
public: public:

View file

@ -5,7 +5,7 @@
namespace esphome { namespace esphome {
namespace api { namespace api {
static const char *TAG = "api.proto"; static const char *const TAG = "api.proto";
void ProtoMessage::decode(const uint8_t *buffer, size_t length) { void ProtoMessage::decode(const uint8_t *buffer, size_t length) {
uint32_t i = 0; uint32_t i = 0;

View file

@ -4,7 +4,7 @@
namespace esphome { namespace esphome {
namespace as3935 { namespace as3935 {
static const char *TAG = "as3935"; static const char *const TAG = "as3935";
void AS3935Component::setup() { void AS3935Component::setup() {
ESP_LOGCONFIG(TAG, "Setting up AS3935..."); ESP_LOGCONFIG(TAG, "Setting up AS3935...");

View file

@ -4,7 +4,7 @@
namespace esphome { namespace esphome {
namespace as3935_i2c { namespace as3935_i2c {
static const char *TAG = "as3935_i2c"; static const char *const TAG = "as3935_i2c";
void I2CAS3935Component::write_register(uint8_t reg, uint8_t mask, uint8_t bits, uint8_t start_pos) { void I2CAS3935Component::write_register(uint8_t reg, uint8_t mask, uint8_t bits, uint8_t start_pos) {
uint8_t write_reg; uint8_t write_reg;

View file

@ -4,7 +4,7 @@
namespace esphome { namespace esphome {
namespace as3935_spi { namespace as3935_spi {
static const char *TAG = "as3935_spi"; static const char *const TAG = "as3935_spi";
void SPIAS3935Component::setup() { void SPIAS3935Component::setup() {
ESP_LOGI(TAG, "SPIAS3935Component setup started!"); ESP_LOGI(TAG, "SPIAS3935Component setup started!");

View file

@ -6,7 +6,7 @@
namespace esphome { namespace esphome {
namespace atc_mithermometer { namespace atc_mithermometer {
static const char *TAG = "atc_mithermometer"; static const char *const TAG = "atc_mithermometer";
void ATCMiThermometer::dump_config() { void ATCMiThermometer::dump_config() {
ESP_LOGCONFIG(TAG, "ATC MiThermometer"); ESP_LOGCONFIG(TAG, "ATC MiThermometer");

View file

@ -5,7 +5,7 @@
namespace esphome { namespace esphome {
namespace atm90e32 { namespace atm90e32 {
static const char *TAG = "atm90e32"; static const char *const TAG = "atm90e32";
void ATM90E32Component::update() { void ATM90E32Component::update() {
if (this->read16_(ATM90E32_REGISTER_METEREN) != 1) { if (this->read16_(ATM90E32_REGISTER_METEREN) != 1) {

View file

@ -6,7 +6,7 @@
namespace esphome { namespace esphome {
namespace b_parasite { namespace b_parasite {
static const char *TAG = "b_parasite"; static const char *const TAG = "b_parasite";
void BParasite::dump_config() { void BParasite::dump_config() {
ESP_LOGCONFIG(TAG, "b_parasite"); ESP_LOGCONFIG(TAG, "b_parasite");

View file

@ -4,7 +4,7 @@
namespace esphome { namespace esphome {
namespace bang_bang { namespace bang_bang {
static const char *TAG = "bang_bang.climate"; static const char *const TAG = "bang_bang.climate";
void BangBangClimate::setup() { void BangBangClimate::setup() {
this->sensor_->add_on_state_callback([this](float state) { this->sensor_->add_on_state_callback([this](float state) {

View file

@ -4,7 +4,7 @@
namespace esphome { namespace esphome {
namespace bh1750 { namespace bh1750 {
static const char *TAG = "bh1750.sensor"; static const char *const TAG = "bh1750.sensor";
static const uint8_t BH1750_COMMAND_POWER_ON = 0b00000001; static const uint8_t BH1750_COMMAND_POWER_ON = 0b00000001;
static const uint8_t BH1750_COMMAND_MT_REG_HI = 0b01000000; // last 3 bits static const uint8_t BH1750_COMMAND_MT_REG_HI = 0b01000000; // last 3 bits

View file

@ -4,7 +4,7 @@
namespace esphome { namespace esphome {
namespace binary { namespace binary {
static const char *TAG = "binary.fan"; static const char *const TAG = "binary.fan";
void binary::BinaryFan::dump_config() { void binary::BinaryFan::dump_config() {
ESP_LOGCONFIG(TAG, "Fan '%s':", this->fan_->get_name().c_str()); ESP_LOGCONFIG(TAG, "Fan '%s':", this->fan_->get_name().c_str());

View file

@ -4,7 +4,7 @@
namespace esphome { namespace esphome {
namespace binary_sensor { namespace binary_sensor {
static const char *TAG = "binary_sensor.automation"; static const char *const TAG = "binary_sensor.automation";
void binary_sensor::MultiClickTrigger::on_state_(bool state) { void binary_sensor::MultiClickTrigger::on_state_(bool state) {
// Handle duplicate events // Handle duplicate events

View file

@ -5,7 +5,7 @@ namespace esphome {
namespace binary_sensor { namespace binary_sensor {
static const char *TAG = "binary_sensor"; static const char *const TAG = "binary_sensor";
void BinarySensor::add_on_state_callback(std::function<void(bool)> &&callback) { void BinarySensor::add_on_state_callback(std::function<void(bool)> &&callback) {
this->state_callback_.add(std::move(callback)); this->state_callback_.add(std::move(callback));

View file

@ -7,7 +7,7 @@ namespace esphome {
namespace binary_sensor { namespace binary_sensor {
static const char *TAG = "sensor.filter"; static const char *const TAG = "sensor.filter";
void Filter::output(bool value, bool is_initial) { void Filter::output(bool value, bool is_initial) {
if (!this->dedup_.next(value)) if (!this->dedup_.next(value))

View file

@ -4,7 +4,7 @@
namespace esphome { namespace esphome {
namespace binary_sensor_map { namespace binary_sensor_map {
static const char *TAG = "binary_sensor_map"; static const char *const TAG = "binary_sensor_map";
void BinarySensorMap::dump_config() { LOG_SENSOR(" ", "binary_sensor_map", this); } void BinarySensorMap::dump_config() { LOG_SENSOR(" ", "binary_sensor_map", this); }

View file

@ -9,7 +9,7 @@
namespace esphome { namespace esphome {
namespace ble_client { namespace ble_client {
static const char *TAG = "ble_client"; static const char *const TAG = "ble_client";
void BLEClient::setup() { void BLEClient::setup() {
auto ret = esp_ble_gattc_app_register(this->app_id); auto ret = esp_ble_gattc_app_register(this->app_id);

View file

@ -9,7 +9,7 @@
namespace esphome { namespace esphome {
namespace ble_client { namespace ble_client {
static const char *TAG = "ble_sensor"; static const char *const TAG = "ble_sensor";
uint32_t BLESensor::hash_base() { return 343459825UL; } uint32_t BLESensor::hash_base() { return 343459825UL; }

View file

@ -7,7 +7,7 @@
namespace esphome { namespace esphome {
namespace ble_client { namespace ble_client {
static const char *TAG = "ble_switch"; static const char *const TAG = "ble_switch";
void BLEClientSwitch::write_state(bool state) { void BLEClientSwitch::write_state(bool state) {
this->parent_->set_enabled(state); this->parent_->set_enabled(state);

View file

@ -6,7 +6,7 @@
namespace esphome { namespace esphome {
namespace ble_presence { namespace ble_presence {
static const char *TAG = "ble_presence"; static const char *const TAG = "ble_presence";
void BLEPresenceDevice::dump_config() { LOG_BINARY_SENSOR("", "BLE Presence", this); } void BLEPresenceDevice::dump_config() { LOG_BINARY_SENSOR("", "BLE Presence", this); }

View file

@ -6,7 +6,7 @@
namespace esphome { namespace esphome {
namespace ble_rssi { namespace ble_rssi {
static const char *TAG = "ble_rssi"; static const char *const TAG = "ble_rssi";
void BLERSSISensor::dump_config() { LOG_SENSOR("", "BLE RSSI Sensor", this); } void BLERSSISensor::dump_config() { LOG_SENSOR("", "BLE RSSI Sensor", this); }

View file

@ -6,7 +6,7 @@
namespace esphome { namespace esphome {
namespace ble_scanner { namespace ble_scanner {
static const char *TAG = "ble_scanner"; static const char *const TAG = "ble_scanner";
void BLEScanner::dump_config() { LOG_TEXT_SENSOR("", "BLE Scanner", this); } void BLEScanner::dump_config() { LOG_TEXT_SENSOR("", "BLE Scanner", this); }

View file

@ -4,7 +4,7 @@
namespace esphome { namespace esphome {
namespace bme280 { namespace bme280 {
static const char *TAG = "bme280.sensor"; static const char *const TAG = "bme280.sensor";
static const uint8_t BME280_REGISTER_DIG_T1 = 0x88; static const uint8_t BME280_REGISTER_DIG_T1 = 0x88;
static const uint8_t BME280_REGISTER_DIG_T2 = 0x8A; static const uint8_t BME280_REGISTER_DIG_T2 = 0x8A;

View file

@ -4,7 +4,7 @@
namespace esphome { namespace esphome {
namespace bme680 { namespace bme680 {
static const char *TAG = "bme680.sensor"; static const char *const TAG = "bme680.sensor";
static const uint8_t BME680_REGISTER_COEFF1 = 0x89; static const uint8_t BME680_REGISTER_COEFF1 = 0x89;
static const uint8_t BME680_REGISTER_COEFF2 = 0xE1; static const uint8_t BME680_REGISTER_COEFF2 = 0xE1;

View file

@ -6,7 +6,7 @@
namespace esphome { namespace esphome {
namespace bme680_bsec { namespace bme680_bsec {
#ifdef USE_BSEC #ifdef USE_BSEC
static const char *TAG = "bme680_bsec.sensor"; static const char *const TAG = "bme680_bsec.sensor";
static const std::string IAQ_ACCURACY_STATES[4] = {"Stabilizing", "Uncertain", "Calibrating", "Calibrated"}; static const std::string IAQ_ACCURACY_STATES[4] = {"Stabilizing", "Uncertain", "Calibrating", "Calibrated"};

View file

@ -4,7 +4,7 @@
namespace esphome { namespace esphome {
namespace bmp085 { namespace bmp085 {
static const char *TAG = "bmp085.sensor"; static const char *const TAG = "bmp085.sensor";
static const uint8_t BMP085_ADDRESS = 0x77; static const uint8_t BMP085_ADDRESS = 0x77;
static const uint8_t BMP085_REGISTER_AC1_H = 0xAA; static const uint8_t BMP085_REGISTER_AC1_H = 0xAA;

View file

@ -4,7 +4,7 @@
namespace esphome { namespace esphome {
namespace bmp280 { namespace bmp280 {
static const char *TAG = "bmp280.sensor"; static const char *const TAG = "bmp280.sensor";
static const uint8_t BMP280_REGISTER_STATUS = 0xF3; static const uint8_t BMP280_REGISTER_STATUS = 0xF3;
static const uint8_t BMP280_REGISTER_CONTROL = 0xF4; static const uint8_t BMP280_REGISTER_CONTROL = 0xF4;

View file

@ -4,7 +4,7 @@
namespace esphome { namespace esphome {
namespace canbus { namespace canbus {
static const char *TAG = "canbus"; static const char *const TAG = "canbus";
void Canbus::setup() { void Canbus::setup() {
ESP_LOGCONFIG(TAG, "Setting up Canbus..."); ESP_LOGCONFIG(TAG, "Setting up Canbus...");

View file

@ -6,7 +6,7 @@
namespace esphome { namespace esphome {
namespace captive_portal { namespace captive_portal {
static const char *TAG = "captive_portal"; static const char *const TAG = "captive_portal";
void CaptivePortal::handle_index(AsyncWebServerRequest *request) { void CaptivePortal::handle_index(AsyncWebServerRequest *request) {
AsyncResponseStream *stream = request->beginResponseStream("text/html"); AsyncResponseStream *stream = request->beginResponseStream("text/html");
@ -147,7 +147,7 @@ float CaptivePortal::get_setup_priority() const {
} }
void CaptivePortal::dump_config() { ESP_LOGCONFIG(TAG, "Captive Portal:"); } void CaptivePortal::dump_config() { ESP_LOGCONFIG(TAG, "Captive Portal:"); }
CaptivePortal *global_captive_portal = nullptr; CaptivePortal *global_captive_portal = nullptr; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
} // namespace captive_portal } // namespace captive_portal
} // namespace esphome } // namespace esphome

View file

@ -68,7 +68,7 @@ class CaptivePortal : public AsyncWebHandler, public Component {
DNSServer *dns_server_{nullptr}; DNSServer *dns_server_{nullptr};
}; };
extern CaptivePortal *global_captive_portal; extern CaptivePortal *global_captive_portal; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
} // namespace captive_portal } // namespace captive_portal
} // namespace esphome } // namespace esphome

View file

@ -4,7 +4,7 @@
namespace esphome { namespace esphome {
namespace ccs811 { namespace ccs811 {
static const char *TAG = "ccs811"; static const char *const TAG = "ccs811";
// based on // based on
// - https://cdn.sparkfun.com/datasheets/BreakoutBoards/CCS811_Programming_Guide.pdf // - https://cdn.sparkfun.com/datasheets/BreakoutBoards/CCS811_Programming_Guide.pdf

View file

@ -3,7 +3,7 @@
namespace esphome { namespace esphome {
namespace climate { namespace climate {
static const char *TAG = "climate"; static const char *const TAG = "climate";
void ClimateCall::perform() { void ClimateCall::perform() {
ESP_LOGD(TAG, "'%s' - Setting", this->parent_->get_name().c_str()); ESP_LOGD(TAG, "'%s' - Setting", this->parent_->get_name().c_str());

View file

@ -4,7 +4,7 @@
namespace esphome { namespace esphome {
namespace climate_ir { namespace climate_ir {
static const char *TAG = "climate_ir"; static const char *const TAG = "climate_ir";
climate::ClimateTraits ClimateIR::traits() { climate::ClimateTraits ClimateIR::traits() {
auto traits = climate::ClimateTraits(); auto traits = climate::ClimateTraits();

View file

@ -4,7 +4,7 @@
namespace esphome { namespace esphome {
namespace climate_ir_lg { namespace climate_ir_lg {
static const char *TAG = "climate.climate_ir_lg"; static const char *const TAG = "climate.climate_ir_lg";
const uint32_t COMMAND_ON = 0x00000; const uint32_t COMMAND_ON = 0x00000;
const uint32_t COMMAND_ON_AI = 0x03000; const uint32_t COMMAND_ON_AI = 0x03000;

View file

@ -4,7 +4,7 @@
namespace esphome { namespace esphome {
namespace coolix { namespace coolix {
static const char *TAG = "coolix.climate"; static const char *const TAG = "coolix.climate";
const uint32_t COOLIX_OFF = 0xB27BE0; const uint32_t COOLIX_OFF = 0xB27BE0;
const uint32_t COOLIX_SWING = 0xB26BE0; const uint32_t COOLIX_SWING = 0xB26BE0;

View file

@ -4,7 +4,7 @@
namespace esphome { namespace esphome {
namespace cover { namespace cover {
static const char *TAG = "cover"; static const char *const TAG = "cover";
const float COVER_OPEN = 1.0f; const float COVER_OPEN = 1.0f;
const float COVER_CLOSED = 0.0f; const float COVER_CLOSED = 0.0f;

View file

@ -4,7 +4,7 @@
namespace esphome { namespace esphome {
namespace cs5460a { namespace cs5460a {
static const char *TAG = "cs5460a"; static const char *const TAG = "cs5460a";
void CS5460AComponent::write_register_(enum CS5460ARegister addr, uint32_t value) { void CS5460AComponent::write_register_(enum CS5460ARegister addr, uint32_t value) {
this->write_byte(CMD_WRITE | (addr << 1)); this->write_byte(CMD_WRITE | (addr << 1));

View file

@ -4,7 +4,7 @@
namespace esphome { namespace esphome {
namespace cse7766 { namespace cse7766 {
static const char *TAG = "cse7766"; static const char *const TAG = "cse7766";
void CSE7766Component::loop() { void CSE7766Component::loop() {
const uint32_t now = millis(); const uint32_t now = millis();

View file

@ -6,7 +6,7 @@
namespace esphome { namespace esphome {
namespace ct_clamp { namespace ct_clamp {
static const char *TAG = "ct_clamp"; static const char *const TAG = "ct_clamp";
void CTClampSensor::setup() { void CTClampSensor::setup() {
this->is_calibrating_offset_ = true; this->is_calibrating_offset_ = true;

View file

@ -4,7 +4,7 @@
namespace esphome { namespace esphome {
namespace custom { namespace custom {
static const char *TAG = "custom.binary_sensor"; static const char *const TAG = "custom.binary_sensor";
void CustomBinarySensorConstructor::dump_config() { void CustomBinarySensorConstructor::dump_config() {
for (auto *child : this->binary_sensors_) { for (auto *child : this->binary_sensors_) {

View file

@ -4,7 +4,7 @@
namespace esphome { namespace esphome {
namespace custom { namespace custom {
static const char *TAG = "custom.sensor"; static const char *const TAG = "custom.sensor";
void CustomSensorConstructor::dump_config() { void CustomSensorConstructor::dump_config() {
for (auto *child : this->sensors_) { for (auto *child : this->sensors_) {

View file

@ -4,7 +4,7 @@
namespace esphome { namespace esphome {
namespace custom { namespace custom {
static const char *TAG = "custom.switch"; static const char *const TAG = "custom.switch";
void CustomSwitchConstructor::dump_config() { void CustomSwitchConstructor::dump_config() {
for (auto *child : this->switches_) { for (auto *child : this->switches_) {

View file

@ -4,7 +4,7 @@
namespace esphome { namespace esphome {
namespace custom { namespace custom {
static const char *TAG = "custom.text_sensor"; static const char *const TAG = "custom.text_sensor";
void CustomTextSensorConstructor::dump_config() { void CustomTextSensorConstructor::dump_config() {
for (auto *child : this->text_sensors_) { for (auto *child : this->text_sensors_) {

View file

@ -4,7 +4,7 @@
namespace esphome { namespace esphome {
namespace daikin { namespace daikin {
static const char *TAG = "daikin.climate"; static const char *const TAG = "daikin.climate";
void DaikinClimate::transmit_state() { void DaikinClimate::transmit_state() {
uint8_t remote_state[35] = {0x11, 0xDA, 0x27, 0x00, 0xC5, 0x00, 0x00, 0xD7, 0x11, 0xDA, 0x27, 0x00, uint8_t remote_state[35] = {0x11, 0xDA, 0x27, 0x00, 0xC5, 0x00, 0x00, 0xD7, 0x11, 0xDA, 0x27, 0x00,

View file

@ -4,7 +4,7 @@
namespace esphome { namespace esphome {
namespace dallas { namespace dallas {
static const char *TAG = "dallas.sensor"; static const char *const TAG = "dallas.sensor";
static const uint8_t DALLAS_MODEL_DS18S20 = 0x10; static const uint8_t DALLAS_MODEL_DS18S20 = 0x10;
static const uint8_t DALLAS_MODEL_DS1822 = 0x22; static const uint8_t DALLAS_MODEL_DS1822 = 0x22;

View file

@ -5,7 +5,7 @@
namespace esphome { namespace esphome {
namespace dallas { namespace dallas {
static const char *TAG = "dallas.one_wire"; static const char *const TAG = "dallas.one_wire";
const uint8_t ONE_WIRE_ROM_SELECT = 0x55; const uint8_t ONE_WIRE_ROM_SELECT = 0x55;
const int ONE_WIRE_ROM_SEARCH = 0xF0; const int ONE_WIRE_ROM_SEARCH = 0xF0;

View file

@ -11,7 +11,7 @@
namespace esphome { namespace esphome {
namespace debug { namespace debug {
static const char *TAG = "debug"; static const char *const TAG = "debug";
void DebugComponent::dump_config() { void DebugComponent::dump_config() {
#ifndef ESPHOME_LOG_HAS_DEBUG #ifndef ESPHOME_LOG_HAS_DEBUG

View file

@ -5,9 +5,9 @@
namespace esphome { namespace esphome {
namespace deep_sleep { namespace deep_sleep {
static const char *TAG = "deep_sleep"; static const char *const TAG = "deep_sleep";
bool global_has_deep_sleep = false; bool global_has_deep_sleep = false; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
void DeepSleepComponent::setup() { void DeepSleepComponent::setup() {
ESP_LOGCONFIG(TAG, "Setting up Deep Sleep..."); ESP_LOGCONFIG(TAG, "Setting up Deep Sleep...");

View file

@ -79,7 +79,7 @@ class DeepSleepComponent : public Component {
bool prevent_{false}; bool prevent_{false};
}; };
extern bool global_has_deep_sleep; extern bool global_has_deep_sleep; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
template<typename... Ts> class EnterDeepSleepAction : public Action<Ts...> { template<typename... Ts> class EnterDeepSleepAction : public Action<Ts...> {
public: public:

View file

@ -4,7 +4,7 @@
namespace esphome { namespace esphome {
namespace dfplayer { namespace dfplayer {
static const char *TAG = "dfplayer"; static const char *const TAG = "dfplayer";
void DFPlayer::play_folder(uint16_t folder, uint16_t file) { void DFPlayer::play_folder(uint16_t folder, uint16_t file) {
if (folder < 100 && file < 256) { if (folder < 100 && file < 256) {

View file

@ -5,7 +5,7 @@
namespace esphome { namespace esphome {
namespace dht { namespace dht {
static const char *TAG = "dht"; static const char *const TAG = "dht";
void DHT::setup() { void DHT::setup() {
ESP_LOGCONFIG(TAG, "Setting up DHT..."); ESP_LOGCONFIG(TAG, "Setting up DHT...");

View file

@ -8,7 +8,7 @@
namespace esphome { namespace esphome {
namespace dht12 { namespace dht12 {
static const char *TAG = "dht12"; static const char *const TAG = "dht12";
void DHT12Component::update() { void DHT12Component::update() {
uint8_t data[5]; uint8_t data[5];

View file

@ -8,7 +8,7 @@
namespace esphome { namespace esphome {
namespace display { namespace display {
static const char *TAG = "display"; static const char *const TAG = "display";
const Color COLOR_OFF(0, 0, 0, 0); const Color COLOR_OFF(0, 0, 0, 0);
const Color COLOR_ON(255, 255, 255, 255); const Color COLOR_ON(255, 255, 255, 255);

View file

@ -7,7 +7,7 @@
namespace esphome { namespace esphome {
namespace ds1307 { namespace ds1307 {
static const char *TAG = "ds1307"; static const char *const TAG = "ds1307";
void DS1307Component::setup() { void DS1307Component::setup() {
ESP_LOGCONFIG(TAG, "Setting up DS1307..."); ESP_LOGCONFIG(TAG, "Setting up DS1307...");

View file

@ -5,7 +5,7 @@
namespace esphome { namespace esphome {
namespace duty_cycle { namespace duty_cycle {
static const char *TAG = "duty_cycle"; static const char *const TAG = "duty_cycle";
void DutyCycleSensor::setup() { void DutyCycleSensor::setup() {
ESP_LOGCONFIG(TAG, "Setting up Duty Cycle Sensor '%s'...", this->get_name().c_str()); ESP_LOGCONFIG(TAG, "Setting up Duty Cycle Sensor '%s'...", this->get_name().c_str());

View file

@ -14,7 +14,7 @@
namespace esphome { namespace esphome {
namespace e131 { namespace e131 {
static const char *TAG = "e131"; static const char *const TAG = "e131";
static const int PORT = 5568; static const int PORT = 5568;
E131Component::E131Component() {} E131Component::E131Component() {}

View file

@ -5,7 +5,7 @@
namespace esphome { namespace esphome {
namespace e131 { namespace e131 {
static const char *TAG = "e131_addressable_light_effect"; static const char *const TAG = "e131_addressable_light_effect";
static const int MAX_DATA_SIZE = (sizeof(E131Packet::values) - 1); static const int MAX_DATA_SIZE = (sizeof(E131Packet::values) - 1);
E131AddressableLightEffect::E131AddressableLightEffect(const std::string &name) : AddressableLightEffect(name) {} E131AddressableLightEffect::E131AddressableLightEffect(const std::string &name) : AddressableLightEffect(name) {}

View file

@ -8,7 +8,7 @@
namespace esphome { namespace esphome {
namespace e131 { namespace e131 {
static const char *TAG = "e131"; static const char *const TAG = "e131";
static const uint8_t ACN_ID[12] = {0x41, 0x53, 0x43, 0x2d, 0x45, 0x31, 0x2e, 0x31, 0x37, 0x00, 0x00, 0x00}; static const uint8_t ACN_ID[12] = {0x41, 0x53, 0x43, 0x2d, 0x45, 0x31, 0x2e, 0x31, 0x37, 0x00, 0x00, 0x00};
static const uint32_t VECTOR_ROOT = 4; static const uint32_t VECTOR_ROOT = 4;

View file

@ -4,7 +4,7 @@
namespace esphome { namespace esphome {
namespace endstop { namespace endstop {
static const char *TAG = "endstop.cover"; static const char *const TAG = "endstop.cover";
using namespace esphome::cover; using namespace esphome::cover;

View file

@ -14,7 +14,7 @@
namespace esphome { namespace esphome {
namespace esp32_ble { namespace esp32_ble {
static const char *TAG = "esp32_ble"; static const char *const TAG = "esp32_ble";
void ESP32BLE::setup() { void ESP32BLE::setup() {
global_ble = this; global_ble = this;

View file

@ -9,7 +9,7 @@
namespace esphome { namespace esphome {
namespace esp32_ble { namespace esp32_ble {
static const char *TAG = "esp32_ble.characteristic"; static const char *const TAG = "esp32_ble.characteristic";
BLECharacteristic::BLECharacteristic(const ESPBTUUID uuid, uint32_t properties) : uuid_(uuid) { BLECharacteristic::BLECharacteristic(const ESPBTUUID uuid, uint32_t properties) : uuid_(uuid) {
this->set_value_lock_ = xSemaphoreCreateBinary(); this->set_value_lock_ = xSemaphoreCreateBinary();

View file

@ -9,7 +9,7 @@
namespace esphome { namespace esphome {
namespace esp32_ble { namespace esp32_ble {
static const char *TAG = "esp32_ble.descriptor"; static const char *const TAG = "esp32_ble.descriptor";
BLEDescriptor::BLEDescriptor(ESPBTUUID uuid, uint16_t max_len) { BLEDescriptor::BLEDescriptor(ESPBTUUID uuid, uint16_t max_len) {
this->uuid_ = uuid; this->uuid_ = uuid;

View file

@ -16,7 +16,7 @@
namespace esphome { namespace esphome {
namespace esp32_ble { namespace esp32_ble {
static const char *TAG = "esp32_ble.server"; static const char *const TAG = "esp32_ble.server";
static const uint16_t device_information_service__UUID = 0x180A; static const uint16_t device_information_service__UUID = 0x180A;
static const uint16_t MODEL_UUID = 0x2A24; static const uint16_t MODEL_UUID = 0x2A24;

View file

@ -7,7 +7,7 @@
namespace esphome { namespace esphome {
namespace esp32_ble { namespace esp32_ble {
static const char *TAG = "esp32_ble.service"; static const char *const TAG = "esp32_ble.service";
BLEService::BLEService(ESPBTUUID uuid, uint16_t num_handles, uint8_t inst_id) BLEService::BLEService(ESPBTUUID uuid, uint16_t num_handles, uint8_t inst_id)
: uuid_(uuid), num_handles_(num_handles), inst_id_(inst_id) {} : uuid_(uuid), num_handles_(num_handles), inst_id_(inst_id) {}

View file

@ -13,7 +13,7 @@
namespace esphome { namespace esphome {
namespace esp32_ble_beacon { namespace esp32_ble_beacon {
static const char *TAG = "esp32_ble_beacon"; static const char *const TAG = "esp32_ble_beacon";
static esp_ble_adv_params_t ble_adv_params = { static esp_ble_adv_params_t ble_adv_params = {
.adv_int_min = 0x20, .adv_int_min = 0x20,

View file

@ -19,7 +19,7 @@
namespace esphome { namespace esphome {
namespace esp32_ble_tracker { namespace esp32_ble_tracker {
static const char *TAG = "esp32_ble_tracker"; static const char *const TAG = "esp32_ble_tracker";
ESP32BLETracker *global_esp32_ble_tracker = nullptr; ESP32BLETracker *global_esp32_ble_tracker = nullptr;

View file

@ -6,7 +6,7 @@
namespace esphome { namespace esphome {
namespace esp32_camera { namespace esp32_camera {
static const char *TAG = "esp32_camera"; static const char *const TAG = "esp32_camera";
void ESP32Camera::setup() { void ESP32Camera::setup() {
global_esp32_camera = this; global_esp32_camera = this;

View file

@ -9,7 +9,7 @@
namespace esphome { namespace esphome {
namespace esp32_dac { namespace esp32_dac {
static const char *TAG = "esp32_dac"; static const char *const TAG = "esp32_dac";
void ESP32DAC::setup() { void ESP32DAC::setup() {
ESP_LOGCONFIG(TAG, "Setting up ESP32 DAC Output..."); ESP_LOGCONFIG(TAG, "Setting up ESP32 DAC Output...");

View file

@ -7,7 +7,7 @@
namespace esphome { namespace esphome {
namespace esp32_hall { namespace esp32_hall {
static const char *TAG = "esp32_hall"; static const char *const TAG = "esp32_hall";
void ESP32HallSensor::update() { void ESP32HallSensor::update() {
float value = (hallRead() / 4095.0f) * 10000.0f; float value = (hallRead() / 4095.0f) * 10000.0f;

View file

@ -8,7 +8,7 @@
namespace esphome { namespace esphome {
namespace esp32_improv { namespace esp32_improv {
static const char *TAG = "esp32_improv.component"; static const char *const TAG = "esp32_improv.component";
ESP32ImprovComponent::ESP32ImprovComponent() { global_improv_component = this; } ESP32ImprovComponent::ESP32ImprovComponent() { global_improv_component = this; }

View file

@ -6,7 +6,7 @@
namespace esphome { namespace esphome {
namespace esp32_touch { namespace esp32_touch {
static const char *TAG = "esp32_touch"; static const char *const TAG = "esp32_touch";
void ESP32TouchComponent::setup() { void ESP32TouchComponent::setup() {
ESP_LOGCONFIG(TAG, "Setting up ESP32 Touch Hub..."); ESP_LOGCONFIG(TAG, "Setting up ESP32 Touch Hub...");

View file

@ -11,7 +11,7 @@
namespace esphome { namespace esphome {
namespace esp8266_pwm { namespace esp8266_pwm {
static const char *TAG = "esp8266_pwm"; static const char *const TAG = "esp8266_pwm";
void ESP8266PWM::setup() { void ESP8266PWM::setup() {
ESP_LOGCONFIG(TAG, "Setting up ESP8266 PWM Output..."); ESP_LOGCONFIG(TAG, "Setting up ESP8266 PWM Output...");

View file

@ -21,7 +21,7 @@ extern void tcpipInit();
namespace esphome { namespace esphome {
namespace ethernet { namespace ethernet {
static const char *TAG = "ethernet"; static const char *const TAG = "ethernet";
EthernetComponent *global_eth_component; EthernetComponent *global_eth_component;

View file

@ -9,7 +9,7 @@ namespace exposure_notifications {
using namespace esp32_ble_tracker; using namespace esp32_ble_tracker;
static const char *TAG = "exposure_notifications"; static const char *const TAG = "exposure_notifications";
bool ExposureNotificationTrigger::parse_device(const ESPBTDevice &device) { bool ExposureNotificationTrigger::parse_device(const ESPBTDevice &device) {
// See also https://blog.google/documents/70/Exposure_Notification_-_Bluetooth_Specification_v1.2.2.pdf // See also https://blog.google/documents/70/Exposure_Notification_-_Bluetooth_Specification_v1.2.2.pdf

View file

@ -4,7 +4,7 @@
namespace esphome { namespace esphome {
namespace ezo { namespace ezo {
static const char *TAG = "ezo.sensor"; static const char *const TAG = "ezo.sensor";
static const uint16_t EZO_STATE_WAIT = 1; static const uint16_t EZO_STATE_WAIT = 1;
static const uint16_t EZO_STATE_SEND_TEMP = 2; static const uint16_t EZO_STATE_SEND_TEMP = 2;

View file

@ -4,7 +4,7 @@
namespace esphome { namespace esphome {
namespace fan { namespace fan {
static const char *TAG = "fan.automation"; static const char *const TAG = "fan.automation";
} // namespace fan } // namespace fan
} // namespace esphome } // namespace esphome

View file

@ -5,7 +5,7 @@
namespace esphome { namespace esphome {
namespace fan { namespace fan {
static const char *TAG = "fan"; static const char *const TAG = "fan";
const FanTraits &FanState::get_traits() const { return this->traits_; } const FanTraits &FanState::get_traits() const { return this->traits_; }
void FanState::set_traits(const FanTraits &traits) { this->traits_ = traits; } void FanState::set_traits(const FanTraits &traits) { this->traits_ = traits; }

View file

@ -4,7 +4,7 @@
namespace esphome { namespace esphome {
namespace fastled_base { namespace fastled_base {
static const char *TAG = "fastled"; static const char *const TAG = "fastled";
void FastLEDLightOutput::setup() { void FastLEDLightOutput::setup() {
ESP_LOGCONFIG(TAG, "Setting up FastLED light..."); ESP_LOGCONFIG(TAG, "Setting up FastLED light...");

View file

@ -4,7 +4,7 @@
namespace esphome { namespace esphome {
namespace fingerprint_grow { namespace fingerprint_grow {
static const char *TAG = "fingerprint_grow"; static const char *const TAG = "fingerprint_grow";
// Based on Adafruit's library: https://github.com/adafruit/Adafruit-Fingerprint-Sensor-Library // Based on Adafruit's library: https://github.com/adafruit/Adafruit-Fingerprint-Sensor-Library

View file

@ -9,7 +9,7 @@ namespace fujitsu_general {
((message)[(nibble) / 2] |= ((value) &0b00001111) << (((nibble) % 2) ? 0 : 4)) ((message)[(nibble) / 2] |= ((value) &0b00001111) << (((nibble) % 2) ? 0 : 4))
#define GET_NIBBLE(message, nibble) (((message)[(nibble) / 2] >> (((nibble) % 2) ? 0 : 4)) & 0b00001111) #define GET_NIBBLE(message, nibble) (((message)[(nibble) / 2] >> (((nibble) % 2) ? 0 : 4)) & 0b00001111)
static const char *TAG = "fujitsu_general.climate"; static const char *const TAG = "fujitsu_general.climate";
// Common header // Common header
const uint8_t FUJITSU_GENERAL_COMMON_LENGTH = 6; const uint8_t FUJITSU_GENERAL_COMMON_LENGTH = 6;

View file

@ -4,7 +4,7 @@
namespace esphome { namespace esphome {
namespace gpio { namespace gpio {
static const char *TAG = "gpio.binary_sensor"; static const char *const TAG = "gpio.binary_sensor";
void GPIOBinarySensor::setup() { void GPIOBinarySensor::setup() {
this->pin_->setup(); this->pin_->setup();

View file

@ -4,7 +4,7 @@
namespace esphome { namespace esphome {
namespace gpio { namespace gpio {
static const char *TAG = "gpio.output"; static const char *const TAG = "gpio.output";
void GPIOBinaryOutput::dump_config() { void GPIOBinaryOutput::dump_config() {
ESP_LOGCONFIG(TAG, "GPIO Binary Output:"); ESP_LOGCONFIG(TAG, "GPIO Binary Output:");

View file

@ -4,7 +4,7 @@
namespace esphome { namespace esphome {
namespace gpio { namespace gpio {
static const char *TAG = "switch.gpio"; static const char *const TAG = "switch.gpio";
float GPIOSwitch::get_setup_priority() const { return setup_priority::HARDWARE; } float GPIOSwitch::get_setup_priority() const { return setup_priority::HARDWARE; }
void GPIOSwitch::setup() { void GPIOSwitch::setup() {

View file

@ -4,7 +4,7 @@
namespace esphome { namespace esphome {
namespace gps { namespace gps {
static const char *TAG = "gps"; static const char *const TAG = "gps";
TinyGPSPlus &GPSListener::get_tiny_gps() { return this->parent_->get_tiny_gps(); } TinyGPSPlus &GPSListener::get_tiny_gps() { return this->parent_->get_tiny_gps(); }

View file

@ -4,7 +4,7 @@
namespace esphome { namespace esphome {
namespace gps { namespace gps {
static const char *TAG = "gps.time"; static const char *const TAG = "gps.time";
void GPSTime::from_tiny_gps_(TinyGPSPlus &tiny_gps) { void GPSTime::from_tiny_gps_(TinyGPSPlus &tiny_gps) {
if (!tiny_gps.time.isValid() || !tiny_gps.date.isValid()) if (!tiny_gps.time.isValid() || !tiny_gps.date.isValid())

View file

@ -4,7 +4,7 @@
namespace esphome { namespace esphome {
namespace hdc1080 { namespace hdc1080 {
static const char *TAG = "hdc1080"; static const char *const TAG = "hdc1080";
static const uint8_t HDC1080_ADDRESS = 0x40; // 0b1000000 from datasheet static const uint8_t HDC1080_ADDRESS = 0x40; // 0b1000000 from datasheet
static const uint8_t HDC1080_CMD_CONFIGURATION = 0x02; static const uint8_t HDC1080_CMD_CONFIGURATION = 0x02;

View file

@ -3,7 +3,7 @@
namespace esphome { namespace esphome {
namespace hitachi_ac344 { namespace hitachi_ac344 {
static const char *TAG = "climate.hitachi_ac344"; static const char *const TAG = "climate.hitachi_ac344";
void set_bits(uint8_t *const dst, const uint8_t offset, const uint8_t nbits, const uint8_t data) { void set_bits(uint8_t *const dst, const uint8_t offset, const uint8_t nbits, const uint8_t data) {
if (offset >= 8 || !nbits) if (offset >= 8 || !nbits)

Some files were not shown because too many files have changed in this diff Show more