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

Side by Side Diff: cc/PRESUBMIT.py

Issue 609663003: cc: Remove use of PassAs() and constructor-casting with scoped_ptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cc-passas: no-base-changes Created 6 years, 2 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 unified diff | Download patch
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Top-level presubmit script for cc. 5 """Top-level presubmit script for cc.
6 6
7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts 7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
8 for more details about the presubmit API built into depot_tools. 8 for more details about the presubmit API built into depot_tools.
9 """ 9 """
10 10
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 if ('FIX'+'ME') in contents: 139 if ('FIX'+'ME') in contents:
140 errors.append(f.LocalPath()) 140 errors.append(f.LocalPath())
141 141
142 if errors: 142 if errors:
143 return [output_api.PresubmitError( 143 return [output_api.PresubmitError(
144 'All TODO comments should be of the form TODO(name). ' + 144 'All TODO comments should be of the form TODO(name). ' +
145 'Use TODO instead of FIX' + 'ME', 145 'Use TODO instead of FIX' + 'ME',
146 items=errors)] 146 items=errors)]
147 return [] 147 return []
148 148
149 def CheckScopedPtr(input_api, output_api,
150 white_list=CC_SOURCE_FILES, black_list=None):
151 black_list = tuple(black_list or input_api.DEFAULT_BLACK_LIST)
152 source_file_filter = lambda x: input_api.FilterSourceFile(x,
153 white_list,
154 black_list)
155 errors = []
156 for f in input_api.AffectedSourceFiles(source_file_filter):
157 for line_number, line in f.ChangedContents():
158 # Disallow:
159 # return scoped_ptr<T>(foo);
160 # bar = scoped_ptr<T>(foo);
161 # But allow:
162 # return scoped_ptr<T[]>(foo);
163 # bar = scoped_ptr<T[]>(foo);
164 if re.search(r'(=|\breturn)\s*scoped_ptr<[^>]*[^>\]]>\([^)]+\)', line):
enne (OOO) 2014/09/26 16:58:22 regex nits: matching non-greedily, [^>]*> is clea
165 errors.append(output_api.PresubmitError(
166 ('%s:%d uses explicit scoped_ptr constructor. ' +
167 'Use make_scoped_ptr() instead.') % (f.LocalPath(), line_number)))
168 # Disallow:
169 # return scoped_ptr<T>();
170 # bar = scoped_ptr<T>();
171 if re.search(r'(=|\breturn)\s*scoped_ptr<[^>+]>\(\)', line):
vmpstr 2014/09/26 16:44:23 ... [^>]+ ... ?
danakj 2014/09/26 16:56:44 That matches the T in scoped_ptr<T> It doesn't ha
enne (OOO) 2014/09/26 16:58:22 I think this is wrong; did you intend for the + to
172 errors.append(output_api.PresubmitError(
173 '%s:%d uses scoped_ptr<T>(). Use nullptr instead.' %
174 (f.LocalPath(), line_number)))
175 return errors
176
149 def FindUnquotedQuote(contents, pos): 177 def FindUnquotedQuote(contents, pos):
150 match = re.search(r"(?<!\\)(?P<quote>\")", contents[pos:]) 178 match = re.search(r"(?<!\\)(?P<quote>\")", contents[pos:])
151 return -1 if not match else match.start("quote") + pos 179 return -1 if not match else match.start("quote") + pos
152 180
153 def FindUselessIfdefs(input_api, output_api): 181 def FindUselessIfdefs(input_api, output_api):
154 errors = [] 182 errors = []
155 source_file_filter = lambda x: x 183 source_file_filter = lambda x: x
156 for f in input_api.AffectedSourceFiles(source_file_filter): 184 for f in input_api.AffectedSourceFiles(source_file_filter):
157 contents = input_api.ReadFile(f, 'rb') 185 contents = input_api.ReadFile(f, 'rb')
158 if re.search(r'#if\s*0\s', contents): 186 if re.search(r'#if\s*0\s', contents):
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 else: 307 else:
280 return [] 308 return []
281 309
282 def CheckChangeOnUpload(input_api, output_api): 310 def CheckChangeOnUpload(input_api, output_api):
283 results = [] 311 results = []
284 results += CheckAsserts(input_api, output_api) 312 results += CheckAsserts(input_api, output_api)
285 results += CheckStdAbs(input_api, output_api) 313 results += CheckStdAbs(input_api, output_api)
286 results += CheckPassByValue(input_api, output_api) 314 results += CheckPassByValue(input_api, output_api)
287 results += CheckChangeLintsClean(input_api, output_api) 315 results += CheckChangeLintsClean(input_api, output_api)
288 results += CheckTodos(input_api, output_api) 316 results += CheckTodos(input_api, output_api)
317 results += CheckScopedPtr(input_api, output_api)
289 results += CheckNamespace(input_api, output_api) 318 results += CheckNamespace(input_api, output_api)
290 results += CheckForUseOfWrongClock(input_api, output_api) 319 results += CheckForUseOfWrongClock(input_api, output_api)
291 results += FindUselessIfdefs(input_api, output_api) 320 results += FindUselessIfdefs(input_api, output_api)
292 results += input_api.canned_checks.CheckPatchFormatted(input_api, output_api) 321 results += input_api.canned_checks.CheckPatchFormatted(input_api, output_api)
293 return results 322 return results
294 323
295 def GetPreferredTryMasters(project, change): 324 def GetPreferredTryMasters(project, change):
296 return { 325 return {
297 'tryserver.blink': { 326 'tryserver.blink': {
298 'linux_blink_rel': set(['defaulttests']), 327 'linux_blink_rel': set(['defaulttests']),
299 }, 328 },
300 'tryserver.chromium.gpu': { 329 'tryserver.chromium.gpu': {
301 'linux_gpu': set(['defaulttests']), 330 'linux_gpu': set(['defaulttests']),
302 'mac_gpu': set(['defaulttests']), 331 'mac_gpu': set(['defaulttests']),
303 'win_gpu': set(['defaulttests']), 332 'win_gpu': set(['defaulttests']),
304 }, 333 },
305 } 334 }
OLDNEW
« no previous file with comments | « no previous file | cc/animation/animation_unittest.cc » ('j') | cc/animation/keyframed_animation_curve.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698