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:
|
for path in file_paths:
|
||||||
try:
|
try:
|
||||||
with open(path, "r", encoding="utf-8") as f:
|
with open(path, "r", encoding="utf-8") as f:
|
||||||
lines = f.readlines()
|
lines = files.read().splitlines()
|
||||||
error_lines = []
|
error_lines = [idx if line.endswith(" ") for idx, line in enumerate(lines, start=1)]
|
||||||
for idx, line in enumerate(lines, start=1):
|
|
||||||
if line.rstrip("\n") != line.rstrip():
|
|
||||||
error_lines.append(idx)
|
|
||||||
if error_lines:
|
if error_lines:
|
||||||
issues[path] = error_lines
|
issues[path] = error_lines
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@@ -57,10 +54,7 @@ def check_tabs(file_paths):
|
|||||||
try:
|
try:
|
||||||
with open(path, "r", encoding="utf-8") as f:
|
with open(path, "r", encoding="utf-8") as f:
|
||||||
lines = f.readlines()
|
lines = f.readlines()
|
||||||
tab_lines = []
|
tab_lines = [idx if "\t" in line for idx, line in enumerate(lines, start=1)]
|
||||||
for idx, line in enumerate(lines, start=1):
|
|
||||||
if "\t" in line:
|
|
||||||
tab_lines.append(idx)
|
|
||||||
if tab_lines:
|
if tab_lines:
|
||||||
issues[path] = tab_lines
|
issues[path] = tab_lines
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
Reference in New Issue
Block a user