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

parameter-list-wrapping false positive #859

Closed
allenhumphreys opened this issue Aug 26, 2020 · 0 comments · Fixed by #936
Closed

parameter-list-wrapping false positive #859

allenhumphreys opened this issue Aug 26, 2020 · 0 comments · Fixed by #936

Comments

@allenhumphreys
Copy link

Observed Behavior

I seem to have found a very strange edge case in parameter-list-wrapper rule. It must be an edge case because it took a very long time to find a reasonably minimal reproduction case. Every time I changed something it did not trigger.

To illustrate, any of the following changes will avoid the false positive:

  • Renaming the property startDateTime to property
  • Renaming TestClassA to TestClass
  • Eliminating the line WORDS c.property = ${"interpolation".length}

The issue is ktlint triggers the rule and attempt to reformat the line

${FUNCTION_2(TestClassA::startDateTime, descending = true)}

to

${FUNCTION_2(
    TestClassA::startDateTime,
    descending = true
)}

Expected Behavior

I should not encounter a false positive.

Steps to Reproduce

class Scope {
    fun foo() {
        function("arg1", "arg2") {
            """
            WORDS
            WORDS c.property = ${"interpolation".length}
            ${FUNCTION_2(TestClassA::startDateTime, descending = true)}
            """
        }
    }
}

data class TestClassA(
    val startDateTime: Long
)

class Query
fun function(vararg parameters: String, block: () -> String): Query = Query()
fun FUNCTION_2(property: KProperty1<*, *>, parameterWithDefault: String = "default", descending: Boolean = false): String = ""

Your Environment

  • Version of ktlint used: 0.38.1
  • Name and version (or code for custom task) of integration used (Gradle plugin, Maven plugin, command line, custom Gradle task): kotlinter
  • Version of Gradle used (if applicable): 6.6
  • Operating System and version: macOS 10.15.6
# 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.

3 participants