diff options
author | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-16 05:05:59 +0000 |
---|---|---|
committer | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-16 05:05:59 +0000 |
commit | 127f18ec329490d72c21ffaac2af086534f95412 (patch) | |
tree | 7d2a67c6495d7009548607e8ee34ec32820c0879 /PRESUBMIT.py | |
parent | 536f7e6060e4c116a30c9138e188c43ef617b3f7 (diff) | |
download | chromium_src-127f18ec329490d72c21ffaac2af086534f95412.zip chromium_src-127f18ec329490d72c21ffaac2af086534f95412.tar.gz chromium_src-127f18ec329490d72c21ffaac2af086534f95412.tar.bz2 |
Added presubmit warnings about base coordinate system.
BUG=132984
TEST=none
Review URL: https://chromiumcodereview.appspot.com/10556015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@142578 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'PRESUBMIT.py')
-rw-r--r-- | PRESUBMIT.py | 113 |
1 files changed, 113 insertions, 0 deletions
diff --git a/PRESUBMIT.py b/PRESUBMIT.py index d4d00ed..375978d 100644 --- a/PRESUBMIT.py +++ b/PRESUBMIT.py @@ -31,6 +31,78 @@ _TEST_ONLY_WARNING = ( 'Email joi@chromium.org if you have questions.') +_BANNED_OBJC_FUNCTIONS = ( + ( + 'addTrackingRect:', + ('The use of -[NSView addTrackingRect:owner:userData:assumeInside:] is' + 'prohibited. Please use CrTrackingArea instead.', + 'http://dev.chromium.org/developers/coding-style/cocoa-dos-and-donts', + ), + False, + ), + ( + 'NSTrackingArea', + ('The use of NSTrackingAreas is prohibited. Please use CrTrackingArea', + 'instead.', + 'http://dev.chromium.org/developers/coding-style/cocoa-dos-and-donts', + ), + False, + ), + ( + 'convertPointFromBase:', + ('The use of -[NSView convertPointFromBase:] is almost certainly wrong.', + 'Please use |convertPoint:(point) fromView:nil| instead.', + 'http://dev.chromium.org/developers/coding-style/cocoa-dos-and-donts', + ), + True, + ), + ( + 'convertPointToBase:', + ('The use of -[NSView convertPointToBase:] is almost certainly wrong.', + 'Please use |convertPoint:(point) toView:nil| instead.', + 'http://dev.chromium.org/developers/coding-style/cocoa-dos-and-donts', + ), + True, + ), + ( + 'convertRectFromBase:', + ('The use of -[NSView convertRectFromBase:] is almost certainly wrong.', + 'Please use |convertRect:(point) fromView:nil| instead.', + 'http://dev.chromium.org/developers/coding-style/cocoa-dos-and-donts', + ), + True, + ), + ( + 'convertRectToBase:', + ('The use of -[NSView convertRectToBase:] is almost certainly wrong.', + 'Please use |convertRect:(point) toView:nil| instead.', + 'http://dev.chromium.org/developers/coding-style/cocoa-dos-and-donts', + ), + True, + ), + ( + 'convertSizeFromBase:', + ('The use of -[NSView convertSizeFromBase:] is almost certainly wrong.', + 'Please use |convertSize:(point) fromView:nil| instead.', + 'http://dev.chromium.org/developers/coding-style/cocoa-dos-and-donts', + ), + True, + ), + ( + 'convertSizeToBase:', + ('The use of -[NSView convertSizeToBase:] is almost certainly wrong.', + 'Please use |convertSize:(point) toView:nil| instead.', + 'http://dev.chromium.org/developers/coding-style/cocoa-dos-and-donts', + ), + True, + ), +) + + +_BANNED_CPP_FUNCTIONS = ( +) + + def _CheckNoInterfacesInBase(input_api, output_api): """Checks to make sure no files in libbase.a have |@interface|.""" @@ -219,6 +291,46 @@ def _CheckNoFilePathWatcherDelegate(input_api, output_api): '\n'.join(problems))] +def _CheckNoBannedFunctions(input_api, output_api): + """Make sure that banned functions are not used.""" + warnings = [] + errors = [] + + file_filter = lambda f: f.LocalPath().endswith(('.mm', '.m', '.h')) + for f in input_api.AffectedFiles(file_filter=file_filter): + for line_num, line in f.ChangedContents(): + for func_name, message, error in _BANNED_OBJC_FUNCTIONS: + if func_name in line: + problems = warnings; + if error: + problems = errors; + problems.append(' %s:%d:' % (f.LocalPath(), line_num)) + for message_line in message: + problems.append(' %s' % message_line) + + file_filter = lambda f: f.LocalPath().endswith(('.cc', '.mm', '.h')) + for f in input_api.AffectedFiles(file_filter=file_filter): + for line_num, line in f.ChangedContents(): + for func_name, message, error in _BANNED_CPP_FUNCTIONS: + if func_name in line: + problems = warnings; + if error: + problems = errors; + problems.append(' %s:%d:' % (f.LocalPath(), line_num)) + for message_line in message: + problems.append(' %s' % message_line) + + result = [] + if (warnings): + result.append(output_api.PresubmitPromptWarning( + 'Banned functions were used.\n' + '\n'.join(warnings))) + if (errors): + result.append(output_api.PresubmitError( + 'Banned functions were used.\n' + '\n'.join(errors))) + return result + + + def _CommonChecks(input_api, output_api): """Checks common to both upload and commit.""" results = [] @@ -234,6 +346,7 @@ def _CommonChecks(input_api, output_api): results.extend(_CheckNoFRIEND_TEST(input_api, output_api)) results.extend(_CheckNoScopedAllowIO(input_api, output_api)) results.extend(_CheckNoFilePathWatcherDelegate(input_api, output_api)) + results.extend(_CheckNoBannedFunctions(input_api, output_api)) return results |