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

Side by Side Diff: PRESUBMIT.py

Issue 10556015: Added presubmit warnings about base coordinate system. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 Chromium. 5 """Top-level presubmit script for Chromium.
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 gcl. 8 for more details about the presubmit API built into gcl.
9 """ 9 """
10 10
(...skipping 13 matching lines...) Expand all
24 24
25 25
26 _TEST_ONLY_WARNING = ( 26 _TEST_ONLY_WARNING = (
27 'You might be calling functions intended only for testing from\n' 27 'You might be calling functions intended only for testing from\n'
28 'production code. It is OK to ignore this warning if you know what\n' 28 'production code. It is OK to ignore this warning if you know what\n'
29 'you are doing, as the heuristics used to detect the situation are\n' 29 'you are doing, as the heuristics used to detect the situation are\n'
30 'not perfect. The commit queue will not block on this warning.\n' 30 'not perfect. The commit queue will not block on this warning.\n'
31 'Email joi@chromium.org if you have questions.') 31 'Email joi@chromium.org if you have questions.')
32 32
33 33
34 _BANNED_FUNCTIONS = (
Mark Mentovai 2012/06/15 18:50:53 I would name this _BANNED_FUNCTIONS_OBJC…
35 (
36 'addTrackingRect:',
37 ('The use of -[NSView addTrackingRect:owner:userData:assumeInside:] is'
38 'prohibited. Please use CrTrackingArea instead.',
39 'http://dev.chromium.org/developers/coding-style/cocoa-dos-and-donts',
40 ),
41 ),
42 (
43 'NSTrackingArea',
44 ('The use of NSTrackingAreas is prohibited. Please use CrTrackingArea',
45 'instead.',
46 'http://dev.chromium.org/developers/coding-style/cocoa-dos-and-donts',
47 ),
48 ),
49 (
50 'convertPointFromBase:',
51 ('The use of -[NSView convertPointFromBase:] is almost certainly wrong.',
52 'Please use |convertPoint:(point) fromView:nil| instead.',
53 'http://dev.chromium.org/developers/coding-style/cocoa-dos-and-donts',
54 ),
55 ),
56 (
57 'convertPointToBase:',
58 ('The use of -[NSView convertPointToBase:] is almost certainly wrong.',
59 'Please use |convertPoint:(point) toView:nil| instead.',
60 'http://dev.chromium.org/developers/coding-style/cocoa-dos-and-donts',
61 ),
62 ),
63 (
64 'convertRectFromBase:',
65 ('The use of -[NSView convertRectFromBase:] is almost certainly wrong.',
66 'Please use |convertRect:(point) fromView:nil| instead.',
67 'http://dev.chromium.org/developers/coding-style/cocoa-dos-and-donts',
68 ),
69 ),
70 (
71 'convertRectToBase:',
72 ('The use of -[NSView convertRectToBase:] is almost certainly wrong.',
73 'Please use |convertRect:(point) toView:nil| instead.',
74 'http://dev.chromium.org/developers/coding-style/cocoa-dos-and-donts',
75 ),
76 ),
77 (
78 'convertSizeFromBase:',
79 ('The use of -[NSView convertSizeFromBase:] is almost certainly wrong.',
80 'Please use |convertSize:(point) fromView:nil| instead.',
81 'http://dev.chromium.org/developers/coding-style/cocoa-dos-and-donts',
82 ),
83 ),
84 (
85 'convertSizeToBase:',
86 ('The use of -[NSView convertSizeToBase:] is almost certainly wrong.',
87 'Please use |convertSize:(point) toView:nil| instead.',
88 'http://dev.chromium.org/developers/coding-style/cocoa-dos-and-donts',
89 ),
90 ),
91 )
92
93
34 94
35 def _CheckNoInterfacesInBase(input_api, output_api): 95 def _CheckNoInterfacesInBase(input_api, output_api):
36 """Checks to make sure no files in libbase.a have |@interface|.""" 96 """Checks to make sure no files in libbase.a have |@interface|."""
37 pattern = input_api.re.compile(r'^\s*@interface', input_api.re.MULTILINE) 97 pattern = input_api.re.compile(r'^\s*@interface', input_api.re.MULTILINE)
38 files = [] 98 files = []
39 for f in input_api.AffectedSourceFiles(input_api.FilterSourceFile): 99 for f in input_api.AffectedSourceFiles(input_api.FilterSourceFile):
40 if (f.LocalPath().startswith('base/') and 100 if (f.LocalPath().startswith('base/') and
41 not f.LocalPath().endswith('_unittest.mm')): 101 not f.LocalPath().endswith('_unittest.mm')):
42 contents = input_api.ReadFile(f) 102 contents = input_api.ReadFile(f)
43 if pattern.search(contents): 103 if pattern.search(contents):
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 if 'FilePathWatcher::Delegate' in line: 272 if 'FilePathWatcher::Delegate' in line:
213 problems.append(' %s:%d' % (f.LocalPath(), line_num)) 273 problems.append(' %s:%d' % (f.LocalPath(), line_num))
214 274
215 if not problems: 275 if not problems:
216 return [] 276 return []
217 return [output_api.PresubmitPromptWarning('New code should not use ' 277 return [output_api.PresubmitPromptWarning('New code should not use '
218 'FilePathWatcher::Delegate. Use the callback interface instead.\n' + 278 'FilePathWatcher::Delegate. Use the callback interface instead.\n' +
219 '\n'.join(problems))] 279 '\n'.join(problems))]
220 280
221 281
282 def _CheckNoBannedFunctions(input_api, output_api):
283 """Make sure that banned functions are not used."""
284 problems = []
285
286 file_filter = lambda f: f.LocalPath().endswith(('.cc', '.mm', '.h'))
Mark Mentovai 2012/06/15 18:50:53 …and omit .cc but include .m.
Avi (use Gerrit) 2012/06/15 18:55:24 I did it this way deliberately. I wanted a general
Mark Mentovai 2012/06/15 18:58:25 Avi wrote:
287 for f in input_api.AffectedFiles(file_filter=file_filter):
288 for line_num, line in f.ChangedContents():
289 for func_name, message in _BANNED_FUNCTIONS:
290 if func_name in line:
291 problems.append(' %s:%d:' % (f.LocalPath(), line_num))
292 for message_line in message:
293 problems.append(' %s' % message_line)
294
295 if not problems:
296 return []
297 return [output_api.PresubmitPromptWarning('Banned functions were used.\n' +
298 '\n'.join(problems))]
299
300
301
222 def _CommonChecks(input_api, output_api): 302 def _CommonChecks(input_api, output_api):
223 """Checks common to both upload and commit.""" 303 """Checks common to both upload and commit."""
224 results = [] 304 results = []
225 results.extend(input_api.canned_checks.PanProjectChecks( 305 results.extend(input_api.canned_checks.PanProjectChecks(
226 input_api, output_api, excluded_paths=_EXCLUDED_PATHS)) 306 input_api, output_api, excluded_paths=_EXCLUDED_PATHS))
227 results.extend(_CheckNoInterfacesInBase(input_api, output_api)) 307 results.extend(_CheckNoInterfacesInBase(input_api, output_api))
228 results.extend(_CheckAuthorizedAuthor(input_api, output_api)) 308 results.extend(_CheckAuthorizedAuthor(input_api, output_api))
229 results.extend( 309 results.extend(
230 _CheckNoProductionCodeUsingTestOnlyFunctions(input_api, output_api)) 310 _CheckNoProductionCodeUsingTestOnlyFunctions(input_api, output_api))
231 results.extend(_CheckNoIOStreamInHeaders(input_api, output_api)) 311 results.extend(_CheckNoIOStreamInHeaders(input_api, output_api))
232 results.extend(_CheckNoNewWStrings(input_api, output_api)) 312 results.extend(_CheckNoNewWStrings(input_api, output_api))
233 results.extend(_CheckNoDEPSGIT(input_api, output_api)) 313 results.extend(_CheckNoDEPSGIT(input_api, output_api))
234 results.extend(_CheckNoFRIEND_TEST(input_api, output_api)) 314 results.extend(_CheckNoFRIEND_TEST(input_api, output_api))
235 results.extend(_CheckNoScopedAllowIO(input_api, output_api)) 315 results.extend(_CheckNoScopedAllowIO(input_api, output_api))
236 results.extend(_CheckNoFilePathWatcherDelegate(input_api, output_api)) 316 results.extend(_CheckNoFilePathWatcherDelegate(input_api, output_api))
317 results.extend(_CheckNoBannedFunctions(input_api, output_api))
237 return results 318 return results
238 319
239 320
240 def _CheckSubversionConfig(input_api, output_api): 321 def _CheckSubversionConfig(input_api, output_api):
241 """Verifies the subversion config file is correctly setup. 322 """Verifies the subversion config file is correctly setup.
242 323
243 Checks that autoprops are enabled, returns an error otherwise. 324 Checks that autoprops are enabled, returns an error otherwise.
244 """ 325 """
245 join = input_api.os_path.join 326 join = input_api.os_path.join
246 if input_api.platform == 'win32': 327 if input_api.platform == 'win32':
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 for non_android_re in (aura_re, win_re): 448 for non_android_re in (aura_re, win_re):
368 if all(re.search(non_android_re, f) for f in affected_files): 449 if all(re.search(non_android_re, f) for f in affected_files):
369 possibly_android = False 450 possibly_android = False
370 break 451 break
371 if possibly_android: 452 if possibly_android:
372 for f in change.AffectedFiles(): 453 for f in change.AffectedFiles():
373 if any(re.search(r, f.LocalPath()) for r in android_re_list): 454 if any(re.search(r, f.LocalPath()) for r in android_re_list):
374 preferred.append('android') 455 preferred.append('android')
375 break 456 break
376 return preferred 457 return preferred
OLDNEW
« 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