 Chromium Code Reviews
 Chromium Code Reviews Issue 653883002:
  Adding Presubmit error when OVERRIDE and FINAL is not used as C++11 standard  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master
    
  
    Issue 653883002:
  Adding Presubmit error when OVERRIDE and FINAL is not used as C++11 standard  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master| 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 gcl. | 8 for more details about the presubmit API built into gcl. | 
| 9 """ | 9 """ | 
| 10 | 10 | 
| 11 | 11 | 
| 12 import re | 12 import re | 
| 
M-A Ruel
2014/10/14 14:38:20
I know it's not your fault but it's really time to
 
MRV
2014/10/15 08:49:58
Done.
 | |
| 13 import sys | 13 import sys | 
| 
M-A Ruel
2014/10/14 14:38:20
Same. sys.executable is accessible through input_a
 
MRV
2014/10/15 08:49:58
I moved the "import sys", whereveer it required, n
 | |
| 14 | 14 | 
| 15 | 15 | 
| 16 _EXCLUDED_PATHS = ( | 16 _EXCLUDED_PATHS = ( | 
| 17 r"^breakpad[\\\/].*", | 17 r"^breakpad[\\\/].*", | 
| 18 r"^native_client_sdk[\\\/]src[\\\/]build_tools[\\\/]make_rules.py", | 18 r"^native_client_sdk[\\\/]src[\\\/]build_tools[\\\/]make_rules.py", | 
| 19 r"^native_client_sdk[\\\/]src[\\\/]build_tools[\\\/]make_simple.py", | 19 r"^native_client_sdk[\\\/]src[\\\/]build_tools[\\\/]make_simple.py", | 
| 20 r"^native_client_sdk[\\\/]src[\\\/]tools[\\\/].*.mk", | 20 r"^native_client_sdk[\\\/]src[\\\/]tools[\\\/].*.mk", | 
| 21 r"^net[\\\/]tools[\\\/]spdyshark[\\\/].*", | 21 r"^net[\\\/]tools[\\\/]spdyshark[\\\/].*", | 
| 22 r"^skia[\\\/].*", | 22 r"^skia[\\\/].*", | 
| 23 r"^v8[\\\/].*", | 23 r"^v8[\\\/].*", | 
| (...skipping 1227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1251 file_filter = lambda f: input_api.FilterSourceFile( | 1251 file_filter = lambda f: input_api.FilterSourceFile( | 
| 1252 f, white_list=file_inclusion_pattern, black_list=black_list) | 1252 f, white_list=file_inclusion_pattern, black_list=black_list) | 
| 1253 for fpath in input_api.AffectedFiles(file_filter=file_filter): | 1253 for fpath in input_api.AffectedFiles(file_filter=file_filter): | 
| 1254 for line_num, line in fpath.ChangedContents(): | 1254 for line_num, line in fpath.ChangedContents(): | 
| 1255 for (deprecated_value, value) in _DEPRECATED_CSS: | 1255 for (deprecated_value, value) in _DEPRECATED_CSS: | 
| 1256 if input_api.re.search(deprecated_value, line): | 1256 if input_api.re.search(deprecated_value, line): | 
| 1257 results.append(output_api.PresubmitError( | 1257 results.append(output_api.PresubmitError( | 
| 1258 "%s:%d: Use of deprecated CSS %s, use %s instead" % | 1258 "%s:%d: Use of deprecated CSS %s, use %s instead" % | 
| 1259 (fpath.LocalPath(), line_num, deprecated_value, value))) | 1259 (fpath.LocalPath(), line_num, deprecated_value, value))) | 
| 1260 return results | 1260 return results | 
| 1261 | 1261 | 
| 
M-A Ruel
2014/10/14 14:38:20
two lines between file level symbols.
 
MRV
2014/10/15 08:49:58
Done.
 | |
| 1262 def _CheckForOverrideAndFinalRules(input_api, output_api): | |
| 1263 """Checks for override and final used as per C++11""" | |
| 1264 problems = [] | |
| 1265 for f in input_api.AffectedFiles(): | |
| 1266 if (f.LocalPath().endswith(('.cc', '.mm', '.cpp', '.h'))): | |
| 1267 for line_num, line in f.ChangedContents(): | |
| 1268 if (re.search(r"\bOVERRIDE\b", line) or | |
| 
M-A Ruel
2014/10/14 14:38:20
input_api.re.search(r"\b(FINAL|OVERRIDE)\b", line)
 
MRV
2014/10/15 08:49:58
Done.
 | |
| 1269 re.search(r"\bFINAL\b", line)): | |
| 1270 problems.append(' %s:%d' % (f.LocalPath(), line_num)) | |
| 1271 | |
| 1272 if not problems: | |
| 1273 return [] | |
| 1274 return [output_api.PresubmitError('Use C++11\'s |override| and' | |
| 
M-A Ruel
2014/10/14 14:38:20
Weird alignment, either all align to "(" or align
 
MRV
2014/10/15 08:49:58
Done.
 | |
| 1275 ' |final| rather than OVERRIDE and FINAL. \n' + | |
| 
M-A Ruel
2014/10/14 14:38:20
Use '%s' instead of '+'
 
MRV
2014/10/15 08:49:58
I am using displaying the errors directly now.
 | |
| 1276 '\n'.join(problems))] | |
| 1277 | |
| 1278 | |
| 1262 def _CommonChecks(input_api, output_api): | 1279 def _CommonChecks(input_api, output_api): | 
| 1263 """Checks common to both upload and commit.""" | 1280 """Checks common to both upload and commit.""" | 
| 1264 results = [] | 1281 results = [] | 
| 1265 results.extend(input_api.canned_checks.PanProjectChecks( | 1282 results.extend(input_api.canned_checks.PanProjectChecks( | 
| 1266 input_api, output_api, | 1283 input_api, output_api, | 
| 1267 excluded_paths=_EXCLUDED_PATHS + _TESTRUNNER_PATHS)) | 1284 excluded_paths=_EXCLUDED_PATHS + _TESTRUNNER_PATHS)) | 
| 1268 results.extend(_CheckAuthorizedAuthor(input_api, output_api)) | 1285 results.extend(_CheckAuthorizedAuthor(input_api, output_api)) | 
| 1269 results.extend( | 1286 results.extend( | 
| 1270 _CheckNoProductionCodeUsingTestOnlyFunctions(input_api, output_api)) | 1287 _CheckNoProductionCodeUsingTestOnlyFunctions(input_api, output_api)) | 
| 1271 results.extend(_CheckNoIOStreamInHeaders(input_api, output_api)) | 1288 results.extend(_CheckNoIOStreamInHeaders(input_api, output_api)) | 
| (...skipping 21 matching lines...) Expand all Loading... | |
| 1293 input_api, | 1310 input_api, | 
| 1294 output_api, | 1311 output_api, | 
| 1295 source_file_filter=lambda x: x.LocalPath().endswith('.grd'))) | 1312 source_file_filter=lambda x: x.LocalPath().endswith('.grd'))) | 
| 1296 results.extend(_CheckSpamLogging(input_api, output_api)) | 1313 results.extend(_CheckSpamLogging(input_api, output_api)) | 
| 1297 results.extend(_CheckForAnonymousVariables(input_api, output_api)) | 1314 results.extend(_CheckForAnonymousVariables(input_api, output_api)) | 
| 1298 results.extend(_CheckCygwinShell(input_api, output_api)) | 1315 results.extend(_CheckCygwinShell(input_api, output_api)) | 
| 1299 results.extend(_CheckUserActionUpdate(input_api, output_api)) | 1316 results.extend(_CheckUserActionUpdate(input_api, output_api)) | 
| 1300 results.extend(_CheckNoDeprecatedCSS(input_api, output_api)) | 1317 results.extend(_CheckNoDeprecatedCSS(input_api, output_api)) | 
| 1301 results.extend(_CheckParseErrors(input_api, output_api)) | 1318 results.extend(_CheckParseErrors(input_api, output_api)) | 
| 1302 results.extend(_CheckForIPCRules(input_api, output_api)) | 1319 results.extend(_CheckForIPCRules(input_api, output_api)) | 
| 1320 results.extend(_CheckForOverrideAndFinalRules(input_api, output_api)) | |
| 1303 | 1321 | 
| 1304 if any('PRESUBMIT.py' == f.LocalPath() for f in input_api.AffectedFiles()): | 1322 if any('PRESUBMIT.py' == f.LocalPath() for f in input_api.AffectedFiles()): | 
| 1305 results.extend(input_api.canned_checks.RunUnitTestsInDirectory( | 1323 results.extend(input_api.canned_checks.RunUnitTestsInDirectory( | 
| 1306 input_api, output_api, | 1324 input_api, output_api, | 
| 1307 input_api.PresubmitLocalPath(), | 1325 input_api.PresubmitLocalPath(), | 
| 1308 whitelist=[r'^PRESUBMIT_test\.py$'])) | 1326 whitelist=[r'^PRESUBMIT_test\.py$'])) | 
| 1309 return results | 1327 return results | 
| 1310 | 1328 | 
| 1311 | 1329 | 
| 1312 def _CheckAuthorizedAuthor(input_api, output_api): | 1330 def _CheckAuthorizedAuthor(input_api, output_api): | 
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1715 builders.extend(['cros_x86']) | 1733 builders.extend(['cros_x86']) | 
| 1716 | 1734 | 
| 1717 # The AOSP bot doesn't build the chrome/ layer, so ignore any changes to it | 1735 # The AOSP bot doesn't build the chrome/ layer, so ignore any changes to it | 
| 1718 # unless they're .gyp(i) files as changes to those files can break the gyp | 1736 # unless they're .gyp(i) files as changes to those files can break the gyp | 
| 1719 # step on that bot. | 1737 # step on that bot. | 
| 1720 if (not all(re.search('^chrome', f) for f in files) or | 1738 if (not all(re.search('^chrome', f) for f in files) or | 
| 1721 any(re.search('\.gypi?$', f) for f in files)): | 1739 any(re.search('\.gypi?$', f) for f in files)): | 
| 1722 builders.extend(['android_aosp']) | 1740 builders.extend(['android_aosp']) | 
| 1723 | 1741 | 
| 1724 return GetDefaultTryConfigs(builders) | 1742 return GetDefaultTryConfigs(builders) | 
| OLD | NEW |