fix(parser): Correctly handle DOS new lines in 'line' rules

Do not consider the trailing `\r` of a line a part of it.
This commit is contained in:
Adrien Vergé
2019-03-25 18:44:45 +01:00
parent 2a66ec2e5e
commit fec2c2fba7
6 changed files with 58 additions and 12 deletions

View File

@@ -171,3 +171,12 @@ class LineLengthTestCase(RuleTestCase):
'# This is a test to check if “line-length” works nice\n'
'with: “unicode characters” that span accross bytes! ↺\n',
conf, problem1=(2, 53), problem2=(3, 53))
def test_with_dos_newlines(self):
conf = ('line-length: {max: 10}\n'
'new-lines: {type: dos}\n'
'new-line-at-end-of-file: disable\n')
self.check('---\r\nABCD EFGHI', conf)
self.check('---\r\nABCD EFGHI\r\n', conf)
self.check('---\r\nABCD EFGHIJ', conf, problem=(2, 11))
self.check('---\r\nABCD EFGHIJ\r\n', conf, problem=(2, 11))