max-line-length
What it does
Section titled “What it does”Reports a line longer than max characters (default 120). With allow_non_breakable_words (default on) a line that has no space after its indentation, a leading # run or - is not reported (a long URL); allow_non_breakable_inline_mappings also allows a YAML key: value line whose value has no space.
Why it matters
Section titled “Why it matters”Long lines do not fit next to each other in a diff or a code review, wrap unpredictably in narrow windows, and hide the end of the line when a view scrolls sideways. The limit is a convention of the project, set with max.
To fix, break the line at a natural place.
Example
Section titled “Example”{"key": "0123456789"}Configuration
Section titled “Configuration”lint: rules: max-line-length: level: warn # off (default), warn, error options: max: 120 allow_non_breakable_words: true allow_non_breakable_inline_mappings: false| Option | Type | Default | Description |
|---|---|---|---|
max |
int | 120 |
Longest allowed line, in characters. |
allow_non_breakable_words |
bool | true |
Do not report a line that has no space after its indentation (and after a leading # run or - ), such as a long URL. |
allow_non_breakable_inline_mappings |
bool | false |
With allow_non_breakable_words, also do not report a key: value line whose value has no space. Only in languages that have such lines (YAML). |
Enabled by the presets: cmake/cmake-lint, java/google, kotlin/ktlint, markdown/markdownlint, sql/sqlfluff, yaml/yamllint.
Suppress one line with sudsy-disable-next-line max-line-length in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools. full: Sudsy reports what the upstream rule reports; partial: only part of it, as the last column says.
| Tool | Rule | Match | What differs |
|---|---|---|---|
| checkstyle | LineLength |
partial | No ignore pattern for package and import lines. |
| cmake-lint | C0301 |
full | |
| ktlint | max-line-length |
partial | ktlint_official allows 140 columns (the max option defaults to 120); no exemption for package, import and raw-string lines. |
| markdownlint | MD013 |
partial | No exemptions for code blocks, tables and headings (code_blocks, tables, headings), no strict, stern or line_length per-language defaults. |
| psscriptanalyzer | PSAvoidLongLines |
full | |
| Roslynator | RCS0056 |
partial | no allow_non_breakable_words |
| sqlfluff | LT05 |
full | |
| yamllint | line-length |
full | |
| yamllint | line-length.max |
full | |
| yamllint | line-length.allow-non-breakable-words |
full | |
| yamllint | line-length.allow-non-breakable-inline-mappings |
full |