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

Side by Side Diff: presubmit_canned_checks.py

Issue 234293002: Add file:// case in presubmit_canned_checks.CheckLongLines (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Keep the list in order Created 6 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 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 extra_maxlen = file_maxlen * 3 / 2 352 extra_maxlen = file_maxlen * 3 / 2
353 353
354 line_len = len(line) 354 line_len = len(line)
355 if line_len <= file_maxlen: 355 if line_len <= file_maxlen:
356 return True 356 return True
357 357
358 if line_len > extra_maxlen: 358 if line_len > extra_maxlen:
359 return False 359 return False
360 360
361 return ( 361 return (
362 any((url in line) for url in ('http://', 'https://')) or 362 any((url in line) for url in ('file://', 'http://', 'https://')) or
363 input_api.re.match( 363 input_api.re.match(
364 r'.*[A-Za-z][A-Za-z_0-9]{%d,}.*' % long_symbol, line)) 364 r'.*[A-Za-z][A-Za-z_0-9]{%d,}.*' % long_symbol, line))
365 365
366 def format_error(filename, line_num, line): 366 def format_error(filename, line_num, line):
367 return '%s, line %s, %s chars' % (filename, line_num, len(line)) 367 return '%s, line %s, %s chars' % (filename, line_num, len(line))
368 368
369 errors = _FindNewViolationsOfRule(no_long_lines, input_api, 369 errors = _FindNewViolationsOfRule(no_long_lines, input_api,
370 source_file_filter, 370 source_file_filter,
371 error_formatter=format_error) 371 error_formatter=format_error)
372 if errors: 372 if errors:
(...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after
1061 def CheckPatchFormatted(input_api, output_api): 1061 def CheckPatchFormatted(input_api, output_api):
1062 import git_cl 1062 import git_cl
1063 cmd = ['cl', 'format', '--dry-run', input_api.PresubmitLocalPath()] 1063 cmd = ['cl', 'format', '--dry-run', input_api.PresubmitLocalPath()]
1064 code, _ = git_cl.RunGitWithCode(cmd, suppress_stderr=True) 1064 code, _ = git_cl.RunGitWithCode(cmd, suppress_stderr=True)
1065 if code == 2: 1065 if code == 2:
1066 return [output_api.PresubmitPromptWarning( 1066 return [output_api.PresubmitPromptWarning(
1067 'Your patch is not formatted, please run git cl format.')] 1067 'Your patch is not formatted, please run git cl format.')]
1068 # As this is just a warning, ignore all other errors if the user 1068 # As this is just a warning, ignore all other errors if the user
1069 # happens to have a broken clang-format, doesn't use git, etc etc. 1069 # happens to have a broken clang-format, doesn't use git, etc etc.
1070 return [] 1070 return []
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