Kotlin - Force explicit type declarations in IntelliJ IDEA

Viewed 139

For readability purposes, I prefer to write...

val value: Int = 0

...rather than...

val value = 0

...but sometimes, I forget to add the type declaration, which leads to inconsistent code style.

Is there an option to enforce explicit type declarations?

1 Answers

I would write a custom Detekt rule to check that. There's also an IDE plugin for it and it highlights near real time.

Related