Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Max line length #47

Closed
Nycto opened this issue May 30, 2017 · 9 comments
Closed

Max line length #47

Nycto opened this issue May 30, 2017 · 9 comments

Comments

@Nycto
Copy link

Nycto commented May 30, 2017

I would like to enforce a maximum line length on the files being linted. I'm partial to 100 characters, or even 120.

@shyiko
Copy link
Collaborator

shyiko commented May 30, 2017

Hi @Nycto. I'm not sure this is something that can be part of the standard ruleset (while I try to stay within 120 characters myself). But here are some of the options that you might want to consider:

@shyiko
Copy link
Collaborator

shyiko commented May 30, 2017

On the other hand we could make it part of the ktlint and enable it whenever max_line_length is explicitly set for kt/kts files.

@Nycto
Copy link
Author

Nycto commented May 30, 2017

I'm not sure this is something that can be part of the standard ruleset

I suppose it depends on what your goals with this project are. Do you have any tenants you're working with to help you decide whether a rule belomgs in the standard set? For example, if you told me "All Kotlin files should feel like they were written by the same person", I could make a good case for this. But I would have a harder time with something like "Kotlin files should be as short and noise free as possible".

@JLLeitschuh
Copy link
Contributor

Place where kotlin code style stuff is discussed: https://github.com/yole/kotlin-style-guide

Perhaps pose this question here and let the community come to some sort of consensus.

shyiko added a commit that referenced this issue Jul 24, 2017
@shyiko
Copy link
Collaborator

shyiko commented Jul 24, 2017

@Nycto available in 0.9.0.

Add

[*.{kt,kts}]
max_line_length = 120

to the .editorconfig. ktlint will take it from there.

P.S. comments are not checked (intentionally).
P.P.S. ktlint does not (and probably never will) enforce any max_line_length by default.

@shyiko shyiko closed this as completed Jul 24, 2017
@mhlz
Copy link

mhlz commented Jul 24, 2017

In my rule I also excluded imports since they can't be broken up and some class names are really long (especially in libraries we don't control).

Imports are always folded away in IntelliJ anyways. Does ktlint's implementation ignore them?

@shyiko
Copy link
Collaborator

shyiko commented Jul 24, 2017

@mhlz now it does :) (both package & import directives)

@alashow
Copy link

alashow commented Jun 25, 2020

@shyiko Is it possible to ignore max line length for kotlin raw strings?

@Tapchicoma
Copy link
Collaborator

@alashow yes, please check this section of project readme: https://github.com/pinterest/ktlint#how-do-i-suppress-an-error-for-a-lineblockfile

If it will not work for you, please open a new issue.

@pinterest pinterest locked and limited conversation to collaborators Jun 25, 2020
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants