1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-03 03:42:20 +01:00

[ruff] Enable PERF rules and fix all violations (#9874)

This commit is contained in:
J. Nick Koston
2025-07-25 08:15:54 -10:00
committed by GitHub
parent 88ccde4ba1
commit f808c38f10
18 changed files with 90 additions and 96 deletions

View File

@@ -41,11 +41,12 @@ CONFIG_NEWLIB_LIBC=y
return include_paths
def extract_defines(command):
defines = []
define_pattern = re.compile(r"-D\s*([^\s]+)")
for match in define_pattern.findall(command):
if match not in ("_ASMLANGUAGE"):
defines.append(match)
defines = [
match
for match in define_pattern.findall(command)
if match not in ("_ASMLANGUAGE")
]
return defines
def find_cxx_path(commands):
@@ -78,13 +79,14 @@ CONFIG_NEWLIB_LIBC=y
return include_paths
def extract_cxx_flags(command):
flags = []
# Extracts CXXFLAGS from the command string, excluding includes and defines.
flag_pattern = re.compile(
r"(-O[0-3s]|-g|-std=[^\s]+|-Wall|-Wextra|-Werror|--[^\s]+|-f[^\s]+|-m[^\s]+|-imacros\s*[^\s]+)"
)
for match in flag_pattern.findall(command):
flags.append(match.replace("-imacros ", "-imacros"))
flags = [
match.replace("-imacros ", "-imacros")
for match in flag_pattern.findall(command)
]
return flags
def transform_to_idedata_format(compile_commands):