| OLD | NEW |
| 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 depot_tools. | 8 for more details about the presubmit API built into depot_tools. |
| 9 """ | 9 """ |
| 10 | 10 |
| (...skipping 1566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1577 break | 1577 break |
| 1578 | 1578 |
| 1579 if len(files): | 1579 if len(files): |
| 1580 return [output_api.PresubmitError( | 1580 return [output_api.PresubmitError( |
| 1581 'Do not introduce new mojom targets with use_new_wrapper_types set to ' | 1581 'Do not introduce new mojom targets with use_new_wrapper_types set to ' |
| 1582 'false. The mode is deprecated and will be removed soon.', | 1582 'false. The mode is deprecated and will be removed soon.', |
| 1583 files)] | 1583 files)] |
| 1584 return [] | 1584 return [] |
| 1585 | 1585 |
| 1586 | 1586 |
| 1587 def _CheckUselessForwardDeclarations(input_api, output_api): |
| 1588 """Checks that affected header files do not contain useless class |
| 1589 or struct forward declaration. |
| 1590 """ |
| 1591 results = [] |
| 1592 class_pattern = input_api.re.compile(r'^class\s+(\w+);$', |
| 1593 input_api.re.MULTILINE) |
| 1594 struct_pattern = input_api.re.compile(r'^struct\s+(\w+);$', |
| 1595 input_api.re.MULTILINE) |
| 1596 for f in input_api.AffectedFiles(): |
| 1597 if not f.LocalPath().endswith('.h'): |
| 1598 continue |
| 1599 |
| 1600 contents = input_api.ReadFile(f) |
| 1601 fwd_decls = input_api.re.findall(class_pattern, contents) |
| 1602 fwd_decls.extend(input_api.re.findall(struct_pattern, contents)) |
| 1603 |
| 1604 for decl in fwd_decls: |
| 1605 count = sum(1 for _ in input_api.re.finditer( |
| 1606 r'\b%s\b' % input_api.re.escape(decl), contents)) |
| 1607 if count == 1: |
| 1608 results.append(output_api.PresubmitPromptWarning( |
| 1609 '%s: %s forward declaration seems to be useless' % |
| 1610 (f.LocalPath(), decl))) |
| 1611 |
| 1612 return results |
| 1613 |
| 1614 |
| 1587 def _CheckAndroidToastUsage(input_api, output_api): | 1615 def _CheckAndroidToastUsage(input_api, output_api): |
| 1588 """Checks that code uses org.chromium.ui.widget.Toast instead of | 1616 """Checks that code uses org.chromium.ui.widget.Toast instead of |
| 1589 android.widget.Toast (Chromium Toast doesn't force hardware | 1617 android.widget.Toast (Chromium Toast doesn't force hardware |
| 1590 acceleration on low-end devices, saving memory). | 1618 acceleration on low-end devices, saving memory). |
| 1591 """ | 1619 """ |
| 1592 toast_import_pattern = input_api.re.compile( | 1620 toast_import_pattern = input_api.re.compile( |
| 1593 r'^import android\.widget\.Toast;$') | 1621 r'^import android\.widget\.Toast;$') |
| 1594 | 1622 |
| 1595 errors = [] | 1623 errors = [] |
| 1596 | 1624 |
| (...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2026 results.extend(_CheckNoDeprecatedJS(input_api, output_api)) | 2054 results.extend(_CheckNoDeprecatedJS(input_api, output_api)) |
| 2027 results.extend(_CheckParseErrors(input_api, output_api)) | 2055 results.extend(_CheckParseErrors(input_api, output_api)) |
| 2028 results.extend(_CheckForIPCRules(input_api, output_api)) | 2056 results.extend(_CheckForIPCRules(input_api, output_api)) |
| 2029 results.extend(_CheckForWindowsLineEndings(input_api, output_api)) | 2057 results.extend(_CheckForWindowsLineEndings(input_api, output_api)) |
| 2030 results.extend(_CheckSingletonInHeaders(input_api, output_api)) | 2058 results.extend(_CheckSingletonInHeaders(input_api, output_api)) |
| 2031 results.extend(_CheckNoDeprecatedCompiledResourcesGYP(input_api, output_api)) | 2059 results.extend(_CheckNoDeprecatedCompiledResourcesGYP(input_api, output_api)) |
| 2032 results.extend(_CheckPydepsNeedsUpdating(input_api, output_api)) | 2060 results.extend(_CheckPydepsNeedsUpdating(input_api, output_api)) |
| 2033 results.extend(_CheckJavaStyle(input_api, output_api)) | 2061 results.extend(_CheckJavaStyle(input_api, output_api)) |
| 2034 results.extend(_CheckIpcOwners(input_api, output_api)) | 2062 results.extend(_CheckIpcOwners(input_api, output_api)) |
| 2035 results.extend(_CheckMojoUsesNewWrapperTypes(input_api, output_api)) | 2063 results.extend(_CheckMojoUsesNewWrapperTypes(input_api, output_api)) |
| 2064 results.extend(_CheckUselessForwardDeclarations(input_api, output_api)) |
| 2036 | 2065 |
| 2037 if any('PRESUBMIT.py' == f.LocalPath() for f in input_api.AffectedFiles()): | 2066 if any('PRESUBMIT.py' == f.LocalPath() for f in input_api.AffectedFiles()): |
| 2038 results.extend(input_api.canned_checks.RunUnitTestsInDirectory( | 2067 results.extend(input_api.canned_checks.RunUnitTestsInDirectory( |
| 2039 input_api, output_api, | 2068 input_api, output_api, |
| 2040 input_api.PresubmitLocalPath(), | 2069 input_api.PresubmitLocalPath(), |
| 2041 whitelist=[r'^PRESUBMIT_test\.py$'])) | 2070 whitelist=[r'^PRESUBMIT_test\.py$'])) |
| 2042 return results | 2071 return results |
| 2043 | 2072 |
| 2044 | 2073 |
| 2045 def _CheckAuthorizedAuthor(input_api, output_api): | 2074 def _CheckAuthorizedAuthor(input_api, output_api): |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2306 results.extend(input_api.canned_checks.CheckTreeIsOpen( | 2335 results.extend(input_api.canned_checks.CheckTreeIsOpen( |
| 2307 input_api, | 2336 input_api, |
| 2308 output_api, | 2337 output_api, |
| 2309 json_url='http://chromium-status.appspot.com/current?format=json')) | 2338 json_url='http://chromium-status.appspot.com/current?format=json')) |
| 2310 | 2339 |
| 2311 results.extend(input_api.canned_checks.CheckChangeHasBugField( | 2340 results.extend(input_api.canned_checks.CheckChangeHasBugField( |
| 2312 input_api, output_api)) | 2341 input_api, output_api)) |
| 2313 results.extend(input_api.canned_checks.CheckChangeHasDescription( | 2342 results.extend(input_api.canned_checks.CheckChangeHasDescription( |
| 2314 input_api, output_api)) | 2343 input_api, output_api)) |
| 2315 return results | 2344 return results |
| OLD | NEW |