mirror of
https://github.com/adrienverge/yamllint.git
synced 2025-02-25 18:55:20 -06:00
line_length: skip all hash signs starting comment
This commit is contained in:
parent
5d8ef2ea23
commit
e53ea093e2
@ -116,6 +116,27 @@ class LineLengthTestCase(RuleTestCase):
|
||||
'long_line: http://localhost/very/very/long/url\n'
|
||||
'...\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'
|
||||
' subkey: value\n', conf)
|
||||
self.check('---\n'
|
||||
'## http://www.verylongurlurlurlurlurlurlurlurl.com\n'
|
||||
'key:\n'
|
||||
' subkey: value\n', conf)
|
||||
self.check('---\n'
|
||||
'# # http://www.verylongurlurlurlurlurlurlurlurl.com\n'
|
||||
'key:\n'
|
||||
' subkey: value\n', conf,
|
||||
problem=(2, 21))
|
||||
self.check('---\n'
|
||||
'#A http://www.verylongurlurlurlurlurlurlurlurl.com\n'
|
||||
'key:\n'
|
||||
' subkey: value\n', conf,
|
||||
problem1=(2, 2, 'comments'),
|
||||
problem2=(2, 21, 'line-length'))
|
||||
|
||||
conf = ('line-length: {max: 20, allow-non-breakable-words: true}\n'
|
||||
'trailing-spaces: disable')
|
||||
self.check('---\n'
|
||||
|
@ -140,7 +140,11 @@ def check(conf, line):
|
||||
start += 1
|
||||
|
||||
if start != line.end:
|
||||
if line.buffer[start] in ('#', '-'):
|
||||
if line.buffer[start] == '#':
|
||||
while line.buffer[start] == '#':
|
||||
start += 1
|
||||
start += 1
|
||||
elif line.buffer[start] == '-':
|
||||
start += 2
|
||||
|
||||
if line.buffer.find(' ', start, line.end) == -1:
|
||||
|
Loading…
Reference in New Issue
Block a user