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

bug in indentation checking when nesting objects and sealed classes #2257

Closed
kenyee opened this issue Sep 10, 2023 · 2 comments · Fixed by #2266
Closed

bug in indentation checking when nesting objects and sealed classes #2257

kenyee opened this issue Sep 10, 2023 · 2 comments · Fixed by #2266
Assignees
Milestone

Comments

@kenyee
Copy link

kenyee commented Sep 10, 2023

Expected Behavior

This should be properly formatted:

sealed class T(val name: String) {
    sealed class C(
        name: String,
        val something: String,
    ) : T(name) {
        object Black : C(
            name = "black",
            something = "else",
        )
    }
}

Observed Behavior

It complains that lines 7-9 (starting from name="black") should be indented 4 more spaces:

/tmp/bug1.txt:7:1: Unexpected indentation (12) (should be 16) (standard:indent)
/tmp/bug1.txt:8:1: Unexpected indentation (12) (should be 16) (standard:indent)
/tmp/bug1.txt:9:1: Unexpected indentation (8) (should be 12) (standard:indent)

Steps to Reproduce

Copy first snippet into /tmp/bug.txt
Run ktlint 1.0.0 on it:

ktlint /tmp/bug.txt

Your Environment

  • Version of ktlint used: 1.0.0
  • Relevant parts of the .editorconfig settings
  • indent_style = space
  • Name and version (or code for custom task) of integration used (Gradle plugin, Maven plugin, command line, custom Gradle task): command line
  • Version of Gradle used (if applicable): N.A.
  • Operating System and version: OSX
@paul-dingemans
Copy link
Collaborator

This is indeed a regression bug in 1.0 release.

@paul-dingemans paul-dingemans added this to the 1.0.1 milestone Sep 11, 2023
@paul-dingemans paul-dingemans self-assigned this Sep 11, 2023
@paul-dingemans
Copy link
Collaborator

The problem can be reproduced with a somewhat simpler example:

class Foo(
    foo: String,
) {
    object Bar : Baz(
        baz = "baz",
        bar = "bar",
    )
}

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

Successfully merging a pull request may close this issue.

2 participants