Commit 86a62d0d authored by yangguo@chromium.org's avatar yangguo@chromium.org

Added check for trailing whitespaces and corrected existing violations.

Review URL: http://codereview.chromium.org/7826007

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@9094 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 4e94cd8b
# Copyright (c) 2011 The Chromium Authors. All rights reserved.
# Copyright 2011 the V8 project authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
......
......@@ -29,7 +29,8 @@
// This situation can arise with sliced strings. This tests for an ARM bug
// that was fixed in r554.
var base = "Now is the time for all good men to come to the aid of the party. " +
var base =
"Now is the time for all good men to come to the aid of the party. " +
"Now is the time for all good men to come to the aid of the party."
var s1 = base.substring(0, 64);
var s2 = base.substring(66, 130);
......
#!/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):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment