line_length: skip all hash signs starting comment

pull/370/head
Patryk Małek 4 years ago
parent 5d8ef2ea23
commit 328ad7fc61

@ -116,6 +116,16 @@ class LineLengthTestCase(RuleTestCase):
'long_line: http://localhost/very/very/long/url\n' 'long_line: http://localhost/very/very/long/url\n'
'...\n', conf, problem=(2, 21)) '...\n', conf, problem=(2, 21))
conf = 'line-length: {max: 20, allow-non-breakable-words: true}'
self.check('---\n'
'# http://www.verylongurlurlurlurlurlurlurlurl.com\n'
'key:\n'
' value:\n', conf)
self.check('---\n'
'## http://www.verylongurlurlurlurlurlurlurlurl.com\n'
'key:\n'
' value:\n', conf)
conf = ('line-length: {max: 20, allow-non-breakable-words: true}\n' conf = ('line-length: {max: 20, allow-non-breakable-words: true}\n'
'trailing-spaces: disable') 'trailing-spaces: disable')
self.check('---\n' self.check('---\n'

@ -140,7 +140,11 @@ def check(conf, line):
start += 1 start += 1
if start != line.end: if start != line.end:
if line.buffer[start] in ('#', '-'): if line.buffer[start] in ('#'):
idx = line.buffer.find(' ', start, line.end)
if idx != -1:
start = idx + 1
elif line.buffer[start] in ('-'):
start += 2 start += 2
if line.buffer.find(' ', start, line.end) == -1: if line.buffer.find(' ', start, line.end) == -1:

Loading…
Cancel
Save