summaryrefslogtreecommitdiffstats
path: root/misc
diff options
context:
space:
mode:
authorJan Niklas Hasse <jhasse@bixense.com>2019-04-17 16:04:28 (GMT)
committerJan Niklas Hasse <jhasse@bixense.com>2019-04-17 16:04:54 (GMT)
commit71b96489325e5e2629464687c60f20d9905ab51c (patch)
tree8ab2373f170b346ebd018c8e70ff43699b29f716 /misc
parentb344c799788426b3b26eabcbef5728955e8e2703 (diff)
downloadNinja-71b96489325e5e2629464687c60f20d9905ab51c.zip
Ninja-71b96489325e5e2629464687c60f20d9905ab51c.tar.gz
Ninja-71b96489325e5e2629464687c60f20d9905ab51c.tar.bz2
Remove trailing whitespace from all files
Diffstat (limited to 'misc')
-rwxr-xr-xmisc/ci.py41
1 files changed, 41 insertions, 0 deletions
diff --git a/misc/ci.py b/misc/ci.py
new file mode 100755
index 0000000..17cbf14
--- /dev/null
+++ b/misc/ci.py
@@ -0,0 +1,41 @@
+#!/usr/bin/env python3
+
+import os
+
+ignores = [
+ '.git/',
+ 'misc/afl-fuzz-tokens/',
+ 'ninja_deps',
+ 'src/depfile_parser.cc',
+ 'src/lexer.cc',
+]
+
+error_count = 0
+
+def error(path, msg):
+ global error_count
+ error_count += 1
+ print('\x1b[1;31m{}\x1b[0;31m{}\x1b[0m'.format(path, msg))
+
+for root, directory, filenames in os.walk('.'):
+ for filename in filenames:
+ path = os.path.join(root, filename)[2:]
+ if any([path.startswith(x) for x in ignores]):
+ continue
+ with open(path, 'rb') as file:
+ line_nr = 1
+ try:
+ for line in [x.decode() for x in file.readlines()]:
+ if len(line) == 0 or line[-1] != '\n':
+ error(path, ' missing newline at end of file.')
+ if len(line) > 1:
+ if line[-2] == '\r':
+ error(path, ' has Windows line endings.')
+ break
+ if line[-2] == ' ' or line[-2] == '\t':
+ error(path, ':{} has trailing whitespace.'.format(line_nr))
+ line_nr += 1
+ except UnicodeError:
+ pass # binary file
+
+exit(error_count)