I have factory methods in a companion object that ...
# detekt
j
I have factory methods in a companion object that are inline so that they can use a reified type parameter which are triggering the
MemberNameEqualsClassName
rule. Is inline factory functions a known issue with this rule (or am I perhaps doing something else wrong that's making it trigger)?
b
That's strange. The inline should not affect at all. Could you provide a sample?
j
Copy code
data class FieldInfo<T>(

    val alias: String,
    val extractor: (String) -> T
) {
    companion object {
        // this complains about MemberNameEqualsClassName
        inline fun <reified T> fieldInfo(
            alias: String,
            noinline extractor: (String) -> T
        ): FieldInfo<T> {
            return FieldInfo(alias, extractor)
        }
    }
}
b
It's not related with the inline. The function inside your companion object has the same name as your class so
MemberNameEqualsClassName
flags it. I don't know what's the reason behind this rule but it flags your code correctly. If you don't agree with the rule you can disable it or if you agree with it you should rename the function.
j
Ok, the rule docs claim "factory" functions are allowed though... Not exactly sure what the definition of factory it uses is?
b
No idea you can check the tests of that rule and maybe it gives you some hints. Anyway you can open an issue about this. Because, at least, there is an issue in the documentation
j
👍 thanks, i'll try to find the minimum reproducible case and file one