Skip to content
New issue

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

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

Already on GitHub? # to your account

Indentation violation for constructor with generic types #938

Closed
chao2zhang opened this issue Oct 5, 2020 · 0 comments · Fixed by #951
Closed

Indentation violation for constructor with generic types #938

chao2zhang opened this issue Oct 5, 2020 · 0 comments · Fixed by #951

Comments

@chao2zhang
Copy link
Contributor

Expected Behavior

Preferably ViewModelWithALongLongLongLongLongLongLongLongName3 should pass ktlint and is compliant with the recommended code style in Android Studio:

package com.chaozhang.testktlint

class GenericTypeWithALongLongALong1

class GenericTypeWithALongLongALong2

class GenericTypeWithALongLongALong3

class ViewModelWithALongLongLongLongLongLongLongLongName<
    A : GenericTypeWithALongLongALong1,
    B : GenericTypeWithALongLongALong2,
    C : GenericTypeWithALongLongALong3
> constructor(
    parameterWithLongLongLongLongLongLongLongLongNameA: A,
    parameterWithLongLongLongLongLongLongLongLongNameB: B,
    parameterWithLongLongLongLongLongLongLongLongNameC: C
)

class ViewModelWithALongLongLongLongLongLongLongLongName2<
    A : GenericTypeWithALongLongALong1,
    B : GenericTypeWithALongLongALong2,
    C : GenericTypeWithALongLongALong3
    > constructor(
        parameterWithLongLongLongLongLongLongLongLongNameA: A,
        parameterWithLongLongLongLongLongLongLongLongNameB: B,
        parameterWithLongLongLongLongLongLongLongLongNameC: C
    )

class ViewModelWithALongLongLongLongLongLongLongLongName3<
    A : GenericTypeWithALongLongALong1,
    B : GenericTypeWithALongLongALong2,
    C : GenericTypeWithALongLongALong3
    > constructor(
    parameterWithLongLongLongLongLongLongLongLongNameA: A,
    parameterWithLongLongLongLongLongLongLongLongNameB: B,
    parameterWithLongLongLongLongLongLongLongLongNameC: C
)

Observed Behavior

Violations detected in ViewModelWithALongLongLongLongLongLongLongLongName, ViewModelWithALongLongLongLongLongLongLongLongName2 and ViewModelWithALongLongLongLongLongLongLongLongName3.

/Users/cazhang/TestKtLint/app/src/main/java/com/chaozhang/testktlint/ParameterWithGeneric.kt:13:1: Unexpected indentation (0) (should be 4)

/Users/cazhang/TestKtLint/app/src/main/java/com/chaozhang/testktlint/ParameterWithGeneric.kt:24:1: Unexpected indentation (8) (should be 4)
/Users/cazhang/TestKtLint/app/src/main/java/com/chaozhang/testktlint/ParameterWithGeneric.kt:25:1: Unexpected indentation (8) (should be 4)
/Users/cazhang/TestKtLint/app/src/main/java/com/chaozhang/testktlint/ParameterWithGeneric.kt:26:1: Unexpected indentation (8) (should be 4)
/Users/cazhang/TestKtLint/app/src/main/java/com/chaozhang/testktlint/ParameterWithGeneric.kt:27:1: Unexpected indentation (4) (should be 0)

/Users/cazhang/TestKtLint/app/src/main/java/com/chaozhang/testktlint/ParameterWithGeneric.kt:34:5: Unexpected indentation (expected 8, actual 4)
/Users/cazhang/TestKtLint/app/src/main/java/com/chaozhang/testktlint/ParameterWithGeneric.kt:35:5: Unexpected indentation (expected 8, actual 4)
/Users/cazhang/TestKtLint/app/src/main/java/com/chaozhang/testktlint/ParameterWithGeneric.kt:36:5: Unexpected indentation (expected 8, actual 4)
/Users/cazhang/TestKtLint/app/src/main/java/com/chaozhang/testktlint/ParameterWithGeneric.kt:37:1: Unexpected indentation (expected 4, actual 0)

Steps to Reproduce

Copy-paste the snippet and run ktlint.

Your Environment

  • Version of ktlint used: 0.39.0 (This issue happens starting 0.37.0)
  • Name and version (or code for custom task) of integration used (Gradle plugin, Maven plugin, command line, custom Gradle task): custom gradle task
  • Version of Gradle used (if applicable): 6.5
  • Operating System and version: MacOS 10.15.6
  • Link to your project (if it's a public repository): https://gist.github.com/chao2zhang/c4fe4f91bb1cd04c2098e7f8d7eff508
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
1 participant