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

Continuation indent is doubled when indentation and function signature are enabled #1661

Closed
eygraber opened this issue Sep 29, 2022 · 5 comments

Comments

@eygraber
Copy link
Contributor

Expected Behavior

I expect a single indent to be used for continuation indents.

The Kotlin style guide migration suggests that:

In Kotlin coding conventions, it's recommended to use a single indent in cases where the long continuation indent has been forced before.

Observed Behavior

A double indent is being used.

Steps to Reproduce

repro project

I'm using ktlint through detekt, using the command ./gradlew detektMetadataMain. In between each of these cases, I am running git reset --hard in order to reset the file to original formatting. The rules can be configured in the detekt.yml file.

  1. Indentation and FunctionSignature enabled - two function bodies are moved inline with the signature and indentation is doubled for continuations
  2. Indentation enabled and FunctionSignature disabled - no changes
  3. Indentation disabled and FunctionSignature enabled - two function bodies are moved inline with the signature

Your Environment

  • Version of ktlint used: 0.46.1 (through detekt 1.22.0-RC1)
  • Version of Gradle used (if applicable): 7.5.1
@paul-dingemans
Copy link
Collaborator

@eygraber Can you please simplify the issue? The current issue description is a mix of Detekt and Ktlint and you are assuming that the problem is caused by Ktlint. I am not familiar with Detekt, so this makes it hard for me to investigate. Also the problem can be caused by the way Detekt invokes Ktlint.

Please try to reproduce your problem with the Ktlint CLI (see https://pinterest.github.io/ktlint/install/cli/) only so that we just know whether this issue needs to be investigated by the Ktlint or the Detekt project.

Also minimize your example file to contain the least amount of code that displays the problem. Finally, also enclose the expected output.

@eygraber
Copy link
Contributor Author

OK I followed the cli instructions and when running ktlint at the root of that project the issue is present.

@paul-dingemans
Copy link
Collaborator

Also minimize your example file to contain the least amount of code that displays the problem. Finally, also enclose the expected output.

It is not clear to me what exactly you perceive as the problem. Please paste code, formatted as you would have expected it.

@eygraber
Copy link
Contributor Author

I forgot to configure ktlint the way I have detekt configured 🙈

After doing that, ktlint behaves correctly. I will raise the issue with detekt.

@paul-dingemans
Copy link
Collaborator

I forgot to configure ktlint the way I have detekt configured 🙈

After doing that, ktlint behaves correctly. I will raise the issue with detekt.

Tnx for confirming.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants