From d93c3233fef401b79aa0f5e9617308b8a0d32da3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Matos?= Date: Sun, 2 Mar 2025 19:47:55 +0000 Subject: [PATCH] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Benjamin Bræstrup Sayoc --- tools/lint/generic_checks.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/tools/lint/generic_checks.py b/tools/lint/generic_checks.py index 25f1a2d794..b7eb19675f 100755 --- a/tools/lint/generic_checks.py +++ b/tools/lint/generic_checks.py @@ -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: