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

Side by Side Diff: base/PRESUBMIT.py

Issue 611153004: replace OVERRIDE and FINAL with override and final in base/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: CC_ -> BASE_ 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
« no previous file with comments | « no previous file | base/android/trace_event_binding.cc » ('j') | 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 """Chromium presubmit script for src/base. 5 """Chromium presubmit script for src/base.
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 on the presubmit API built into gcl. 8 for more details on the presubmit API built into gcl.
9 """ 9 """
10 10
11 import re
12
13 BASE_SOURCE_FILES=(r'^base/.*\.(cc|h|mm)$',)
14
11 def _CheckNoInterfacesInBase(input_api, output_api): 15 def _CheckNoInterfacesInBase(input_api, output_api):
12 """Checks to make sure no files in libbase.a have |@interface|.""" 16 """Checks to make sure no files in libbase.a have |@interface|."""
13 pattern = input_api.re.compile(r'^\s*@interface', input_api.re.MULTILINE) 17 pattern = input_api.re.compile(r'^\s*@interface', input_api.re.MULTILINE)
14 files = [] 18 files = []
15 for f in input_api.AffectedSourceFiles(input_api.FilterSourceFile): 19 for f in input_api.AffectedSourceFiles(input_api.FilterSourceFile):
16 if (f.LocalPath().startswith('base/') and 20 if (f.LocalPath().startswith('base/') and
17 not "/test/" in f.LocalPath() and 21 not "/test/" in f.LocalPath() and
18 not f.LocalPath().endswith('_unittest.mm') and 22 not f.LocalPath().endswith('_unittest.mm') and
19 not f.LocalPath().endswith('mac/sdk_forward_declarations.h')): 23 not f.LocalPath().endswith('mac/sdk_forward_declarations.h')):
20 contents = input_api.ReadFile(f) 24 contents = input_api.ReadFile(f)
21 if pattern.search(contents): 25 if pattern.search(contents):
22 files.append(f) 26 files.append(f)
23 27
24 if len(files): 28 if len(files):
25 return [ output_api.PresubmitError( 29 return [ output_api.PresubmitError(
26 'Objective-C interfaces or categories are forbidden in libbase. ' + 30 'Objective-C interfaces or categories are forbidden in libbase. ' +
27 'See http://groups.google.com/a/chromium.org/group/chromium-dev/' + 31 'See http://groups.google.com/a/chromium.org/group/chromium-dev/' +
28 'browse_thread/thread/efb28c10435987fd', 32 'browse_thread/thread/efb28c10435987fd',
29 files) ] 33 files) ]
30 return [] 34 return []
31 35
32 36
33 def _CommonChecks(input_api, output_api): 37 def _CommonChecks(input_api, output_api):
34 """Checks common to both upload and commit.""" 38 """Checks common to both upload and commit."""
35 results = [] 39 results = []
36 results.extend(_CheckNoInterfacesInBase(input_api, output_api)) 40 results.extend(_CheckNoInterfacesInBase(input_api, output_api))
37 return results 41 return results
38 42
43 def _CheckOverrideFinal(input_api, output_api,
44 whitelist=BASE_SOURCE_FILES, blacklist=None):
45 """Make sure new lines of code don't use the OVERRIDE or FINAL macros."""
46
47 # TODO(mostynb): remove this check once the macros are removed
48 # from base/compiler_specific.h.
49
50 errors = []
51
52 source_file_filter = lambda x: input_api.FilterSourceFile(
53 x, white_list=BASE_SOURCE_FILES, black_list=None)
54
55 override_files = []
56 final_files = []
57
58 for f in input_api.AffectedSourceFiles(source_file_filter):
59 contents = input_api.ReadFile(f, 'rb')
60
61 # "override" and "final" should be used instead of OVERRIDE/FINAL now.
62 if re.search(r"\bOVERRIDE\b", contents):
63 override_files.append(f.LocalPath())
64
65 if re.search(r"\bFINAL\b", contents):
66 final_files.append(f.LocalPath())
67
68 if override_files:
69 return [output_api.PresubmitError(
70 'These files use OVERRIDE instead of using override:',
71 items=override_files)]
72 if final_files:
73 return [output_api.PresubmitError(
74 'These files use FINAL instead of using final:',
75 items=final_files)]
76
77 return []
78
39 def CheckChangeOnUpload(input_api, output_api): 79 def CheckChangeOnUpload(input_api, output_api):
40 results = [] 80 results = []
81 results.extend(_CheckOverrideFinal(input_api, output_api))
41 results.extend(_CommonChecks(input_api, output_api)) 82 results.extend(_CommonChecks(input_api, output_api))
42 return results 83 return results
43 84
44 85
45 def CheckChangeOnCommit(input_api, output_api): 86 def CheckChangeOnCommit(input_api, output_api):
46 results = [] 87 results = []
47 results.extend(_CommonChecks(input_api, output_api)) 88 results.extend(_CommonChecks(input_api, output_api))
48 return results 89 return results
49 90
50 91
51 def GetPreferredTryMasters(project, change): 92 def GetPreferredTryMasters(project, change):
52 return { 93 return {
53 'tryserver.chromium.linux': { 94 'tryserver.chromium.linux': {
54 'linux_chromium_rel_swarming': set(['defaulttests']), 95 'linux_chromium_rel_swarming': set(['defaulttests']),
55 }, 96 },
56 'tryserver.chromium.mac': { 97 'tryserver.chromium.mac': {
57 'mac_chromium_rel_swarming': set(['defaulttests']), 98 'mac_chromium_rel_swarming': set(['defaulttests']),
58 }, 99 },
59 'tryserver.chromium.win': { 100 'tryserver.chromium.win': {
60 'win_chromium_rel_swarming': set(['defaulttests']), 101 'win_chromium_rel_swarming': set(['defaulttests']),
61 } 102 }
62 } 103 }
OLDNEW
« no previous file with comments | « no previous file | base/android/trace_event_binding.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698