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

Unified Diff: base/PRESUBMIT.py

Issue 611153004: replace OVERRIDE and FINAL with override and final in base/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: CC_ -> BASE_ 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/android/trace_event_binding.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/PRESUBMIT.py
diff --git a/base/PRESUBMIT.py b/base/PRESUBMIT.py
index 732ac27e2a2ad81242510881a0978782f71229be..758a79053ae57eaeff62d1f39a468991817829d0 100644
--- a/base/PRESUBMIT.py
+++ b/base/PRESUBMIT.py
@@ -8,6 +8,10 @@ See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
for more details on the presubmit API built into gcl.
"""
+import re
+
+BASE_SOURCE_FILES=(r'^base/.*\.(cc|h|mm)$',)
+
def _CheckNoInterfacesInBase(input_api, output_api):
"""Checks to make sure no files in libbase.a have |@interface|."""
pattern = input_api.re.compile(r'^\s*@interface', input_api.re.MULTILINE)
@@ -36,8 +40,45 @@ def _CommonChecks(input_api, output_api):
results.extend(_CheckNoInterfacesInBase(input_api, output_api))
return results
+def _CheckOverrideFinal(input_api, output_api,
+ whitelist=BASE_SOURCE_FILES, blacklist=None):
+ """Make sure new lines of code don't use the OVERRIDE or FINAL macros."""
+
+ # TODO(mostynb): remove this check once the macros are removed
+ # from base/compiler_specific.h.
+
+ errors = []
+
+ source_file_filter = lambda x: input_api.FilterSourceFile(
+ x, white_list=BASE_SOURCE_FILES, black_list=None)
+
+ override_files = []
+ final_files = []
+
+ for f in input_api.AffectedSourceFiles(source_file_filter):
+ contents = input_api.ReadFile(f, 'rb')
+
+ # "override" and "final" should be used instead of OVERRIDE/FINAL now.
+ if re.search(r"\bOVERRIDE\b", contents):
+ override_files.append(f.LocalPath())
+
+ if re.search(r"\bFINAL\b", contents):
+ final_files.append(f.LocalPath())
+
+ if override_files:
+ return [output_api.PresubmitError(
+ 'These files use OVERRIDE instead of using override:',
+ items=override_files)]
+ if final_files:
+ return [output_api.PresubmitError(
+ 'These files use FINAL instead of using final:',
+ items=final_files)]
+
+ return []
+
def CheckChangeOnUpload(input_api, output_api):
results = []
+ results.extend(_CheckOverrideFinal(input_api, output_api))
results.extend(_CommonChecks(input_api, output_api))
return results
« no previous file with comments | « no previous file | base/android/trace_event_binding.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698