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

The linter and formatter results are inconsistent #854

Closed
m15o opened this issue Aug 24, 2020 · 0 comments · Fixed by #929
Closed

The linter and formatter results are inconsistent #854

m15o opened this issue Aug 24, 2020 · 0 comments · Fixed by #929

Comments

@m15o
Copy link

m15o commented Aug 24, 2020

Expected Behavior

Trying to format the following code. Expected no errors.

package test

class PropertyA
class PropertyB
class PropertyC

fun someFunction(a: PropertyA, b: PropertyB, c: PropertyC): String = TODO()

fun main(args: Array<String>) {
    if (someFunction(
        PropertyA(),
        PropertyB(),
        PropertyC()
    ) ==
        "ABC"
    ) {
        TODO()
    }
}

Observed Behavior

ktlintFormat task fails with the following message

> Task :ktlintMainSourceSetFormat FAILED
/Users/me/IdeaProjects/test/src/main/kotlin/main.kt:11:13: Unexpected indentation (expected 8, actual 12)
/Users/me/IdeaProjects/test/src/main/kotlin/main.kt:12:17: Unexpected indentation (expected 8, actual 12)
/Users/me/IdeaProjects/test/src/main/kotlin/main.kt:14:1: Unexpected indentation (expected 8, actual 12)
/Users/me/IdeaProjects/test/src/main/kotlin/main.kt:15:12: Unexpected indentation (expected 4, actual 8)

ktlintCheck task produces following errors:

> Task :ktlintMainSourceSetCheck FAILED
/Users/me/IdeaProjects/test/src/main/kotlin/main.kt:11:1: Unexpected indentation (8) (should be 12)
/Users/me/IdeaProjects/test/src/main/kotlin/main.kt:12:1: Unexpected indentation (8) (should be 12)
/Users/me/IdeaProjects/test/src/main/kotlin/main.kt:13:1: Unexpected indentation (8) (should be 12)
/Users/me/IdeaProjects/test/src/main/kotlin/main.kt:14:1: Unexpected indentation (4) (should be 8)

It seem to be formatted in continuation inden 8:

package test

class PropertyA
class PropertyB
class PropertyC

fun someFunction(a: PropertyA, b: PropertyB, c: PropertyC): String = TODO()

fun main(args: Array<String>) {
    if (someFunction(
            PropertyA(),
            PropertyB(),
            PropertyC()
        ) ==
        "ABC"
    ) {
        TODO()
    }
}

Steps to Reproduce

Your Environment

  • Version of ktlint used: 0.38.1
  • Used ktlint gradleplugin (org.jlleitschuh.gradle.ktlint:9.3.0
  • Version of Gradle used (if applicable): 6.3
  • Operating System and version: macOS 10.15.6
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