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

Unified Diff: ui/PRESUBMIT.py

Issue 919253002: ui: Add another presubmit check to catch two more scoped_ptr usages. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: import re Created 5 years, 10 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: ui/PRESUBMIT.py
diff --git a/ui/PRESUBMIT.py b/ui/PRESUBMIT.py
index 0123fc6db2e075efb67b09ea1292598e58efadeb..fa093682e68f2ce5008b3347a5effb6cc149235d 100644
--- a/ui/PRESUBMIT.py
+++ b/ui/PRESUBMIT.py
@@ -8,6 +8,8 @@ See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
for more details about the presubmit API built into depot_tools.
"""
+import re
Marc-Antoine Ruel (Google) 2015/02/13 02:16:51 not needed
+
INCLUDE_CPP_FILES_ONLY = (
r'.*\.(cc|h|mm)$',
)
@@ -22,8 +24,18 @@ def CheckScopedPtr(input_api, output_api,
for f in input_api.AffectedSourceFiles(source_file_filter):
for line_number, line in f.ChangedContents():
# Disallow:
+ # return scoped_ptr<T>(foo);
+ # bar = scoped_ptr<T>(foo);
+ # But allow:
+ # return scoped_ptr<T[]>(foo);
+ # bar = scoped_ptr<T[]>(foo);
+ if re.search(r'(=|\breturn)\s*scoped_ptr<.*?(?<!])>\([^)]+\)', line):
Marc-Antoine Ruel (Google) 2015/02/13 02:16:51 input_api.re. ... could be simplified to ... scop
tfarina 2015/02/13 02:28:40 Done.
+ errors.append(output_api.PresubmitError(
+ ('%s:%d uses explicit scoped_ptr constructor. ' +
+ 'Use make_scoped_ptr() instead.') % (f.LocalPath(), line_number)))
+ # Disallow:
# scoped_ptr<T>()
- if input_api.re.search(r'\bscoped_ptr<.*?>\(\)', line):
+ if re.search(r'\bscoped_ptr<.*?>\(\)', line):
errors.append(output_api.PresubmitError(
'%s:%d uses scoped_ptr<T>(). Use nullptr instead.' %
(f.LocalPath(), line_number)))
« 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