Apply suggestions from code review

Co-authored-by: Benjamin Bræstrup Sayoc <benj5378@outlook.com>
This commit is contained in:
João Matos
2025-03-02 19:47:55 +00:00
committed by GitHub
parent 5d97c20cc7
commit 5e72c0afe5

View File

@@ -35,11 +35,8 @@ def check_trailing_whitespace(file_paths):
for path in file_paths:
try:
with open(path, "r", encoding="utf-8") as f:
lines = f.readlines()
error_lines = []
for idx, line in enumerate(lines, start=1):
if line.rstrip("\n") != line.rstrip():
error_lines.append(idx)
lines = files.read().splitlines()
error_lines = [idx if line.endswith(" ") for idx, line in enumerate(lines, start=1)]
if error_lines:
issues[path] = error_lines
except Exception as e:
@@ -57,10 +54,7 @@ def check_tabs(file_paths):
try:
with open(path, "r", encoding="utf-8") as f:
lines = f.readlines()
tab_lines = []
for idx, line in enumerate(lines, start=1):
if "\t" in line:
tab_lines.append(idx)
tab_lines = [idx if "\t" in line for idx, line in enumerate(lines, start=1)]
if tab_lines:
issues[path] = tab_lines
except Exception as e: