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

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

Example:

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: https://kotlinlang.org/docs/reference/coding-conventions.html#function-names

(Kotlin analyzer on SonarCloud 7.5.0.19485)

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.

Hi Jonathan,

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

Alban

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.