Reviewers: ,

Message:
Please review a simple patch that removes trailing whitespace in python
files and adds a lint check for trailing whitespace to presubmit.py

Description:
Add a check to presubmit.py linting python and SCons files for trailing
whitespace.

BUG=82

Please review this at http://codereview.chromium.org/119239

SVN Base: http://v8.googlecode.com/svn/branches/bleeding_edge/

Affected files:
   M     SConstruct
   M     tools/js2c.py
   M     tools/presubmit.py
   M     tools/test.py


Index: tools/js2c.py
===================================================================
--- tools/js2c.py       (revision 2110)
+++ tools/js2c.py       (working copy)
@@ -291,7 +291,7 @@
        ids.append((id, len(lines)))
      source_lines.append(SOURCE_DECLARATION % { 'id': id, 'data': data })
      source_lines_empty.append(SOURCE_DECLARATION % { 'id': id, 'data': 0 })
-
+
    # Build delay support functions
    get_index_cases = [ ]
    get_script_source_cases = [ ]
Index: tools/presubmit.py
===================================================================
--- tools/presubmit.py  (revision 2110)
+++ tools/presubmit.py  (working copy)
@@ -137,7 +137,7 @@
                or (name == 'third_party'))

    IGNORE_LINT = ['flag-definitions.h']
-
+
    def IgnoreFile(self, name):
      return (super(CppLintProcessor, self).IgnoreFile(name)
                or (name in CppLintProcessor.IGNORE_LINT))
@@ -180,10 +180,12 @@
        'libraries.cc', 'libraries-empty.cc', 'jsmin.py', 'regexp-pcre.js']
    IGNORE_TABS = IGNORE_COPYRIGHTS + ['unicode-test.js',
        'html-comments.js']
+  NO_TRAILING_WHITESPACE_EXTENSIONS = ['py', 'SConscript', 'SConstruct']

    def ProcessContents(self, name, contents):
      result = True
      base = basename(name)
+    extension = base.split('.').pop()
      if not base in SourceProcessor.IGNORE_TABS:
        if '\t' in contents:
          print "%s contains tabs" % name
@@ -192,6 +194,10 @@
        if not COPYRIGHT_HEADER_PATTERN.search(contents):
          print "%s is missing a correct copyright header." % name
          result = False
+    if extension in SourceProcessor.NO_TRAILING_WHITESPACE_EXTENSIONS:
+      if ' \n' in contents or contents.endswith(' '):
+        print "%s has trailing whitespace." % name
+        result = False
      return result

    def ProcessFiles(self, files):
Index: tools/test.py
===================================================================
--- tools/test.py       (revision 2110)
+++ tools/test.py       (working copy)
@@ -390,7 +390,7 @@

    def HasTimedOut(self):
      return self.output.timed_out;
-
+
    def HasFailed(self):
      execution_failed = self.test.DidFail(self.output)
      if self.test.IsNegative():
Index: SConstruct
===================================================================
--- SConstruct  (revision 2110)
+++ SConstruct  (working copy)
@@ -638,7 +638,7 @@

  def GetVersion():
    version_components = GetVersionComponents()
-
+
    if version_components[len(version_components) - 1] == '0':
      version_components.pop()
    return '.'.join(version_components)
@@ -646,10 +646,10 @@

  def GetSpecificSONAME():
    SONAME_PATTERN = re.compile(r"#define\s+SONAME\s+\"(.*)\"")
-
+
    source = open(join(root_dir, 'src', 'version.cc')).read()
    match = SONAME_PATTERN.search(source)
-
+
    if match:
      return match.group(1).strip()
    else:



--~--~---------~--~----~------------~-------~--~----~
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
-~----------~----~----~----~------~----~------~--~---

Reply via email to