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

Unified Diff: depot_tools/presubmit_canned_checks.py

Issue 7747023: Ignore C++ comments while checking for Singleton<T> in headers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/
Patch Set: '' 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: depot_tools/presubmit_canned_checks.py
===================================================================
--- depot_tools/presubmit_canned_checks.py (revision 98268)
+++ depot_tools/presubmit_canned_checks.py (working copy)
@@ -828,14 +828,21 @@
def _CheckSingletonInHeaders(input_api, output_api, source_file_filter):
"""Checks to make sure no header files have |Singleton<|."""
- pattern = input_api.re.compile(r'Singleton<')
+ pattern = input_api.re.compile(r'Singleton\s*<')
+
+ def strip_cpp_eol_comment(line):
+ pattern = input_api.re.compile(r'//.*$')
+ return pattern.sub('', line)
M-A Ruel 2011/08/26 13:12:45 I'm not sure it's useful; using "input_api.re.sub(
Denis Lagno 2011/08/26 13:31:33 Done.
+
files = []
for f in input_api.AffectedSourceFiles(source_file_filter):
if (f.LocalPath().endswith('.h') or f.LocalPath().endswith('.hxx') or
f.LocalPath().endswith('.hpp') or f.LocalPath().endswith('.inl')):
contents = input_api.ReadFile(f)
- if pattern.search(contents):
- files.append(f)
+ for line in contents.splitlines(False):
+ if pattern.search(strip_cpp_eol_comment(line)):
+ files.append(f)
+ break
if files:
return [ output_api.PresubmitError(
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698