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

Side by Side Diff: presubmit_canned_checks.py

Issue 424733003: Add exception for long url(..) lines in css files in presubmit_canned_checks.CheckLongLines (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: more review comments Created 6 years, 4 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 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 # Hard line length limit at 50% more. 351 # Hard line length limit at 50% more.
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 if any((url in line) for url in ('file://', 'http://', 'https://')):
362 any((url in line) for url in ('file://', 'http://', 'https://')) or 362 return True
363 input_api.re.match( 363
364 r'.*[A-Za-z][A-Za-z_0-9]{%d,}.*' % long_symbol, line)) 364 if 'url(' in line and file_extension == 'css':
365 return True
366
367 return input_api.re.match(
368 r'.*[A-Za-z][A-Za-z_0-9]{%d,}.*' % long_symbol, line)
365 369
366 def format_error(filename, line_num, line): 370 def format_error(filename, line_num, line):
367 return '%s, line %s, %s chars' % (filename, line_num, len(line)) 371 return '%s, line %s, %s chars' % (filename, line_num, len(line))
368 372
369 errors = _FindNewViolationsOfRule(no_long_lines, input_api, 373 errors = _FindNewViolationsOfRule(no_long_lines, input_api,
370 source_file_filter, 374 source_file_filter,
371 error_formatter=format_error) 375 error_formatter=format_error)
372 if errors: 376 if errors:
373 msg = 'Found lines longer than %s characters (first 5 shown).' % maxlen 377 msg = 'Found lines longer than %s characters (first 5 shown).' % maxlen
374 return [output_api.PresubmitPromptWarning(msg, items=errors[:5])] 378 return [output_api.PresubmitPromptWarning(msg, items=errors[:5])]
(...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after
1094 def CheckPatchFormatted(input_api, output_api): 1098 def CheckPatchFormatted(input_api, output_api):
1095 import git_cl 1099 import git_cl
1096 cmd = ['cl', 'format', '--dry-run', input_api.PresubmitLocalPath()] 1100 cmd = ['cl', 'format', '--dry-run', input_api.PresubmitLocalPath()]
1097 code, _ = git_cl.RunGitWithCode(cmd, suppress_stderr=True) 1101 code, _ = git_cl.RunGitWithCode(cmd, suppress_stderr=True)
1098 if code == 2: 1102 if code == 2:
1099 return [output_api.PresubmitPromptWarning( 1103 return [output_api.PresubmitPromptWarning(
1100 'Your patch is not formatted, please run git cl format.')] 1104 'Your patch is not formatted, please run git cl format.')]
1101 # As this is just a warning, ignore all other errors if the user 1105 # As this is just a warning, ignore all other errors if the user
1102 # happens to have a broken clang-format, doesn't use git, etc etc. 1106 # happens to have a broken clang-format, doesn't use git, etc etc.
1103 return [] 1107 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