diff --git a/Tools/scripts/patchcheck.py b/Tools/scripts/patchcheck.py --- a/Tools/scripts/patchcheck.py +++ b/Tools/scripts/patchcheck.py @@ -51,6 +51,21 @@ def normalize_whitespace(file_paths): result = map(reindent.check, (x for x in file_paths if x.endswith('.py'))) return sum(result) +@status("Checking whitespace and line length in C files, ACKS and NEWS", + info=lambda x: "%s files" % x) +def check_pep7(file_paths): + """Report tabs, trailing whitespace and long lines in .[ch], ACKS, NEWS.""" + files = (x for x in file_paths + if x.endswith(('.c', '.h')) or x in ('Misc/ACKS', 'Misc/NEWS')) + result = 0 + for filename in files: + with open(filename) as fp: + for line in fp: + if '\t' in line or line[-2].isspace() or len(line) > 80: + result += 1 + break + return result + @status("Docs modified", modal=True) def docs_modified(file_paths): """Report if any files in the Docs directory.""" @@ -74,6 +89,7 @@ def main(): file_paths = changed_files() # PEP 7/8 verification. normalize_whitespace(file_paths) + check_pep7(file_paths) # Docs updated. docs_modified(file_paths) # Misc/ACKS changed.