Apply suggestions from code review
Co-authored-by: Benjamin Bræstrup Sayoc <benj5378@outlook.com>
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user