Function Naming

ID

kotlin.naming_method

Severity

info

Remediation Complexity

trivial

Remediation Risk

medium

Remediation Effort

low

Resource

Code Smell

Language

Kotlin

Tags

naming_convention, style

Description

Reports function declarations whose name does not match the configurable methodNamePattern (default: ^[a-z][a-zA-Z0-9_]*$). Kotlin’s convention requires function names to use camelCase, starting with a lowercase letter. Backtick-escaped names used in test functions are excluded.

Rationale

Consistent camelCase naming makes it immediately clear that an identifier is a function, not a type. Uppercase-starting function names are typically a mistake or a holdover from another language’s convention.

// Bad — starts with uppercase
fun ProcessData() {}  // FLAW
fun GetUser(): String = ""  // FLAW

// Good
fun processData() {}
fun getUser(): String = ""

// OK — backtick-escaped test name
fun `should return empty list when no items`() {}

Remediation

Rename the function to start with a lowercase letter following camelCase.