Chromium Code Reviews| 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 13 matching lines...) Expand all Loading... | |
| 24 # Disallow: | 24 # Disallow: |
| 25 # return std::unique_ptr<T>(foo); | 25 # return std::unique_ptr<T>(foo); |
| 26 # bar = std::unique_ptr<T>(foo); | 26 # bar = std::unique_ptr<T>(foo); |
| 27 # But allow: | 27 # But allow: |
| 28 # return std::unique_ptr<T[]>(foo); | 28 # return std::unique_ptr<T[]>(foo); |
| 29 # bar = std::unique_ptr<T[]>(foo); | 29 # bar = std::unique_ptr<T[]>(foo); |
| 30 if input_api.re.search( | 30 if input_api.re.search( |
| 31 r'(=|\breturn)\s*std::unique_ptr<[^\[\]>]+>\([^)]+\)', line): | 31 r'(=|\breturn)\s*std::unique_ptr<[^\[\]>]+>\([^)]+\)', line): |
| 32 errors.append(output_api.PresubmitError( | 32 errors.append(output_api.PresubmitError( |
| 33 ('%s:%d uses explicit std::unique_ptr constructor. ' + | 33 ('%s:%d uses explicit std::unique_ptr constructor. ' + |
| 34 'Use base::WrapUnique() instead.') % (f.LocalPath(), line_number))) | 34 'Use base::MakeUnique<T>() instead.') % |
|
sky
2016/09/02 14:17:44
This wording is not correct as it implies MakeUniq
Adam Rice
2016/09/05 06:46:05
Fixed.
| |
| 35 (f.LocalPath(), line_number))) | |
| 35 # TODO(sky): this incorrectly catches templates. Fix and reenable. | 36 # TODO(sky): this incorrectly catches templates. Fix and reenable. |
| 36 # Disallow: | 37 # Disallow: |
| 37 # std::unique_ptr<T>() | 38 # std::unique_ptr<T>() |
| 38 # if input_api.re.search(r'\bstd::unique_ptr<.*?>\(\)', line): | 39 # if input_api.re.search(r'\bstd::unique_ptr<.*?>\(\)', line): |
| 39 # errors.append(output_api.PresubmitError( | 40 # errors.append(output_api.PresubmitError( |
| 40 # '%s:%d uses std::unique_ptr<T>(). Use nullptr instead.' % | 41 # '%s:%d uses std::unique_ptr<T>(). Use nullptr instead.' % |
| 41 # (f.LocalPath(), line_number))) | 42 # (f.LocalPath(), line_number))) |
| 42 return errors | 43 return errors |
| 43 | 44 |
| 44 | 45 |
| 45 def CheckChange(input_api, output_api): | 46 def CheckChange(input_api, output_api): |
| 46 results = [] | 47 results = [] |
| 47 results += CheckUniquePtr(input_api, output_api) | 48 results += CheckUniquePtr(input_api, output_api) |
| 48 return results | 49 return results |
| 49 | 50 |
| 50 | 51 |
| 51 def CheckChangeOnUpload(input_api, output_api): | 52 def CheckChangeOnUpload(input_api, output_api): |
| 52 return CheckChange(input_api, output_api) | 53 return CheckChange(input_api, output_api) |
| 53 | 54 |
| 54 | 55 |
| 55 def CheckChangeOnCommit(input_api, output_api): | 56 def CheckChangeOnCommit(input_api, output_api): |
| 56 return CheckChange(input_api, output_api) | 57 return CheckChange(input_api, output_api) |
| OLD | NEW |