Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Could we get back the support for continuation indent? #816

Closed
yongce opened this issue Jul 19, 2020 · 19 comments
Closed

Could we get back the support for continuation indent? #816

yongce opened this issue Jul 19, 2020 · 19 comments

Comments

@yongce
Copy link

yongce commented Jul 19, 2020

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.

@Tapchicoma
Copy link
Collaborator

probably we could use ij_continuation_indent_size .editorconfig property

Unfortunately there is no standard .editorconfig property for this, see editorconfig/editorconfig#412

@Tapchicoma Tapchicoma added this to the 0.38.0 milestone Jul 20, 2020
@romtsn
Copy link
Collaborator

romtsn commented Jul 21, 2020

Also, the indentation rule does not really support it in the current state I think

@ZacSweers
Copy link

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
image

@romtsn
Copy link
Collaborator

romtsn commented Aug 4, 2020

@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.

@ZacSweers
Copy link

I did a cursory glance around the changed files and ~99% of the couple dozen I checked were related to the continuation indent change.

@romtsn
Copy link
Collaborator

romtsn commented Aug 4, 2020

Interesting, could you drop a few examples?

@shashachu
Copy link
Contributor

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.

@vRallev
Copy link

vRallev commented Aug 15, 2020

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.

@romtsn
Copy link
Collaborator

romtsn commented Aug 16, 2020

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:
image

If the answer is yes, then we'd also need to bring support for this via editorconfig

@vRallev
Copy link

vRallev commented Aug 17, 2020

We use the continuation indent there.
Screen Shot 2020-08-16 at 9 46 14 PM

@Denchick1
Copy link

you can set a config rule to disable this check
indent_size = unset

@eygraber
Copy link
Contributor

Unable to update Detekt because of this, which in turn is preventing us from updating to Kotlin 1.4.

@vRallev
Copy link

vRallev commented Sep 14, 2020

I guess this feature didn't make it into the 0.39.0 release, did it?

@shashachu shashachu modified the milestones: 0.39.0, 0.40.0 Sep 15, 2020
@Tapchicoma
Copy link
Collaborator

No, planned for next release.

@patrickpilch
Copy link

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 :)

@eygraber
Copy link
Contributor

eygraber commented Mar 1, 2021

@patrickpilch thanks for that. Unfortunately it wasn't able to help us. Wish this issue didn't keep getting bounced to future releases 😞

@ColtonIdle
Copy link

ColtonIdle commented Mar 10, 2021

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.

@ZacSweers
Copy link

ZacSweers commented Mar 30, 2021

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

@paul-dingemans
Copy link
Collaborator

As described here the continuation indent has been dropped in the default IntellI IDEA formatter.

@paul-dingemans paul-dingemans closed this as not planned Won't fix, can't repro, duplicate, stale Aug 16, 2022
@paul-dingemans paul-dingemans unpinned this issue Aug 23, 2022
mnonnenmacher added a commit to oss-review-toolkit/ort that referenced this issue Aug 30, 2023
Enable the "Indentation" rule [1] [2] to ensure consistent indentation
across the codebase. Change the continuation indent from 8 to 4 because
the ktlint rule does not support continuation indents [3] [4].

[1]: https://detekt.dev/docs/rules/formatting#indentation
[2]: https://pinterest.github.io/ktlint/0.50.0/rules/standard/#indentation
[3]: pinterest/ktlint#816
[4]: https://kotlinlang.org/docs/code-style-migration-guide.html#differences-between-kotlin-coding-conventions-and-intellij-idea-default-code-style

Signed-off-by: Martin Nonnenmacher <martin.nonnenmacher@bosch.io>
mnonnenmacher added a commit to oss-review-toolkit/ort that referenced this issue Aug 30, 2023
Enable the "Indentation" rule [1] [2] to ensure consistent indentation
across the codebase. Change the continuation indent from 8 to 4 because
the ktlint rule does not support continuation indents [3] [4].

[1]: https://detekt.dev/docs/rules/formatting#indentation
[2]: https://pinterest.github.io/ktlint/0.50.0/rules/standard/#indentation
[3]: pinterest/ktlint#816
[4]: https://kotlinlang.org/docs/code-style-migration-guide.html#differences-between-kotlin-coding-conventions-and-intellij-idea-default-code-style

Signed-off-by: Martin Nonnenmacher <martin.nonnenmacher@bosch.io>
mnonnenmacher added a commit to oss-review-toolkit/ort that referenced this issue Aug 30, 2023
Enable the "Indentation" rule [1] [2] to ensure consistent indentation
across the codebase. Change the continuation indent from 8 to 4 because
the ktlint rule does not support continuation indents [3] [4].

[1]: https://detekt.dev/docs/rules/formatting#indentation
[2]: https://pinterest.github.io/ktlint/0.50.0/rules/standard/#indentation
[3]: pinterest/ktlint#816
[4]: https://kotlinlang.org/docs/code-style-migration-guide.html#differences-between-kotlin-coding-conventions-and-intellij-idea-default-code-style

Signed-off-by: Martin Nonnenmacher <martin.nonnenmacher@bosch.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests