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

Incorrect formatting for properties with by keyword #1162

Closed
scottdweber opened this issue Jun 8, 2021 · 0 comments · Fixed by #1173
Closed

Incorrect formatting for properties with by keyword #1162

scottdweber opened this issue Jun 8, 2021 · 0 comments · Fixed by #1173
Labels

Comments

@scottdweber
Copy link

Given the following code:

private val aSampleValue: SampleValue
    by lazy {
        SampleValue()
    }

Expected Behavior

Leave the code unchanged. This is how Android Studio formats this code when using the official Kotlin style guide.

Observed Behavior

0.39.0 formats this way, which isn't terrible, but also doesn't match official Kotlin style guide:

private val aSampleValue: SampleValue
by lazy {
    SampleValue()
}

0.40.0 and 0.41.0 formats this way, which is quite unpleasant:

private val aSampleValue: SampleValue
    by lazy {
    SampleValue()
}

Your Environment

  • Version of ktlint used: 0.39.0, 0.40.0, 0.41.0
  • org.jlleitschuh.gradle:ktlint-gradle:10.1.0
  • Version of Gradle used (if applicable): 6.6.1
  • Operating System and version: macOS 11.4
  • Android Studio: 4.2.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants