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

Ktlint deleting semicolon and adding trailing comma after companion object in Enum class #1758

Closed
Ab0o0o0oD opened this issue Jan 3, 2023 · 1 comment

Comments

@Ab0o0o0oD
Copy link

Ab0o0o0oD commented Jan 3, 2023

Expected Behavior

I have an enum class with statics function in the companion object:

enum class Foo(val type: String){
      A("a"),
      B("b");

companion object {
      fun from(value: String): Foo {
                  return try {
                      valueOf(value)
                  } catch (e: IllegalArgumentException) {
                      // find by type
              }
          }
}

Observed Behavior

ktlint --format deleting the the semicolon ; and adding a trailing comma , after the companion object and raising error:

Not a valid Kotlin file (12:27 expecting ';' after the last enum entry or '}' to close enum class body) (cannot be auto-corrected) ()

enum class Foo(val type: String){
      A("a"),
      B("b")

companion object {
      fun from(value: String): Foo {
                  return try {
                      valueOf(value)
                  } catch (e: IllegalArgumentException) {
                      // find by type
              }
          },
}

Steps to Reproduce

  • Perform ktlint --format

Your Environment

  • Version of ktlint used: 0.48.0
  • Relevant parts of the .editorconfig settings: not applicable
  • Operating System and version: Ventura 13.1
@paul-dingemans
Copy link
Collaborator

Duplicate of #1733. Will be fixed in 0.48.1.

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

No branches or pull requests

2 participants