pinterest / ktlint

An anti-bikeshedding Kotlin linter with built-in formatter
https://pinterest.github.io/ktlint/
MIT License
6.19k stars 505 forks source link

[Question] Why max_line_length contains number of indent white space? #2619

Closed Jaehwa-Noh closed 6 months ago

Jaehwa-Noh commented 6 months ago

Sorry for making it in issue, but I can't join the slack without @jetbrain.com email.

I'm an Android developer and I read this guideline. I don't think document says that including the white space for indent counts into limitation of 100 characters, but ktlint does count that. So, max_line_length works unexpectedly. For example, when I have 80 indent space then I can only 20 character can write to pass the ktlint. What does anybody think about this?

Thank you.

paul-dingemans commented 6 months ago

Sorry for making it in issue, but I can't join the slack without @jetbrain.com email.

You can get an invite here.

I'm an Android developer and I read this guideline. I don't think document says that including the white space for indent counts into limitation of 100 characters, but ktlint does count that.

The indentation spaces are indeed counted. The idea is that the code never exceeds a certain column position. In the old days monitors were not that wide. By setting the max line length you could avoid that you need to scroll horizontal. Nowadays, monitors are that wide, that you still need a max line length to prevent that some lines get reallly long.