Hello everyone, lovely to meet you :wave: Can I g...
# ktlint
m
Hello everyone, lovely to meet you 👋 Can I get your thoughts on this please. I have the following class - note the opening squiggly bracket is outside of the character limit by 1:
Copy code
// Assume that the last allowed character is at the X character on the right                                                               X
internal open class OkHttpClientAdapter(private val url: String, private val httpClient: OkHttpClient = OkHttpClient()) : HttpClientAdapter {
  ... // Some code of no interest.
}
Which, when formatted, turns into this:
Copy code
// Assume that the last allowed character is at the X character on the right                                                               X
internal open class OkHttpClientAdapter(private val url: String, private val httpClient: OkHttpClient = OkHttpClient()) :
  HttpClientAdapter {
  ... // Some code of no interest.
}
I'm using
ktlint_code_style = intellij_idea
and would like something that does the following when format:
Copy code
// Assume that the last allowed character is at the X character on the right                                                               X
internal open class OkHttpClientAdapter(
  private val url: String,
  private val httpClient: OkHttpClient = OkHttpClient(),
) : HttpClientAdapter {
  ... // Some code of no interest.
}
I can achieve this (sort of) by setting
ktlint_standard_class-signature = disabled
along with the code style, but unless I go round and fix all instances of the first formatting I can't benefit from an autofix in any way. It's fine once it is formatted but Ktlint doesn't automatically format in this way. IntelliJ has the ability to do this with the
Put parameters on separate lines
autofix and I was wondering if Ktlint could do something similar if it detects the max character count has been exceeded? In plain words: • For a class signature. • Whose character limit has been exceeded. • Put all parameters on separate lines. • With the closing class constructor bracket on the next line. • And ensure the supertype is on the same line as the closing class bracket. Is there some way I can achieve this via Ktlint? Thanks again for your time 🐱 .