From 322128a77126464dc189bda7d0b52e06bf4ec5bc Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Fri, 31 May 2013 14:51:37 -0400 Subject: [PATCH] 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) --- tools/check-all | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tools/check-all b/tools/check-all index 190382fa08..4c44191e74 100755 --- a/tools/check-all +++ b/tools/check-all @@ -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)