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

Side by Side Diff: presubmit_canned_checks.py

Issue 6755007: Relax |const NSClass*| PRESUBMIT check to not detect false positives (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools/
Patch Set: Created 9 years, 9 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 | Annotate | Revision Log
« 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) 2010 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2010 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 """Generic presubmit checks that can be reused by other presubmit checks.""" 5 """Generic presubmit checks that can be reused by other presubmit checks."""
6 6
7 7
8 ### Description checks 8 ### Description checks
9 9
10 def CheckChangeHasTestField(input_api, output_api): 10 def CheckChangeHasTestField(input_api, output_api):
(...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 approvers = [] 717 approvers = []
718 for m in messages: 718 for m in messages:
719 sender = m['sender'] 719 sender = m['sender']
720 if _IsApprovingComment(m['text']) and match_reviewer(sender): 720 if _IsApprovingComment(m['text']) and match_reviewer(sender):
721 approvers.append(sender) 721 approvers.append(sender)
722 return set(approvers) 722 return set(approvers)
723 723
724 724
725 def _CheckConstNSObject(input_api, output_api, source_file_filter): 725 def _CheckConstNSObject(input_api, output_api, source_file_filter):
726 """Checks to make sure no objective-c files have |const NSSomeClass*|.""" 726 """Checks to make sure no objective-c files have |const NSSomeClass*|."""
727 pattern = input_api.re.compile(r'const\s+NS\w*\s*\*') 727 pattern = input_api.re.compile(
728 r'const\s+NS(?!(Point|Range|Rect|Size)\s*\*)\w*\s*\*')
728 729
729 def objective_c_filter(f): 730 def objective_c_filter(f):
730 return (source_file_filter(f) and 731 return (source_file_filter(f) and
731 input_api.os_path.splitext(f.LocalPath())[1] in ('.h', '.mm')) 732 input_api.os_path.splitext(f.LocalPath())[1] in ('.h', '.m', '.mm'))
732 733
733 files = [] 734 files = []
734 for f in input_api.AffectedSourceFiles(objective_c_filter): 735 for f in input_api.AffectedSourceFiles(objective_c_filter):
735 contents = input_api.ReadFile(f) 736 contents = input_api.ReadFile(f)
736 if pattern.search(contents): 737 if pattern.search(contents):
737 files.append(f) 738 files.append(f)
738 739
739 if files: 740 if files:
740 if input_api.is_committing: 741 if input_api.is_committing:
741 res_type = output_api.PresubmitPromptWarning 742 res_type = output_api.PresubmitPromptWarning
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
828 input_api, output_api, source_file_filter=text_files)) 829 input_api, output_api, source_file_filter=text_files))
829 results.extend(input_api.canned_checks.CheckSvnForCommonMimeTypes( 830 results.extend(input_api.canned_checks.CheckSvnForCommonMimeTypes(
830 input_api, output_api)) 831 input_api, output_api))
831 results.extend(input_api.canned_checks.CheckLicense( 832 results.extend(input_api.canned_checks.CheckLicense(
832 input_api, output_api, license_header, source_file_filter=sources)) 833 input_api, output_api, license_header, source_file_filter=sources))
833 results.extend(_CheckConstNSObject( 834 results.extend(_CheckConstNSObject(
834 input_api, output_api, source_file_filter=sources)) 835 input_api, output_api, source_file_filter=sources))
835 results.extend(_CheckSingletonInHeaders( 836 results.extend(_CheckSingletonInHeaders(
836 input_api, output_api, source_file_filter=sources)) 837 input_api, output_api, source_file_filter=sources))
837 return results 838 return results
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