Commit de3ee901 authored by treib@chromium.org's avatar treib@chromium.org

Add exception for long url(..) lines in css files in presubmit_canned_checks.CheckLongLines

BUG=397508

Review URL: https://codereview.chromium.org/424733003

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@285901 0039d316-1c4b-4281-b951-d872f2087c98
parent abbaa843
...@@ -358,10 +358,14 @@ def CheckLongLines(input_api, output_api, maxlen, source_file_filter=None): ...@@ -358,10 +358,14 @@ def CheckLongLines(input_api, output_api, maxlen, source_file_filter=None):
if line_len > extra_maxlen: if line_len > extra_maxlen:
return False return False
return ( if any((url in line) for url in ('file://', 'http://', 'https://')):
any((url in line) for url in ('file://', 'http://', 'https://')) or return True
input_api.re.match(
r'.*[A-Za-z][A-Za-z_0-9]{%d,}.*' % long_symbol, line)) if 'url(' in line and file_extension == 'css':
return True
return input_api.re.match(
r'.*[A-Za-z][A-Za-z_0-9]{%d,}.*' % long_symbol, line)
def format_error(filename, line_num, line): def format_error(filename, line_num, line):
return '%s, line %s, %s chars' % (filename, line_num, len(line)) return '%s, line %s, %s chars' % (filename, line_num, len(line))
......
...@@ -2253,6 +2253,16 @@ class CannedChecksUnittest(PresubmitTestsBase): ...@@ -2253,6 +2253,16 @@ class CannedChecksUnittest(PresubmitTestsBase):
None, None,
presubmit.OutputApi.PresubmitPromptWarning) presubmit.OutputApi.PresubmitPromptWarning)
def testCannedCheckLongLinesCssUrl(self):
check = lambda x, y, z: presubmit_canned_checks.CheckLongLines(x, y, 10, z)
self.ContentTest(
check,
' url(some.png)',
'foo.css',
' url(some.png)',
'foo.cc',
presubmit.OutputApi.PresubmitPromptWarning)
def testCannedCheckLongLinesLongSymbol(self): def testCannedCheckLongLinesLongSymbol(self):
check = lambda x, y, z: presubmit_canned_checks.CheckLongLines(x, y, 10, z) check = lambda x, y, z: presubmit_canned_checks.CheckLongLines(x, y, 10, z)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment