Chromium Code Reviews| Index: tools/presubmit.py |
| diff --git a/tools/presubmit.py b/tools/presubmit.py |
| index c191fc7497045d86794078badcb5b685b278ea77..e3bc1559e2d1575bcf78c4cfae49f580a7da9ae4 100755 |
| --- a/tools/presubmit.py |
| +++ b/tools/presubmit.py |
| @@ -231,11 +231,11 @@ COPYRIGHT_HEADER_PATTERN = re.compile( |
| class SourceProcessor(SourceFileProcessor): |
| """ |
| - Check that all files include a copyright notice. |
| + Check that all files include a copyright notice and trailing whitespaces. |
|
Jakob Kummerow
2011/09/01 09:29:46
you mean "and *no* trailing whitespace", right?
|
| """ |
| RELEVANT_EXTENSIONS = ['.js', '.cc', '.h', '.py', '.c', 'SConscript', |
| - 'SConstruct', '.status'] |
| + 'SConstruct', '.status', '.gyp', '.gypi'] |
| def IsRelevant(self, name): |
| for ext in SourceProcessor.RELEVANT_EXTENSIONS: |
| if name.endswith(ext): |
| @@ -273,6 +273,18 @@ class SourceProcessor(SourceFileProcessor): |
| if not COPYRIGHT_HEADER_PATTERN.search(contents): |
| print "%s is missing a correct copyright header." % name |
| result = False |
| + if ' \n' in contents or contents.endswith(' '): |
|
Jakob Kummerow
2011/09/01 09:29:46
The "contents.endswith(' ')" case isn't handled be
|
| + line = 0 |
| + lines = [] |
| + for part in contents.split(' \n')[0:-1]: |
| + line += part.count('\n') + 1; |
| + lines.append(str(line)); |
| + linenumbers = ', '.join(lines); |
| + if len(lines) > 1: |
| + print "%s has trailing whitespaces in lines: %s" % (name, linenumbers) |
|
Kevin Millikin (Chromium)
2011/09/01 09:32:21
There is already a check for trailing whitespace f
|
| + else: |
| + print "%s has trailing whitespaces in line %s" % (name, linenumbers) |
| + result = False |
| return result |
| def ProcessFiles(self, files, path): |