ktlint
ktlint copied to clipboard
Could we get back the support for continuation indent?
It seems that ktlint v0.37.0 removed the support for continuation indent. Now all indents are 4 spaces. It would be great if there is a config option for it, so that we can make the decision for the projects.
probably we could use ij_continuation_indent_size
.editorconfig
property
Unfortunately there is no standard .editorconfig
property for this, see https://github.com/editorconfig/editorconfig/issues/412
Also, the indentation rule does not really support it in the current state I think
This removal basically prevents us from updating ktlint, as eating this kind of line cost in our codebase for a change that disagrees with the IDE style's built-in rules is too much
@ZacSweers the problem is that the old indentation rule was pretty dumb and also did not support auto-formatting, it was just reporting some issues, so I guess these changes are not solely caused by the absence of the continuation indent support.
I think we'd be happy to bring it back after the split of the indentation rule, but there are also some misalignments on JetBrains' side (e.g. #805) that have to be clarified first.
I did a cursory glance around the changed files and ~99% of the couple dozen I checked were related to the continuation indent change.
Interesting, could you drop a few examples?
We could definitely consider this. Like @romtsn said, at the time the now-standard Indent rule was written, it greatly simplified the implementation to not support continuation indent. But if we're trying to converge on IDEA and ktlint formatting things the same, it does seem like something we need to support.
Is there any progress on this issue? This seems to become a blocker for Kotlin 1.4.0. Our Square code style has a specific continuation indent that we don't like to drop. It would be sad if we'd need to disable the indent
rule only to get access to the newer version that's compiles with Kotlin 1.4.0.
No progress so far, we were planning to split the rule itself first so it gets easier to disable and also change it. But it seems we need to prioritize it now. I am just curious, do you use continuation indent on some custom code blocks that are different from the official styleguide? By that I mean this:
If the answer is yes, then we'd also need to bring support for this via editorconfig
We use the continuation indent there.
you can set a config rule to disable this check indent_size = unset
Unable to update Detekt because of this, which in turn is preventing us from updating to Kotlin 1.4.
I guess this feature didn't make it into the 0.39.0
release, did it?
No, planned for next release.
Unable to update Detekt because of this, which in turn is preventing us from updating to Kotlin 1.4.
@eygraber I have ktlint set up separately with kotlinter and I'm not leveraging the Detekt formatting plugin. When updating Detekt, a higher version of ktlint was brought in as a transitive dependency and broke the build. If you're in the same boat, then this temporary work-around could be helpful. If you're using the formatting plugin, you can try a similar strategy of forcing the versions of the transitive dependencies (and cross your fingers that it works.) These docs and the buildEnvironment
gradle task are helpful in verification.
buildscript {
dependencies {
classpath("io.gitlab.arturbosch.detekt:detekt-gradle-plugin:$VERSION") {
exclude group: "com.pinterest.ktlint"
}
}
}
Sorry for the off-topic, but I figured this might help what I suspect will be a growing amount of people arriving at these threads after completing some routine version bumps. I'm anxiously awaiting these changes :)
@patrickpilch thanks for that. Unfortunately it wasn't able to help us. Wish this issue didn't keep getting bounced to future releases :disappointed:
I think this may have been fixed? I updated to latest, removed the indent_size = unset
rule and ktlint doesn't fail? I'm still somewhat ignorant to the issue (I encountered it once and blindly copy pasted the unset rule above), but just pointing out that it seems to be all good on my end.
EDIT: Actually nevermind. Somehow it's passing locally but not on CI. I'm running ktlintCheck on both. Really unsure what's going on.
Edit 2: Added back in the indent_size rule and CI now passes. No idea what's going on.
Hey - 0.41.0 was released but doesn't mention this. We're seeing new issues when trying it out as well, where it fails due to expecting a larger continuation indent when we define 2.
@ColtonIdle this issue is about continuation indent, indent_size
is irrelevant to this
As described here the continuation indent has been dropped in the default IntellI IDEA formatter.