From 03f0c53648fe9a10449d50885c6a082d6a9c545b Mon Sep 17 00:00:00 2001 From: "dtu@chromium.org" Date: Fri, 27 Mar 2015 22:22:07 +0000 Subject: [PATCH] Remove 150% hard line length limit for long URLs. BUG= Review URL: https://codereview.chromium.org/1033363002 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@294600 0039d316-1c4b-4281-b951-d872f2087c98 --- presubmit_canned_checks.py | 7 ++++--- tests/presubmit_unittest.py | 8 ++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/presubmit_canned_checks.py b/presubmit_canned_checks.py index 49ed07c6f..bba773728 100644 --- a/presubmit_canned_checks.py +++ b/presubmit_canned_checks.py @@ -368,12 +368,13 @@ def CheckLongLines(input_api, output_api, maxlen, source_file_filter=None): if line_len <= file_maxlen: return True - if line_len > extra_maxlen: - return False - + # Allow long URLs of any length. if any((url in line) for url in ('file://', 'http://', 'https://')): return True + if line_len > extra_maxlen: + return False + if 'url(' in line and file_extension == 'css': return True diff --git a/tests/presubmit_unittest.py b/tests/presubmit_unittest.py index d6cbd09ae..2196d8d63 100755 --- a/tests/presubmit_unittest.py +++ b/tests/presubmit_unittest.py @@ -2205,20 +2205,20 @@ class CannedChecksUnittest(PresubmitTestsBase): check = lambda x, y, z: presubmit_canned_checks.CheckLongLines(x, y, 10, z) self.ContentTest( check, - ' http:// 0 23 5', - None, ' http:// 0 23 56', None, + ' foob:// 0 23 56', + None, presubmit.OutputApi.PresubmitPromptWarning) def testCannedCheckLongLinesFile(self): check = lambda x, y, z: presubmit_canned_checks.CheckLongLines(x, y, 10, z) self.ContentTest( check, - ' file:// 0 23 5', - None, ' file:// 0 23 56', None, + ' foob:// 0 23 56', + None, presubmit.OutputApi.PresubmitPromptWarning) def testCannedCheckLongLinesCssUrl(self):