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

Experimental function-signature rule has different behavior when a function is annotated #1690

Closed
shashachu opened this issue Oct 31, 2022 · 0 comments · Fixed by #1694
Closed

Comments

@shashachu
Copy link
Contributor

The function-signature rule can cause max-line-length violations on annotated functions.

Steps to Reproduce

object MyClass {
    @[MyAnnotation]
    internal fun thisIsAnExtremelyLongFunctionNameWithALotOfWordsSoManyWords(
        thisIsAReallyReallyLongTypeNameThatIsVeryLog: ThisIsAReallyReallyLongTypeNameThatIsVeryLog,
        anotherReallyReallyReallyLongTypeNameHelloThere: AnotherReallyReallyReallyLongTypeNameHelloThere,
    ): YetAnotherReallyReallyLongFunctionNameLookAtThis? {
        return null
    }
}

Formats to:

object MyClass {
    @[MyAnnotation]
    internal fun thisIsAnExtremelyLongFunctionNameWithALotOfWordsSoManyWords(thisIsAReallyReallyLongTypeNameThatIsVeryLog: ThisIsAReallyReallyLongTypeNameThatIsVeryLog, anotherReallyReallyReallyLongTypeNameHelloThere: AnotherReallyReallyReallyLongTypeNameHelloThere): YetAnotherReallyReallyLongFunctionNameLookAtThis? {
        return null
    }
}

This:

object MyClass {
    @MyAnnotation
    internal fun thisIsAnExtremelyLongFunctionNameWithALotOfWordsSoManyWords(
        thisIsAReallyReallyLongTypeNameThatIsVeryLog: ThisIsAReallyReallyLongTypeNameThatIsVeryLog,
        anotherReallyReallyReallyLongTypeNameHelloThere: AnotherReallyReallyReallyLongTypeNameHelloThere,
    ): YetAnotherReallyReallyLongFunctionNameLookAtThis? {
        return null
    }
}

Does not reformat.

Your Environment

  • Version of ktlint used: 0.47.1
  • Relevant parts of the .editorconfig settings: none
  • Name and version (or code for custom task) of integration used (Gradle plugin, Maven plugin, command line, custom Gradle task): CLI
  • Version of Gradle used (if applicable): n/a
  • Operating System and version: Mac OS 12.6
@paul-dingemans paul-dingemans added this to the 0.48.0 milestone Nov 2, 2022
paul-dingemans added a commit to paul-dingemans/ktlint that referenced this issue Nov 2, 2022
paul-dingemans added a commit that referenced this issue Nov 5, 2022
* Handle function signature preceded by an annotation array similar to function preceded by a singular annotation

Closes #1690
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants