mirror of
https://github.com/adrienverge/yamllint.git
synced 2025-02-25 18:55:20 -06:00
line_length: Allow mapping values with long unbreakable lines
This commit is contained in:
parent
5b98cd2053
commit
d017631aff
@ -84,6 +84,8 @@ class LineLengthTestCase(RuleTestCase):
|
|||||||
'another:\n'
|
'another:\n'
|
||||||
' - https://localhost/very/very/long/url\n'
|
' - https://localhost/very/very/long/url\n'
|
||||||
'...\n', conf)
|
'...\n', conf)
|
||||||
|
self.check('---\n'
|
||||||
|
'long_line: http://localhost/very/very/long/url\n', conf)
|
||||||
|
|
||||||
conf = 'line-length: {max: 20, allow-non-breakable-words: no}'
|
conf = 'line-length: {max: 20, allow-non-breakable-words: no}'
|
||||||
self.check('---\n' + 30 * 'A' + '\n', conf, problem=(2, 21))
|
self.check('---\n' + 30 * 'A' + '\n', conf, problem=(2, 21))
|
||||||
@ -106,3 +108,6 @@ class LineLengthTestCase(RuleTestCase):
|
|||||||
'another:\n'
|
'another:\n'
|
||||||
' - https://localhost/very/very/long/url\n'
|
' - https://localhost/very/very/long/url\n'
|
||||||
'...\n', conf, problem=(5, 21))
|
'...\n', conf, problem=(5, 21))
|
||||||
|
self.check('---\n'
|
||||||
|
'long_line: http://localhost/very/very/long/url\n'
|
||||||
|
'...\n', conf, problem=(2, 21))
|
||||||
|
@ -72,6 +72,7 @@ Use this rule to set a limit to lines length.
|
|||||||
http://localhost/very/very/very/very/very/very/very/very/long/url
|
http://localhost/very/very/very/very/very/very/very/very/long/url
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import yaml
|
||||||
|
|
||||||
from yamllint.linter import LintProblem
|
from yamllint.linter import LintProblem
|
||||||
|
|
||||||
@ -96,6 +97,11 @@ def check(conf, line):
|
|||||||
if line.buffer.find(' ', start, line.end) == -1:
|
if line.buffer.find(' ', start, line.end) == -1:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
line_yaml = yaml.safe_load(line.content)
|
||||||
|
if (isinstance(line_yaml, dict) and
|
||||||
|
' ' not in line_yaml.popitem()[1]):
|
||||||
|
return
|
||||||
|
|
||||||
yield LintProblem(line.line_no, conf['max'] + 1,
|
yield LintProblem(line.line_no, conf['max'] + 1,
|
||||||
'line too long (%d > %d characters)' %
|
'line too long (%d > %d characters)' %
|
||||||
(line.end - line.start, conf['max']))
|
(line.end - line.start, conf['max']))
|
||||||
|
Loading…
Reference in New Issue
Block a user