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

Side by Side Diff: presubmit_canned_checks.py

Issue 1033363002: Remove 150% hard line length limit for long URLs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 5 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 | 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 # Justifications for each filter: 10 # Justifications for each filter:
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 file_maxlen = maxlens.get(file_extension, maxlens['']) 361 file_maxlen = maxlens.get(file_extension, maxlens[''])
362 # Stupidly long symbols that needs to be worked around if takes 66% of line. 362 # Stupidly long symbols that needs to be worked around if takes 66% of line.
363 long_symbol = file_maxlen * 2 / 3 363 long_symbol = file_maxlen * 2 / 3
364 # Hard line length limit at 50% more. 364 # Hard line length limit at 50% more.
365 extra_maxlen = file_maxlen * 3 / 2 365 extra_maxlen = file_maxlen * 3 / 2
366 366
367 line_len = len(line) 367 line_len = len(line)
368 if line_len <= file_maxlen: 368 if line_len <= file_maxlen:
369 return True 369 return True
370 370
371 # Allow long URLs of any length.
372 if any((url in line) for url in ('file://', 'http://', 'https://')):
373 return True
374
371 if line_len > extra_maxlen: 375 if line_len > extra_maxlen:
372 return False 376 return False
373 377
374 if any((url in line) for url in ('file://', 'http://', 'https://')):
375 return True
376
377 if 'url(' in line and file_extension == 'css': 378 if 'url(' in line and file_extension == 'css':
378 return True 379 return True
379 380
380 if '<include' in line and file_extension in ('css', 'html', 'js'): 381 if '<include' in line and file_extension in ('css', 'html', 'js'):
381 return True 382 return True
382 383
383 return input_api.re.match( 384 return input_api.re.match(
384 r'.*[A-Za-z][A-Za-z_0-9]{%d,}.*' % long_symbol, line) 385 r'.*[A-Za-z][A-Za-z_0-9]{%d,}.*' % long_symbol, line)
385 386
386 def format_error(filename, line_num, line): 387 def format_error(filename, line_num, line):
(...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after
1120 for f in affected_files: 1121 for f in affected_files:
1121 cmd = ['gn', 'format', '--dry-run', f.AbsoluteLocalPath()] 1122 cmd = ['gn', 'format', '--dry-run', f.AbsoluteLocalPath()]
1122 rc = gn.main(cmd) 1123 rc = gn.main(cmd)
1123 if rc == 2: 1124 if rc == 2:
1124 warnings.append(output_api.PresubmitPromptWarning( 1125 warnings.append(output_api.PresubmitPromptWarning(
1125 '%s requires formatting. Please run `gn format --in-place %s`.' % ( 1126 '%s requires formatting. Please run `gn format --in-place %s`.' % (
1126 f.AbsoluteLocalPath(), f.LocalPath()))) 1127 f.AbsoluteLocalPath(), f.LocalPath())))
1127 # It's just a warning, so ignore other types of failures assuming they'll be 1128 # It's just a warning, so ignore other types of failures assuming they'll be
1128 # caught elsewhere. 1129 # caught elsewhere.
1129 return warnings 1130 return warnings
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