diff options
author | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-04 17:50:55 +0000 |
---|---|---|
committer | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-04 17:50:55 +0000 |
commit | 542d1ad27eb1cd7c5dbc19e85f546c927aab37b4 (patch) | |
tree | eb69b37a0825f14248d119cd1458bf4291fd7772 /PRESUBMIT.py | |
parent | 3bf7b36097337d487024f9ad7843d3183ea24593 (diff) | |
download | chromium_src-542d1ad27eb1cd7c5dbc19e85f546c927aab37b4.zip chromium_src-542d1ad27eb1cd7c5dbc19e85f546c927aab37b4.tar.gz chromium_src-542d1ad27eb1cd7c5dbc19e85f546c927aab37b4.tar.bz2 |
Add a presubmit check that catches |const NSString*| and friends.
BUG=TEST=none
Review URL: http://codereview.chromium.org/3082016
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@54925 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'PRESUBMIT.py')
-rw-r--r-- | PRESUBMIT.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/PRESUBMIT.py b/PRESUBMIT.py index 4fd988d..4c0aff1 100644 --- a/PRESUBMIT.py +++ b/PRESUBMIT.py @@ -30,6 +30,27 @@ _LICENSE_HEADER = ( ) +def _CheckConstNSObject(input_api, output_api, source_file_filter): + """Checks to make sure no objective-c files have |const NSSomeClass*|.""" + pattern = input_api.re.compile(r'const\s+NS\w*\s*\*') + files = [] + for f in input_api.AffectedSourceFiles(source_file_filter): + if f.LocalPath().endswith('.h') or f.LocalPath().endswith('.mm'): + contents = input_api.ReadFile(f) + if pattern.search(contents): + files.append(f) + + if len(files): + if input_api.is_committing: + res_type = output_api.PresubmitPromptWarning + else: + res_type = output_api.PresubmitNotifyResult + return [ res_type('|const NSClass*| is wrong, see ' + + 'http://dev.chromium.org/developers/clang-mac', + files) ] + return [] + + def _CommonChecks(input_api, output_api): results = [] # What does this code do? @@ -58,6 +79,8 @@ def _CommonChecks(input_api, output_api): input_api, output_api)) results.extend(input_api.canned_checks.CheckLicense( input_api, output_api, _LICENSE_HEADER, source_file_filter=sources)) + results.extend(_CheckConstNSObject( + input_api, output_api, source_file_filter=sources)) return results |