Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(380)

Unified Diff: tools/presubmit.py

Issue 7826007: Added check for trailing whitespaces and corrected existing violations. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Yet another iteration. Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/gdb-v8-support.py ('k') | tools/process-heap-prof.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/presubmit.py
diff --git a/tools/presubmit.py b/tools/presubmit.py
index c191fc7497045d86794078badcb5b685b278ea77..7b4719f4762725a0771bae77eddac28a031a456d 100755
--- a/tools/presubmit.py
+++ b/tools/presubmit.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
-# Copyright 2008 the V8 project authors. All rights reserved.
+# Copyright 2011 the V8 project authors. All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
@@ -88,7 +88,6 @@ whitespace/blank_line
whitespace/braces
whitespace/comma
whitespace/comments
-whitespace/end_of_line
whitespace/ending_newline
whitespace/indent
whitespace/labels
@@ -231,11 +230,12 @@ 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 no trailing whitespaces.
"""
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,22 @@ class SourceProcessor(SourceFileProcessor):
if not COPYRIGHT_HEADER_PATTERN.search(contents):
print "%s is missing a correct copyright header." % name
result = False
+ ext = base.split('.').pop()
+ if ' \n' in contents or contents.endswith(' '):
+ line = 0
+ lines = []
+ parts = contents.split(' \n')
+ if not contents.endswith(' '):
+ parts.pop()
+ for part in parts:
+ 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)
+ else:
+ print "%s has trailing whitespaces in line %s." % (name, linenumbers)
+ result = False
return result
def ProcessFiles(self, files, path):
« no previous file with comments | « tools/gdb-v8-support.py ('k') | tools/process-heap-prof.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698