ansman
11/12/2024, 2:12 PMfoo
.bar {
...
}.baz {
...
}
whereas I want to format like this (so that you can remove an operator without affecting the closing }
):
foo
.bar {
...
}
.baz {
...
}
I can disable the "Chain method continuation" rule but then you get no enforcement at all. Has anyone solved the same issue?Piotr Krzemiński
11/29/2024, 11:26 AMJames
12/05/2024, 8:22 AM.
in a chain to be on a newline instead of after )
or }
?
I'm not sure I see a way to do this in Chain method continuationPaul Dingemans
12/05/2024, 8:31 AMwakingrufus
12/08/2024, 4:23 PMatticus
12/20/2024, 11:41 AMclass Test(
val test1: String,
val test2: String, // comment
val test3: String
)
And I received the error: 'A comment in a 'value_parameter_list' is only allowed when placed on a separate line (cannot be auto-corrected).'
I want to write the code like this. How can I disable this rule?Mez Pahlan
12/20/2024, 6:34 PM// 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:
// 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:
// 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 🐱 .Paul Dingemans
12/20/2024, 8:12 PMeygraber
01/02/2025, 5:57 PMdroidrcc
02/14/2025, 5:50 PMif (something == ABC
) {
...
} else {
...
}
) {
should be on the same line of the if statement...
if (something == ABC) {
Do you have any insight?andrew
02/20/2025, 1:58 AM.editorconfig
changes when using spotless?Blaž Vantur
02/20/2025, 9:00 AMmax_line_length
for specific methods that are Annotated with @Test
?
We are using back ticks for naming and we like having our names descriptive. But because of that the line length always exceed our defined limit for max_line_length
. Is there a way to ignore it in some other global way without a need of adding suppress annotation directly where it happens?Aditya Bhaskar
03/03/2025, 12:45 PMktlint
related)
Does anyone know of any migration notes or discussions when updating to 5.0.x
of Kotlinter-gradle?
I just made the update and the lintKotlin
task is throwing 100s of lint errors. I’ve confirmed it’s not a ktlint issue by changing the ktlintVersion
to previously working version.
The release notes don’t suggest anything that could impact this.
I have a feeling that the .editorconfig
is not being used.
As an example, one frequent error is due to the function-signature
rule saying “First line of body expression fits on same line as function signature”. But that seems to ignore max-line-length
set to 100 in editorconfig.Klitos Kyriacou
03/03/2025, 6:25 PMMalte
03/27/2025, 7:49 AMelse
branch for when
that have an enum as subject? i.e. i want to make ktlint recognize when(someEnum) {else -> … }
- and raise an issue of coursezt
04/10/2025, 11:07 PMpublic class Hook(public override val replyUserData: Long) : MpvEvent, Reply
into this
public class Hook(public override val replyUserData: Long) :
MpvEvent,
Reply
I cannot figure out what rule is doing this. There really should be an easier way to just quickly see a list of violations in the IDEKlitos Kyriacou
05/02/2025, 2:24 PM[standard:import-ordering]
if I have 100 imports and the 50th one is out of order, it gives the message "Imports must be ordered in lexicographic order" at the start of the first line of import. It would be very useful if it put the message on the first line that was out of order.Paul Dingemans
05/20/2025, 5:23 AMMarcel Overdijk
05/22/2025, 9:13 AM@Schema(
name = "Country",
description = "Representation of a country.",
)
data class CountryDto(
@field:Schema(
description = "The unique identifier for the country.",
)
val id: String,
@field:Schema(
description = "The unique ISO 3166-1 alpha-2 code of the country.",
minLength = 2,
maxLength = 2,
pattern = "^[A-Z]{2}$",
)
val alpha2Code: String,
@field:Schema(
description = "The unique ISO 3166-1 alpha-3 code of the country.",
minLength = 3,
maxLength = 3,
pattern = "^[A-Z]{3}$",
)
val alpha3Code: String,
@field:Schema(
description = "The name of the country.",
)
val name: String,
@field:Schema(
types = ["string", "null"],
description = "The demonym for citizens of the country.",
required = true,
)
val demonym: String?,
@field:Schema(
description = "The identifier for the continent where the country is located.",
)
val continentId: String,
)
a blank link between the fields would help a lot, but this does not seem to be possible... is that correct, or am I missing something?Benoît Liessens
06/25/2025, 1:35 PMPaul Dingemans
06/25/2025, 3:30 PMHadi
07/15/2025, 5:33 PMmodules
dsl of Koin, where function calls duplicated while devs resolving merge conflicts. so we got no compile time or runtime error to notice this! another example is include
calls in settings.gradle.kt file, where there’s no error when there’s duplicated calls. any idea how to solve that?Hadi
07/15/2025, 5:35 PMPaul Dingemans
07/16/2025, 6:16 AM1.7.0
was released earlier this week. This version is based on Kotlin 2.2.0 and as of that supports context parameters. Unfortunately it misformats the context receivers in some cases. This will be fixed in the bugfix release which is coming in 1 to 2 weeks.
Full release notes: https://github.com/pinterest/ktlint/releases/tag/1.7.0Lex Luthor
07/18/2025, 1:19 AM1.7.0
I get the following error:
> Task :runKtlintFormatOverKotlinScripts FAILED
Rule 'internal:ktlint-suppression' throws exception in file 'build.gradle.kts' at position (0:0)
Rule maintainer: KtLint
Issue tracker : <https://github.com/pinterest/ktlint/issues>
Repository : <https://github.com/pinterest/ktlint>
Has anyone else encountered a similar issue?PoisonedYouth
07/18/2025, 5:24 AM1.6.0
to 1.7.0
(without doing any other change). There are a lot of changes when formatting the code like:
OLD:
val updatedDemands = data.demands
.filterNot { userData ->
demands.any { <http://it.cat|it.cat> == <http://userData.cat|userData.cat> }
} + demands.filterNot { it.status == null }
NEW:
val updatedDemands = data.demands
.filterNot { userData ->
demands.any { <http://it.cat|it.cat> == <http://userData.cat|userData.cat> }
} +
demands.filterNot { it.status == null }
Which rule is affecting this? Can I disable it?Paul Dingemans
07/21/2025, 6:14 PM1.7.1
is released. This fixes the problem in ktlint-gradle
plugin, and wrapping of context parameters.
https://github.com/pinterest/ktlint/releases/tag/1.7.1Matteo Mirk
07/31/2025, 12:39 PM1.2.1
to 1.7.1
, and the gradle plugin to the latest version. I enabled max_line_length
which was previously disabled for .kt files. Unfortunately Ktlint has started wrapping some expressions in a way I really don't like, in order to fit within the line length. This and similar expression are being formatted like this:
//BEFORE
val actual = runBlocking { alternativeDatesListingExperiment.sanitizeResponse(subQueryResult, subQuerySanitizer, mockSubListingDetails, getNonPropertyCardStrippingContext(egGraphQLContext, searchParameters = searchParameters)) }
//AFTER
val actual =
runBlocking {
alternativeDatesListingExperiment.sanitizeResponse(
subQueryResult,
subQuerySanitizer,
mockSubListingDetails,
getNonPropertyCardStrippingContext(egGraphQLContext, searchParameters = searchParameters)
)
}
No matter how I tweak the wrapping rules, it stubbornly wraps the expression on the next line after the assignment. What I'd like is this:
val actual = runBlocking {
...
}
I've read the rules documentation thoroughly more than once, and I can't find a reason why it's wrapping the expression like this. Is there something I'm missing or is it impossible to configure Ktlint in such a way? Thanks.
Attaching my editor config for reference.Oleg Nenashev
08/12/2025, 12:23 PMHugo Costa
08/18/2025, 7:59 AM