Does detekt have for body expression functions tha...
# detekt
e
Does detekt have for body expression functions that return Unit and have no explicit return type specification?
1
e
Kinda, I more about preference to write
fun x(): Unit
by
fun x() {}
but this looks like really subjective and no objective reasons
b
They add unit as an exception. I guess that you could adapt that rule to get your desired behaviour.
It could be a flag on detekt or just a custom rule on your side.
e
Thanks, we enabled explicit mode and I refactored construction
fun x() = z()
to
fun x() { z() }
. Which is not agreed style and my personal preference. While I should do instead
fun x(): Unit = z()
to provide implicit API and keep original author intention.
So I was looking for Detekt rule which in most have some objective thinking behind. And finally, I realised that this is pure subjective style.
I hope it is more clear the context about my original message
b
I see. No, there is nothing on detekt to accomplish that. But a custom rule could make the job.
Ktlint also have a similar rule. But I think that unit is an exception for them.
e
Thanks again for the discussion! Super valuable to find mine bias and correct it.