https://kotlinlang.org logo
#ktlint
Title
# ktlint
c

christophsturm

10/08/2023, 8:38 PM
i get the error
Lint error > [standard:function-naming] Function name should start with a lowercase letter (except factory methods) and use camel case
and I wonder how does ktlint detect factory methods?
p

Paul Dingemans

10/09/2023, 4:27 PM
See code how it is determined. The approach is a bit simplistic and might miss certain cases. But basically the name of the method should be equal to the return type.
c

christophsturm

10/09/2023, 7:30 PM
oh ok so it works only when the result value is explicitly declared, I guess there is no simple way to determine that the only call in a method is a constructor call?
p

Paul Dingemans

10/09/2023, 7:34 PM
ktlint has no semantic knowledge. It can only use the AST of the file which is being processed. But also within that file, it does not lookup other elements for cross checking.
53 Views