David Kubecka
08/16/2024, 10:23 AMfun someFun(): Int {
// ...
}
with some context-adding function. For instance binding
from kotlin-result:
fun someFun(): Int = binding {
// ...
}
Unfortunately, this violates two rules: standard:function-signature and standard:multiline-expression-wrapping. I would like to avoid the reformat since it increases the indentation of the whole function body, thereby unnecessarily crippling git history.
Since both these rules might be useful in different contexts I hesitate to simply switch them both off. Would it be possible to relax (possibly optionally - based on a setting) these rules in this situation? I.e. allow the function block to start on the same line as the function header.Paul Dingemans
08/16/2024, 11:41 AMDavid Kubecka
08/16/2024, 11:56 AMEmil Kantis
08/16/2024, 12:52 PMDavid Kubecka
08/16/2024, 1:05 PMval someReallyLongEnterpriseGradeValName = someReallyLongEnterpriseGradeFunName(par1, par2) {
doSomething1()
// ...
}
That looks quite strange to me and I would rather force this to
val someReallyLongEnterpriseGradeValName =
someReallyLongEnterpriseGradeFunName(par1, par2) {
doSomething1()
// ...
}
The situation is different, however, for function bodies because a natural (and also ktlint) way to write a function is
fun someFun(): Int {
// ...
}
and not
fun someFun(): Int
{
// ...
}
So having to change the layout just because I formally convert from block to expression body is IMO wrong.Paul Dingemans
08/16/2024, 1:13 PMIsn't the function-signature check duplicate with the one from multiline-expression-wrapping?Yes, there is some overlap. It is there for backwards compatibility with users who have disabled the
function-signature
.David Kubecka
08/16/2024, 2:48 PMPaul Dingemans
08/21/2024, 3:45 PMDavid Kubecka
08/22/2024, 9:11 AMPaul Dingemans
08/22/2024, 10:32 AM