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

Side by Side Diff: presubmit_canned_checks.py

Issue 13403004: Make maxlen configurable in PanProjectChecks (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Created 7 years, 8 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 | tests/presubmit_unittest.py » ('j') | 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 """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 import os as _os 7 import os as _os
8 _HERE = _os.path.dirname(_os.path.abspath(__file__)) 8 _HERE = _os.path.dirname(_os.path.abspath(__file__))
9 9
10 10
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 """Checks that there is no stray whitespace at source lines end.""" 305 """Checks that there is no stray whitespace at source lines end."""
306 errors = _FindNewViolationsOfRule(lambda _, line : line.rstrip() == line, 306 errors = _FindNewViolationsOfRule(lambda _, line : line.rstrip() == line,
307 input_api, source_file_filter) 307 input_api, source_file_filter)
308 if errors: 308 if errors:
309 return [output_api.PresubmitPromptWarning( 309 return [output_api.PresubmitPromptWarning(
310 'Found line ending with white spaces in:', 310 'Found line ending with white spaces in:',
311 long_text='\n'.join(errors))] 311 long_text='\n'.join(errors))]
312 return [] 312 return []
313 313
314 314
315 def CheckLongLines(input_api, output_api, maxlen=80, source_file_filter=None): 315 def CheckLongLines(input_api, output_api, maxlen, source_file_filter=None):
316 """Checks that there aren't any lines longer than maxlen characters in any of 316 """Checks that there aren't any lines longer than maxlen characters in any of
317 the text files to be submitted. 317 the text files to be submitted.
318 """ 318 """
319 maxlens = { 319 maxlens = {
320 'java': 100, 320 'java': 100,
321 # This is specifically for Android's handwritten makefiles (Android.mk). 321 # This is specifically for Android's handwritten makefiles (Android.mk).
322 'mk': 200, 322 'mk': 200,
323 '': maxlen, 323 '': maxlen,
324 } 324 }
325 # Note: these are C++ specific but processed on all languages. :( 325 # Note: these are C++ specific but processed on all languages. :(
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after
896 'Found Singleton<T> in the following header files.\n' + 896 'Found Singleton<T> in the following header files.\n' +
897 'Please move them to an appropriate source file so that the ' + 897 'Please move them to an appropriate source file so that the ' +
898 'template gets instantiated in a single compilation unit.', 898 'template gets instantiated in a single compilation unit.',
899 files) ] 899 files) ]
900 return [] 900 return []
901 901
902 902
903 def PanProjectChecks(input_api, output_api, 903 def PanProjectChecks(input_api, output_api,
904 excluded_paths=None, text_files=None, 904 excluded_paths=None, text_files=None,
905 license_header=None, project_name=None, 905 license_header=None, project_name=None,
906 owners_check=True): 906 owners_check=True, maxlen=80):
907 """Checks that ALL chromium orbit projects should use. 907 """Checks that ALL chromium orbit projects should use.
908 908
909 These are checks to be run on all Chromium orbit project, including: 909 These are checks to be run on all Chromium orbit project, including:
910 Chromium 910 Chromium
911 Native Client 911 Native Client
912 V8 912 V8
913 When you update this function, please take this broad scope into account. 913 When you update this function, please take this broad scope into account.
914 Args: 914 Args:
915 input_api: Bag of input related interfaces. 915 input_api: Bag of input related interfaces.
916 output_api: Bag of output related interfaces. 916 output_api: Bag of output related interfaces.
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
968 print " %s took a long time: %dms" % (snapshot_memory[1], delta_ms) 968 print " %s took a long time: %dms" % (snapshot_memory[1], delta_ms)
969 snapshot_memory[:] = (dt2, msg) 969 snapshot_memory[:] = (dt2, msg)
970 970
971 if owners_check: 971 if owners_check:
972 snapshot("checking owners") 972 snapshot("checking owners")
973 results.extend(input_api.canned_checks.CheckOwners( 973 results.extend(input_api.canned_checks.CheckOwners(
974 input_api, output_api, source_file_filter=None)) 974 input_api, output_api, source_file_filter=None))
975 975
976 snapshot("checking long lines") 976 snapshot("checking long lines")
977 results.extend(input_api.canned_checks.CheckLongLines( 977 results.extend(input_api.canned_checks.CheckLongLines(
978 input_api, output_api, source_file_filter=sources)) 978 input_api, output_api, maxlen, source_file_filter=sources))
979 snapshot( "checking tabs") 979 snapshot( "checking tabs")
980 results.extend(input_api.canned_checks.CheckChangeHasNoTabs( 980 results.extend(input_api.canned_checks.CheckChangeHasNoTabs(
981 input_api, output_api, source_file_filter=sources)) 981 input_api, output_api, source_file_filter=sources))
982 snapshot( "checking stray whitespace") 982 snapshot( "checking stray whitespace")
983 results.extend(input_api.canned_checks.CheckChangeHasNoStrayWhitespace( 983 results.extend(input_api.canned_checks.CheckChangeHasNoStrayWhitespace(
984 input_api, output_api, source_file_filter=sources)) 984 input_api, output_api, source_file_filter=sources))
985 snapshot("checking nsobjects") 985 snapshot("checking nsobjects")
986 results.extend(_CheckConstNSObject( 986 results.extend(_CheckConstNSObject(
987 input_api, output_api, source_file_filter=sources)) 987 input_api, output_api, source_file_filter=sources))
988 snapshot("checking singletons") 988 snapshot("checking singletons")
(...skipping 18 matching lines...) Expand all
1007 snapshot("checking description") 1007 snapshot("checking description")
1008 results.extend(input_api.canned_checks.CheckChangeHasDescription( 1008 results.extend(input_api.canned_checks.CheckChangeHasDescription(
1009 input_api, output_api)) 1009 input_api, output_api))
1010 results.extend(input_api.canned_checks.CheckDoNotSubmitInDescription( 1010 results.extend(input_api.canned_checks.CheckDoNotSubmitInDescription(
1011 input_api, output_api)) 1011 input_api, output_api))
1012 snapshot("checking do not submit in files") 1012 snapshot("checking do not submit in files")
1013 results.extend(input_api.canned_checks.CheckDoNotSubmitInFiles( 1013 results.extend(input_api.canned_checks.CheckDoNotSubmitInFiles(
1014 input_api, output_api)) 1014 input_api, output_api))
1015 snapshot("done") 1015 snapshot("done")
1016 return results 1016 return results
OLDNEW
« no previous file with comments | « no previous file | tests/presubmit_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698