Check for whitespace in check-all.

Exit with a failing status if any of your
non-excluded JS/Python files have trailing whitespace.

(imported from commit 0aa184fa85a4a1ddeef6ea40dff57ce43c10e459)
This commit is contained in:
Steve Howell 2013-05-31 14:51:37 -04:00
parent 303b8174ac
commit 322128a771
1 changed files with 9 additions and 1 deletions

View File

@ -55,8 +55,11 @@ for filepath in git_files:
by_lang[exn].append(filepath)
def has_trailing_whitespace(fn):
return any(re.search('\s+$', line.strip('\n')) for line in open(fn))
# Invoke the appropriate lint checker for each language
# Invoke the appropriate lint checker for each language,
# and also check files for extra whitespace.
try:
failed = False
@ -71,6 +74,11 @@ try:
except subprocess.CalledProcessError:
failed = True
for fn in by_lang['.js'] + by_lang['.py']:
if has_trailing_whitespace(fn):
sys.stdout.write('Fix whitespace in %s\n' % fn)
failed = True
pyflakes = subprocess.Popen(['pyflakes'] + by_lang['.py'],
stdout = subprocess.PIPE,
stderr = subprocess.PIPE)