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

Ktlint removes curly braces from empty companion object #411

Closed
charlie-mcknight opened this issue May 1, 2019 · 3 comments · Fixed by #600
Closed

Ktlint removes curly braces from empty companion object #411

charlie-mcknight opened this issue May 1, 2019 · 3 comments · Fixed by #600
Labels

Comments

@charlie-mcknight
Copy link

charlie-mcknight commented May 1, 2019

This can cause code to not compile. One instance is if you have another class or enum declared below it. It isn't a huge issue though because you probably shouldn't have empty companion objects lying around.

ex.

class Example {
    companion object {}
    enum class ExampleEnum {
        EXAMPLE
    }
}

is formatted to the code below which does not compile.

class Example {
    companion object
    enum class ExampleEnum {
        EXAMPLE
    }
}
@shashachu
Copy link
Contributor

Ah thanks for the report. Yes not a big deal since it's pretty obvious what the problem is, but the formatter should probably not make your code stop compiling. :)

@shashachu shashachu added the bug label May 6, 2019
@kartdroid
Copy link

Can we override the existing klint rules via configuration?

@shashachu
Copy link
Contributor

@ckarthickit you can disable rules globally via an .editorconfig property or --disabled_rules CLI but the rules themselves are generally not configurable.

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

Successfully merging a pull request may close this issue.

3 participants