Add while/until to the for/do rule

Like 'for/do' check that the while/until operator are on
the same line with the do.

Fixes some pep8 error along the way.

Change-Id: I440afe60691263365bf35310bf4212d94f30c339
(cherry picked from commit 86a8e9767912ae957cbbf6ea20a08106011a7728)
This commit is contained in:
Chmouel Boudjnah
2014-02-04 15:20:15 +01:00
committed by Mathew Odden
parent 31d83270e0
commit d2a242c864

View File

@@ -47,7 +47,7 @@ IGNORE = None
def register_ignores(ignores):
global IGNORE
if ignores:
IGNORE='^(' + '|'.join(ignores.split(',')) + ')'
IGNORE = '^(' + '|'.join(ignores.split(',')) + ')'
def should_ignore(error):
@@ -64,11 +64,15 @@ def print_error(error, line):
def not_continuation(line):
return not re.search('\\\\$', line)
def check_for_do(line):
if not_continuation(line):
if re.search('^\s*for ', line):
match = re.match('^\s*(for|while|until)\s', line)
if match:
operator = match.group(1).strip()
if not re.search(';\s*do(\b|$)', line):
print_error('E010: Do not on same line as for', line)
print_error('E010: Do not on same line as %s' % operator,
line)
def check_if_then(line):