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

False positive in ArgumentListWrappingRule #1002

Closed
jamespfaulkner opened this issue Dec 9, 2020 · 0 comments · Fixed by #1010
Closed

False positive in ArgumentListWrappingRule #1002

jamespfaulkner opened this issue Dec 9, 2020 · 0 comments · Fixed by #1010

Comments

@jamespfaulkner
Copy link

Expected Behavior

ktlint should not report the following violation.

Observed Behavior

Given the following class and a max_line_length of 80

                class B : A({
                    toInt()
                    toInt()
                    toInt()
                    toInt()
                    toInt()
                    toInt()
                })

ktlint fails with the following two violations:
Argument should be on a separate line (unless all arguments can fit a single line)
Missing newline before ")"

No violations are reported if there is no max_line_length.

Steps to Reproduce

This can be recreated using the following test:

    @Test
    fun testLambdaArgumentsAreIgnored() {
        assertThat(
            ArgumentListWrappingRule().lint(
                """
                abstract class A(init: String.() -> Int)
                class B : A({
                    toInt()
                    toInt()
                    toInt()
                    toInt()
                    toInt()
                    toInt()
                })

                fun test(a: Any, b: (Any) -> Any) {
                    test(a = "1", b = {
                        it.toString()
                    })
                }
                """.trimIndent(),
                userData = mapOf("max_line_length" to "80")
            )
        ).isEmpty()
    }

master...jamespfaulkner:false-reporting

Your Environment

  • Version of ktlint used: 0.40.0
  • Version of Gradle used (if applicable): 6.6
  • Operating System and version: MacOS
  • Link to your project (if it's a public repository): master...jamespfaulkner:false-reporting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants