Pattern: Line is too long
Issue: -
Your source code should not contain very long lines. The default wrapping in most tools disrupts the visual structure of the code, making it more difficult to understand.
max
defines the maximal (inclusive) length of lines.allow-non-breakable-words
is used to allow non breakable words (without spaces inside) to overflow the limit. This is useful for long URLs, for instance. Usetrue
to allow,false
to forbid.allow-non-breakable-inline-mappings
impliesallow-non-breakable-words
and extends it to also allow non-breakable words in inline mappings.
-
With
line-length: {max: 70}
the following code snippet would PASS:
long sentence: Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
the following code snippet would FAIL:
long sentence: Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
-
With
line-length: {max: 60, allow-non-breakable-words: true}
the following code snippet would PASS:
this: is: - a: http://localhost/very/very/very/very/very/very/very/very/long/url # this comment is too long, # but hard to split: # http://localhost/another/very/very/very/very/very/very/very/very/long/url
the following code snippet would FAIL:
- this line is waaaaaaaaaaaaaay too long but could be easily split...
and the following code snippet would also FAIL:
- foobar: http://localhost/very/very/very/very/very/very/very/very/long/url
-
With
line-length: {max: 60, allow-non-breakable-words: true, allow-non-breakable-inline-mappings: true}
the following code snippet would PASS:
- foobar: http://localhost/very/very/very/very/very/very/very/very/long/url
-
With
line-length: {max: 60, allow-non-breakable-words: false}
the following code snippet would FAIL:
this: is: - a: http://localhost/very/very/very/very/very/very/very/very/long/url