check-style: Fix trailing whitespace column indicator in verbose mode

This commit is contained in:
Eduardo Almeida
2023-09-06 23:08:17 +01:00
parent 2f62a518a9
commit 5e5f3746db

View File

@@ -489,10 +489,12 @@ def check_trailing_whitespace_file(filename: str,
file_lines[i] = line_fixed
if verbose:
line_fixed_stripped_expanded = line_fixed.rstrip().expandtabs(TAB_SIZE)
verbose_infos.extend([
f'{filename}:{i + 1}: error: Trailing whitespace detected',
f' {line_fixed.rstrip()}',
f' {"":{len(line_fixed) - 1}}^',
f'{filename}:{i + 1}:{len(line_fixed_stripped_expanded) + 1}: error: Trailing whitespace detected',
f' {line_fixed_stripped_expanded}',
f' {"":{len(line_fixed_stripped_expanded)}}^',
])
# Optimization: If running in non-verbose check mode, only one error is needed to check that the file is not compliant