Unused Function Parameter

ID

kotlin.unused_function_parameter

Severity

low

Remediation Complexity

medium

Remediation Risk

low

Remediation Effort

medium

Resource

Code Smell

Language

Kotlin

Tags

dead-code, readability

Description

Reports function parameters that are never referenced inside the function body. Parameters prefixed with _ and parameters of override functions are excluded.

Rationale

An unused parameter clutters the API, increases cognitive load for callers, and often indicates either dead code or a logic error (the author intended to use the parameter but forgot).

// Bad — b is declared but never used
fun add(a: Int, b: Int): Int { // FLAW
    return a
}

// Good — use both parameters
fun add(a: Int, b: Int): Int = a + b

// Also good — _ prefix marks deliberate non-use
fun onEvent(_event: String) {
    println("event fired")
}

Remediation

Either use the parameter in the body, remove it from the signature, or prefix the name with _ to signal that it is intentionally ignored.