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 for no-empty-first-line check with function that returns an anonymous implementation #647

Closed
lwasyl opened this issue Nov 19, 2019 · 4 comments · Fixed by #655

Comments

@lwasyl
Copy link

lwasyl commented Nov 19, 2019

For the following code:

interface Foo {

    fun foo()
}

fun fooBuilder() = object : Foo {

    override fun foo() {
        TODO()
    }
}

KtLint complains for the empty line after Foo { and before override with experimental:no-empty-first-line-in-method-block] First line in a method block should not be empty. This is a false positive, since that empty line is not part of the function declaration, but of a class declaration.

@idntfy
Copy link

idntfy commented Dec 29, 2019

What can be used now to ensure there is no empty line after Foo { and before override?

@Tapchicoma
Copy link
Collaborator

@idntfy most probably it is required new rule, please open a separate issue

@lwasyl
Copy link
Author

lwasyl commented Jan 8, 2020

@idntfy Do you want to treat anonymous classes differently than regular classes?

@idntfy
Copy link

idntfy commented Jan 28, 2020

I want everything to be treated the same way, for me it seems this issue proposes to treat it differently by allowing empty line for anonymous classes while not allowing it in other places

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.

3 participants