Add leading whitespace check
This commit is contained in:
4
build.py
4
build.py
@@ -582,6 +582,7 @@ def build_check_requires_timestamp(t):
|
||||
precious=True)
|
||||
def build_check_whitespace_timestamp(t):
|
||||
CR_RE = re.compile(r'\r')
|
||||
LEADING_WHITESPACE_RE = re.compile(r'\s+')
|
||||
TRAILING_WHITESPACE_RE = re.compile(r'\s+\n\Z')
|
||||
NO_NEWLINE_RE = re.compile(r'[^\n]\Z')
|
||||
ALL_WHITESPACE_RE = re.compile(r'\s+\Z')
|
||||
@@ -589,6 +590,9 @@ def build_check_whitespace_timestamp(t):
|
||||
for filename in sorted(t.newer(t.dependencies)):
|
||||
whitespace = False
|
||||
for lineno, line in enumerate(open(filename, 'rU')):
|
||||
if lineno == 0 and LEADING_WHITESPACE_RE.match(line):
|
||||
t.info('%s:%d: leading whitespace', filename, lineno + 1)
|
||||
errors += 1
|
||||
if CR_RE.search(line):
|
||||
t.info('%s:%d: carriage return character in line', filename, lineno + 1)
|
||||
errors += 1
|
||||
|
||||
Reference in New Issue
Block a user