mirror of
https://github.com/esphome/esphome.git
synced 2025-01-13 08:03:18 +01:00
clang-tidy
This commit is contained in:
parent
355ff1cf4d
commit
0778cc3c72
10 changed files with 70 additions and 19 deletions
|
@ -47,7 +47,7 @@ class HaierClimateBase : public esphome::Component,
|
||||||
void set_supported_presets(const std::set<esphome::climate::ClimatePreset> &presets);
|
void set_supported_presets(const std::set<esphome::climate::ClimatePreset> &presets);
|
||||||
bool valid_connection() const { return this->protocol_phase_ >= ProtocolPhases::IDLE; };
|
bool valid_connection() const { return this->protocol_phase_ >= ProtocolPhases::IDLE; };
|
||||||
size_t available() noexcept override { return esphome::uart::UARTDevice::available(); };
|
size_t available() noexcept override { return esphome::uart::UARTDevice::available(); };
|
||||||
size_t read_array(uint8_t *data, size_t len) noexcept override {
|
size_t read_array(uint8_t *data, size_t len) noexcept override { // NOLINT(readability-non-const-parameter)
|
||||||
return esphome::uart::UARTDevice::read_array(data, len) ? len : 0;
|
return esphome::uart::UARTDevice::read_array(data, len) ? len : 0;
|
||||||
};
|
};
|
||||||
void write_array(const uint8_t *data, size_t len) noexcept override {
|
void write_array(const uint8_t *data, size_t len) noexcept override {
|
||||||
|
|
|
@ -18,7 +18,7 @@ class LVLight : public light::LightOutput {
|
||||||
float red, green, blue;
|
float red, green, blue;
|
||||||
state->current_values_as_rgb(&red, &green, &blue, false);
|
state->current_values_as_rgb(&red, &green, &blue, false);
|
||||||
auto color = lv_color_make(red * 255, green * 255, blue * 255);
|
auto color = lv_color_make(red * 255, green * 255, blue * 255);
|
||||||
if (this->obj_ != nullptr) {
|
if (this->obj_ != nullptr) { // NOLINT(bugprone-branch-clone)
|
||||||
this->set_value_(color);
|
this->set_value_(color);
|
||||||
} else {
|
} else {
|
||||||
this->initial_value_ = color;
|
this->initial_value_ = color;
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
from esphome.core import CORE
|
|
||||||
import esphome.codegen as cg
|
import esphome.codegen as cg
|
||||||
import esphome.config_validation as cv
|
|
||||||
from esphome.components.esp32 import add_idf_sdkconfig_option
|
from esphome.components.esp32 import add_idf_sdkconfig_option
|
||||||
|
import esphome.config_validation as cv
|
||||||
from esphome.const import (
|
from esphome.const import (
|
||||||
CONF_ENABLE_IPV6,
|
CONF_ENABLE_IPV6,
|
||||||
CONF_MIN_IPV6_ADDR_COUNT,
|
CONF_MIN_IPV6_ADDR_COUNT,
|
||||||
|
@ -10,6 +8,7 @@ from esphome.const import (
|
||||||
PLATFORM_ESP8266,
|
PLATFORM_ESP8266,
|
||||||
PLATFORM_RP2040,
|
PLATFORM_RP2040,
|
||||||
)
|
)
|
||||||
|
from esphome.core import CORE
|
||||||
|
|
||||||
CODEOWNERS = ["@esphome/core"]
|
CODEOWNERS = ["@esphome/core"]
|
||||||
AUTO_LOAD = ["mdns"]
|
AUTO_LOAD = ["mdns"]
|
||||||
|
@ -33,6 +32,7 @@ CONFIG_SCHEMA = cv.Schema(
|
||||||
|
|
||||||
|
|
||||||
async def to_code(config):
|
async def to_code(config):
|
||||||
|
cg.add_define("USE_NETWORK")
|
||||||
if (enable_ipv6 := config.get(CONF_ENABLE_IPV6, None)) is not None:
|
if (enable_ipv6 := config.get(CONF_ENABLE_IPV6, None)) is not None:
|
||||||
cg.add_define("USE_NETWORK_IPV6", enable_ipv6)
|
cg.add_define("USE_NETWORK_IPV6", enable_ipv6)
|
||||||
if enable_ipv6:
|
if enable_ipv6:
|
||||||
|
@ -42,11 +42,10 @@ async def to_code(config):
|
||||||
if CORE.using_esp_idf:
|
if CORE.using_esp_idf:
|
||||||
add_idf_sdkconfig_option("CONFIG_LWIP_IPV6", enable_ipv6)
|
add_idf_sdkconfig_option("CONFIG_LWIP_IPV6", enable_ipv6)
|
||||||
add_idf_sdkconfig_option("CONFIG_LWIP_IPV6_AUTOCONFIG", enable_ipv6)
|
add_idf_sdkconfig_option("CONFIG_LWIP_IPV6_AUTOCONFIG", enable_ipv6)
|
||||||
else:
|
elif enable_ipv6:
|
||||||
if enable_ipv6:
|
cg.add_build_flag("-DCONFIG_LWIP_IPV6")
|
||||||
cg.add_build_flag("-DCONFIG_LWIP_IPV6")
|
cg.add_build_flag("-DCONFIG_LWIP_IPV6_AUTOCONFIG")
|
||||||
cg.add_build_flag("-DCONFIG_LWIP_IPV6_AUTOCONFIG")
|
if CORE.is_rp2040:
|
||||||
if CORE.is_rp2040:
|
cg.add_build_flag("-DPIO_FRAMEWORK_ARDUINO_ENABLE_IPV6")
|
||||||
cg.add_build_flag("-DPIO_FRAMEWORK_ARDUINO_ENABLE_IPV6")
|
if CORE.is_esp8266:
|
||||||
if CORE.is_esp8266:
|
cg.add_build_flag("-DPIO_FRAMEWORK_ARDUINO_LWIP2_IPV6_LOW_MEMORY")
|
||||||
cg.add_build_flag("-DPIO_FRAMEWORK_ARDUINO_LWIP2_IPV6_LOW_MEMORY")
|
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include "esphome/core/defines.h"
|
||||||
|
#ifdef USE_NETWORK
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
@ -140,3 +142,4 @@ using IPAddresses = std::array<IPAddress, 5>;
|
||||||
|
|
||||||
} // namespace network
|
} // namespace network
|
||||||
} // namespace esphome
|
} // namespace esphome
|
||||||
|
#endif
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include "esphome/core/defines.h"
|
||||||
|
#ifdef USE_NETWORK
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "ip_address.h"
|
#include "ip_address.h"
|
||||||
|
|
||||||
|
@ -16,3 +17,4 @@ IPAddresses get_ip_addresses();
|
||||||
|
|
||||||
} // namespace network
|
} // namespace network
|
||||||
} // namespace esphome
|
} // namespace esphome
|
||||||
|
#endif
|
||||||
|
|
|
@ -79,7 +79,7 @@ class PartitionLightOutput : public light::AddressableLight {
|
||||||
int32_t seg_off = index - seg.get_dst_offset();
|
int32_t seg_off = index - seg.get_dst_offset();
|
||||||
// offset within the src
|
// offset within the src
|
||||||
int32_t src_off;
|
int32_t src_off;
|
||||||
if (seg.is_reversed()) {
|
if (seg.is_reversed()) { // NOLINT(bugprone-branch-clone)
|
||||||
src_off = seg.get_src_offset() + seg.get_size() - seg_off - 1;
|
src_off = seg.get_src_offset() + seg.get_size() - seg_off - 1;
|
||||||
} else {
|
} else {
|
||||||
src_off = seg.get_src_offset() + seg_off;
|
src_off = seg.get_src_offset() + seg_off;
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "esphome/core/defines.h"
|
||||||
|
#ifdef USE_WIFI
|
||||||
#include "esphome/components/network/ip_address.h"
|
#include "esphome/components/network/ip_address.h"
|
||||||
#include "esphome/core/automation.h"
|
#include "esphome/core/automation.h"
|
||||||
#include "esphome/core/component.h"
|
#include "esphome/core/component.h"
|
||||||
#include "esphome/core/defines.h"
|
|
||||||
#include "esphome/core/helpers.h"
|
#include "esphome/core/helpers.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
@ -442,3 +443,4 @@ template<typename... Ts> class WiFiDisableAction : public Action<Ts...> {
|
||||||
|
|
||||||
} // namespace wifi
|
} // namespace wifi
|
||||||
} // namespace esphome
|
} // namespace esphome
|
||||||
|
#endif
|
||||||
|
|
|
@ -50,7 +50,6 @@
|
||||||
#define USE_LVGL_ROTARY_ENCODER
|
#define USE_LVGL_ROTARY_ENCODER
|
||||||
#define USE_MDNS
|
#define USE_MDNS
|
||||||
#define USE_MEDIA_PLAYER
|
#define USE_MEDIA_PLAYER
|
||||||
#define USE_MQTT
|
|
||||||
#define USE_NEXTION_TFT_UPLOAD
|
#define USE_NEXTION_TFT_UPLOAD
|
||||||
#define USE_NUMBER
|
#define USE_NUMBER
|
||||||
#define USE_ONLINE_IMAGE_PNG_SUPPORT
|
#define USE_ONLINE_IMAGE_PNG_SUPPORT
|
||||||
|
@ -72,8 +71,14 @@
|
||||||
#define USE_UART_DEBUGGER
|
#define USE_UART_DEBUGGER
|
||||||
#define USE_UPDATE
|
#define USE_UPDATE
|
||||||
#define USE_VALVE
|
#define USE_VALVE
|
||||||
|
|
||||||
|
// Things which do not work for zephyr
|
||||||
|
#ifndef USE_ZEPHYR
|
||||||
|
#define USE_MQTT
|
||||||
|
#define USE_NETWORK
|
||||||
#define USE_WIFI
|
#define USE_WIFI
|
||||||
#define USE_WIFI_AP
|
#define USE_WIFI_AP
|
||||||
|
#endif
|
||||||
|
|
||||||
// Arduino-specific feature flags
|
// Arduino-specific feature flags
|
||||||
#ifdef USE_ARDUINO
|
#ifdef USE_ARDUINO
|
||||||
|
|
|
@ -236,7 +236,44 @@ def main():
|
||||||
files = split_list(files, args.split_num)[args.split_at - 1]
|
files = split_list(files, args.split_num)[args.split_at - 1]
|
||||||
|
|
||||||
if args.all_headers and args.split_at in (None, 1):
|
if args.all_headers and args.split_at in (None, 1):
|
||||||
build_all_include()
|
triplet = os.path.basename(idedata["cxx_path"])[:-4]
|
||||||
|
exclude_components = []
|
||||||
|
if "zephyr" in triplet:
|
||||||
|
exclude_components = [
|
||||||
|
"api",
|
||||||
|
"web_server_base",
|
||||||
|
"web_server",
|
||||||
|
"prometheus",
|
||||||
|
"captive_portal",
|
||||||
|
"socket",
|
||||||
|
"voice_assistant",
|
||||||
|
"homeassistant",
|
||||||
|
"bluetooth_proxy",
|
||||||
|
"wake_on_lan",
|
||||||
|
"esphome",
|
||||||
|
"e131",
|
||||||
|
"haier",
|
||||||
|
"improv_serial",
|
||||||
|
"lvgl",
|
||||||
|
"fingerprint_grow",
|
||||||
|
"md5",
|
||||||
|
"mlx90393",
|
||||||
|
"mqtt",
|
||||||
|
"online_image",
|
||||||
|
"sgp4x",
|
||||||
|
"wireguard",
|
||||||
|
"tuya",
|
||||||
|
"status",
|
||||||
|
"nextion",
|
||||||
|
"mqtt",
|
||||||
|
"improv_base",
|
||||||
|
"http_request",
|
||||||
|
"ota",
|
||||||
|
"wifi_info",
|
||||||
|
"wifi_signal",
|
||||||
|
"bedjet",
|
||||||
|
]
|
||||||
|
build_all_include(exclude_components)
|
||||||
files.insert(0, temp_header_file)
|
files.insert(0, temp_header_file)
|
||||||
|
|
||||||
tmpdir = None
|
tmpdir = None
|
||||||
|
|
|
@ -29,7 +29,7 @@ def print_error_for_file(file, body):
|
||||||
print()
|
print()
|
||||||
|
|
||||||
|
|
||||||
def build_all_include():
|
def build_all_include(exclude_components):
|
||||||
# Build a cpp file that includes all header files in this repo.
|
# Build a cpp file that includes all header files in this repo.
|
||||||
# Otherwise header-only integrations would not be tested by clang-tidy
|
# Otherwise header-only integrations would not be tested by clang-tidy
|
||||||
headers = []
|
headers = []
|
||||||
|
@ -37,6 +37,9 @@ def build_all_include():
|
||||||
filetypes = (".h",)
|
filetypes = (".h",)
|
||||||
ext = os.path.splitext(path)[1]
|
ext = os.path.splitext(path)[1]
|
||||||
if ext in filetypes:
|
if ext in filetypes:
|
||||||
|
parts = path.split("/components/")
|
||||||
|
if len(parts) > 1 and parts[1].split("/")[0] in exclude_components:
|
||||||
|
continue
|
||||||
path = os.path.relpath(path, root_path)
|
path = os.path.relpath(path, root_path)
|
||||||
include_p = path.replace(os.path.sep, "/")
|
include_p = path.replace(os.path.sep, "/")
|
||||||
headers.append(f'#include "{include_p}"')
|
headers.append(f'#include "{include_p}"')
|
||||||
|
|
Loading…
Reference in a new issue