mirror of
https://github.com/esphome/esphome.git
synced 2025-09-16 18:22:22 +01:00
[ruff] Enable PERF rules and fix all violations (#9874)
This commit is contained in:
@@ -66,9 +66,10 @@ def main():
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
files = []
|
||||
for path in git_ls_files(["*.cpp", "*.h", "*.tcc"]):
|
||||
files.append(os.path.relpath(path, os.getcwd()))
|
||||
cwd = os.getcwd()
|
||||
files = [
|
||||
os.path.relpath(path, cwd) for path in git_ls_files(["*.cpp", "*.h", "*.tcc"])
|
||||
]
|
||||
|
||||
if args.files:
|
||||
# Match against files specified on command-line
|
||||
|
@@ -219,9 +219,8 @@ def main():
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
files = []
|
||||
for path in git_ls_files(["*.cpp"]):
|
||||
files.append(os.path.relpath(path, os.getcwd()))
|
||||
cwd = os.getcwd()
|
||||
files = [os.path.relpath(path, cwd) for path in git_ls_files(["*.cpp"])]
|
||||
|
||||
# Print initial file count if it's large
|
||||
if len(files) > 50:
|
||||
|
@@ -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):
|
||||
|
Reference in New Issue
Block a user