Complain about binary operators on the ends of lines

This commit is contained in:
w0rp
2019-02-10 11:43:48 +00:00
parent d072d2654c
commit 7a48750610
5 changed files with 26 additions and 14 deletions

View File

@@ -11,6 +11,7 @@ import re
INDENTATION_RE = re.compile(r'^ *')
COMMENT_LINE_RE = re.compile(r'^ *"')
COMMAND_RE = re.compile(r'^ *([a-zA-Z\\]+)')
OPERATOR_END_RE = re.compile(r'(&&|\|\||\+|-|\*\| /)$')
START_BLOCKS = set(['if', 'for', 'while', 'try', 'function'])
END_BLOCKS = set(['endif', 'endfor', 'endwhile', 'endtry', 'endfunction'])
@@ -70,7 +71,7 @@ def check_lines(line_iter):
if (
previous_indentation_level is not None
and indentation_level != previous_indentation_level
and abs(indentation_level - previous_indentation_level) != 4
and abs(indentation_level - previous_indentation_level) != 4 # noqa
):
yield (
line_number,
@@ -119,6 +120,12 @@ def check_lines(line_iter):
previous_line_blank = False
previous_indentation_level = indentation_level
if OPERATOR_END_RE.search(line):
yield (
line_number,
'Put operators at the start of lines instead'
)
def main():
status = 0