Function naming convention (kotlin:S100) should allow starting with a capital


(Jonathan Cornaz) #1

kotlin:S100 raise an issue if a Kotlin function start with capital.


abstract class Foo { ... }

class FooImpl : Foo { ... }

fun Foo(): Foo { return FooImpl(...) } // <-- kotlin:S100 raise an issue

But it is a kotlin convention to name factory-functions like the interface or class returned by the function. And in fact the code example above, comes directly from the official Kotlin convention:

(Kotlin analyzer on SonarCloud

(Jonathan Cornaz) #2

Since function name staring with a Capital letter remains an exception (it only applies for factory functions named after their result type), I’d propose to not change the regex, but instead to skip (not evaluate) the rule if, and only if, the function name is identical to the result type name.

(Alban Auzeill) #6

Hi Jonathan,

Good feedback :+1: , thanks. I created this false-positive ticket SONARSLANG-348