Kirill Zhukov
03/29/2023, 6:25 PMstate = FooState
. Sometimes it’s easy to typo and forget to set the state: FooState
. All of my states are derived from a common State
type, so wondering if there is a rule that makes sure that types of the State
are used.chao
03/29/2023, 7:59 PMtwisterrob
03/30/2023, 3:05 PM@CheckReturnValue
. I don't think there's a Detekt rule that checks dangling objects (or just never written this kind of code). @chao afaiu the use case is:
class SomethingC
object SomethingO
class Other {
fun f() {
this.state = SomethingO // ok, SomethingO.INSTANCE is used
this.state = SomethingC() // ok, constructor's "return value" is used
SomethingO // flag
SomethingC() // flag
}
}
twisterrob
03/30/2023, 3:10 PM.let { MyState(it) }
or when { true -> MyState; else -> error() }
, because these usages are not an assignment, nor a function call.Kirill Zhukov
04/03/2023, 5:15 PM@CheckReturnValue
🙂