OLD | NEW |
1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 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 """Presubmit script for ui. | 5 """Presubmit script for ui. |
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 14 matching lines...) Expand all Loading... |
25 # return scoped_ptr<T>(foo); | 25 # return scoped_ptr<T>(foo); |
26 # bar = scoped_ptr<T>(foo); | 26 # bar = scoped_ptr<T>(foo); |
27 # But allow: | 27 # But allow: |
28 # return scoped_ptr<T[]>(foo); | 28 # return scoped_ptr<T[]>(foo); |
29 # bar = scoped_ptr<T[]>(foo); | 29 # bar = scoped_ptr<T[]>(foo); |
30 if input_api.re.search( | 30 if input_api.re.search( |
31 r'(=|\breturn)\s*scoped_ptr<[^\[\]>]+>\([^)]+\)', line): | 31 r'(=|\breturn)\s*scoped_ptr<[^\[\]>]+>\([^)]+\)', line): |
32 errors.append(output_api.PresubmitError( | 32 errors.append(output_api.PresubmitError( |
33 ('%s:%d uses explicit scoped_ptr constructor. ' + | 33 ('%s:%d uses explicit scoped_ptr constructor. ' + |
34 'Use make_scoped_ptr() instead.') % (f.LocalPath(), line_number))) | 34 'Use make_scoped_ptr() instead.') % (f.LocalPath(), line_number))) |
| 35 # TODO(sky): this incorrectly catches templates. Fix and reenable. |
35 # Disallow: | 36 # Disallow: |
36 # scoped_ptr<T>() | 37 # scoped_ptr<T>() |
37 if input_api.re.search(r'\bscoped_ptr<.*?>\(\)', line): | 38 # if input_api.re.search(r'\bscoped_ptr<.*?>\(\)', line): |
38 errors.append(output_api.PresubmitError( | 39 # errors.append(output_api.PresubmitError( |
39 '%s:%d uses scoped_ptr<T>(). Use nullptr instead.' % | 40 # '%s:%d uses scoped_ptr<T>(). Use nullptr instead.' % |
40 (f.LocalPath(), line_number))) | 41 # (f.LocalPath(), line_number))) |
41 return errors | 42 return errors |
42 | 43 |
43 | 44 |
44 def CheckChange(input_api, output_api): | 45 def CheckChange(input_api, output_api): |
45 results = [] | 46 results = [] |
46 results += CheckScopedPtr(input_api, output_api) | 47 results += CheckScopedPtr(input_api, output_api) |
47 return results | 48 return results |
48 | 49 |
49 | 50 |
50 def CheckChangeOnUpload(input_api, output_api): | 51 def CheckChangeOnUpload(input_api, output_api): |
51 return CheckChange(input_api, output_api) | 52 return CheckChange(input_api, output_api) |
52 | 53 |
53 | 54 |
54 def CheckChangeOnCommit(input_api, output_api): | 55 def CheckChangeOnCommit(input_api, output_api): |
55 return CheckChange(input_api, output_api) | 56 return CheckChange(input_api, output_api) |
OLD | NEW |