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

Side by Side Diff: PRESUBMIT.py

Issue 638663003: 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
Patch Set: Rebased the patch 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 | no next file » | 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 """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
(...skipping 1241 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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 ' OVERRIDE' or ' FINAL' in line:
1269 problems.append(' %s:%d' % (f.LocalPath(), line_num))
1270
1271 if not problems:
1272 return []
1273 return [output_api.PresubmitError('Use C++11\'s |override| and'
1274 ' |final| rather than OVERRIDE and FINAL. \n' +
1275 '\n'.join(problems))]
1276
1262 def _CommonChecks(input_api, output_api): 1277 def _CommonChecks(input_api, output_api):
1263 """Checks common to both upload and commit.""" 1278 """Checks common to both upload and commit."""
1264 results = [] 1279 results = []
1265 results.extend(input_api.canned_checks.PanProjectChecks( 1280 results.extend(input_api.canned_checks.PanProjectChecks(
1266 input_api, output_api, 1281 input_api, output_api,
1267 excluded_paths=_EXCLUDED_PATHS + _TESTRUNNER_PATHS)) 1282 excluded_paths=_EXCLUDED_PATHS + _TESTRUNNER_PATHS))
1268 results.extend(_CheckAuthorizedAuthor(input_api, output_api)) 1283 results.extend(_CheckAuthorizedAuthor(input_api, output_api))
1269 results.extend( 1284 results.extend(
1270 _CheckNoProductionCodeUsingTestOnlyFunctions(input_api, output_api)) 1285 _CheckNoProductionCodeUsingTestOnlyFunctions(input_api, output_api))
1271 results.extend(_CheckNoIOStreamInHeaders(input_api, output_api)) 1286 results.extend(_CheckNoIOStreamInHeaders(input_api, output_api))
(...skipping 21 matching lines...) Expand all
1293 input_api, 1308 input_api,
1294 output_api, 1309 output_api,
1295 source_file_filter=lambda x: x.LocalPath().endswith('.grd'))) 1310 source_file_filter=lambda x: x.LocalPath().endswith('.grd')))
1296 results.extend(_CheckSpamLogging(input_api, output_api)) 1311 results.extend(_CheckSpamLogging(input_api, output_api))
1297 results.extend(_CheckForAnonymousVariables(input_api, output_api)) 1312 results.extend(_CheckForAnonymousVariables(input_api, output_api))
1298 results.extend(_CheckCygwinShell(input_api, output_api)) 1313 results.extend(_CheckCygwinShell(input_api, output_api))
1299 results.extend(_CheckUserActionUpdate(input_api, output_api)) 1314 results.extend(_CheckUserActionUpdate(input_api, output_api))
1300 results.extend(_CheckNoDeprecatedCSS(input_api, output_api)) 1315 results.extend(_CheckNoDeprecatedCSS(input_api, output_api))
1301 results.extend(_CheckParseErrors(input_api, output_api)) 1316 results.extend(_CheckParseErrors(input_api, output_api))
1302 results.extend(_CheckForIPCRules(input_api, output_api)) 1317 results.extend(_CheckForIPCRules(input_api, output_api))
1318 results.extend(_CheckForOverrideAndFinalRules(input_api, output_api))
1303 1319
1304 if any('PRESUBMIT.py' == f.LocalPath() for f in input_api.AffectedFiles()): 1320 if any('PRESUBMIT.py' == f.LocalPath() for f in input_api.AffectedFiles()):
1305 results.extend(input_api.canned_checks.RunUnitTestsInDirectory( 1321 results.extend(input_api.canned_checks.RunUnitTestsInDirectory(
1306 input_api, output_api, 1322 input_api, output_api,
1307 input_api.PresubmitLocalPath(), 1323 input_api.PresubmitLocalPath(),
1308 whitelist=[r'^PRESUBMIT_test\.py$'])) 1324 whitelist=[r'^PRESUBMIT_test\.py$']))
1309 return results 1325 return results
1310 1326
1311 1327
1312 def _CheckAuthorizedAuthor(input_api, output_api): 1328 def _CheckAuthorizedAuthor(input_api, output_api):
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
1715 builders.extend(['cros_x86']) 1731 builders.extend(['cros_x86'])
1716 1732
1717 # The AOSP bot doesn't build the chrome/ layer, so ignore any changes to it 1733 # 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 1734 # unless they're .gyp(i) files as changes to those files can break the gyp
1719 # step on that bot. 1735 # step on that bot.
1720 if (not all(re.search('^chrome', f) for f in files) or 1736 if (not all(re.search('^chrome', f) for f in files) or
1721 any(re.search('\.gypi?$', f) for f in files)): 1737 any(re.search('\.gypi?$', f) for f in files)):
1722 builders.extend(['android_aosp']) 1738 builders.extend(['android_aosp'])
1723 1739
1724 return GetDefaultTryConfigs(builders) 1740 return GetDefaultTryConfigs(builders)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698