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

Side by Side Diff: presubmit_canned_checks.py

Issue 100163002: Allow obj-c import statements to be as long as necessary. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Created 7 years 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 | 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) 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 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 """Checks that there aren't any lines longer than maxlen characters in any of 315 """Checks that there aren't any lines longer than maxlen characters in any of
316 the text files to be submitted. 316 the text files to be submitted.
317 """ 317 """
318 maxlens = { 318 maxlens = {
319 'java': 100, 319 'java': 100,
320 # This is specifically for Android's handwritten makefiles (Android.mk). 320 # This is specifically for Android's handwritten makefiles (Android.mk).
321 'mk': 200, 321 'mk': 200,
322 '': maxlen, 322 '': maxlen,
323 } 323 }
324 # Note: these are C++ specific but processed on all languages. :( 324 # Note: these are C++ specific but processed on all languages. :(
325 MACROS = ('#define', '#include', '#import', '#pragma', '#if', '#endif') 325 MACROS = ('#define', '#include', '#import', '#pragma', '#if', '#endif')
M-A Ruel 2013/12/02 21:24:27 Why not add it there instead?
erikchen2 2013/12/02 21:28:41 because those are the C++ specific compiler direct
M-A Ruel 2013/12/02 21:52:28 As the comment above says, these prefixes are chec
erikchen2 2013/12/02 22:37:13 I've unified the code for java, cpp and obj-c exce
326 326
327 # Special java statements. 327 # Special java statements.
328 SPECIAL_JAVA_STARTS = ('package ', 'import ') 328 SPECIAL_JAVA_STARTS = ('package ', 'import ')
329 329
330 # Special obj-c statements.
331 OBJC_FILE_EXTENSIONS = ('h', 'm', 'mm')
332 SPECIAL_OBJC_STARTS = ('#import')
333
330 def no_long_lines(file_extension, line): 334 def no_long_lines(file_extension, line):
331 # Allow special java statements to be as long as necessary. 335 # Allow special java statements to be as long as necessary.
332 if file_extension == 'java' and line.startswith(SPECIAL_JAVA_STARTS): 336 if file_extension == 'java' and line.startswith(SPECIAL_JAVA_STARTS):
333 return True 337 return True
334 338
339 # Allow special obj-c statements to be as long as necessary.
340 if file_extension in OBJC_FILE_EXTENSIONS and\
341 line.startswith(SPECIAL_OBJC_STARTS):
342 return True
343
335 file_maxlen = maxlens.get(file_extension, maxlens['']) 344 file_maxlen = maxlens.get(file_extension, maxlens[''])
336 # Stupidly long symbols that needs to be worked around if takes 66% of line. 345 # Stupidly long symbols that needs to be worked around if takes 66% of line.
337 long_symbol = file_maxlen * 2 / 3 346 long_symbol = file_maxlen * 2 / 3
338 # Hard line length limit at 50% more. 347 # Hard line length limit at 50% more.
339 extra_maxlen = file_maxlen * 3 / 2 348 extra_maxlen = file_maxlen * 3 / 2
340 349
341 line_len = len(line) 350 line_len = len(line)
342 if line_len <= file_maxlen: 351 if line_len <= file_maxlen:
343 return True 352 return True
344 353
(...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after
1023 snapshot("checking description") 1032 snapshot("checking description")
1024 results.extend(input_api.canned_checks.CheckChangeHasDescription( 1033 results.extend(input_api.canned_checks.CheckChangeHasDescription(
1025 input_api, output_api)) 1034 input_api, output_api))
1026 results.extend(input_api.canned_checks.CheckDoNotSubmitInDescription( 1035 results.extend(input_api.canned_checks.CheckDoNotSubmitInDescription(
1027 input_api, output_api)) 1036 input_api, output_api))
1028 snapshot("checking do not submit in files") 1037 snapshot("checking do not submit in files")
1029 results.extend(input_api.canned_checks.CheckDoNotSubmitInFiles( 1038 results.extend(input_api.canned_checks.CheckDoNotSubmitInFiles(
1030 input_api, output_api)) 1039 input_api, output_api))
1031 snapshot("done") 1040 snapshot("done")
1032 return results 1041 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