Unused Private Function
ID |
kotlin.unused_private_function |
Severity |
low |
Remediation Complexity |
medium |
Remediation Risk |
low |
Remediation Effort |
medium |
Resource |
Code Smell |
Language |
Kotlin |
Tags |
dead-code, readability |
Description
Reports private functions that have no call site or function reference within
the enclosing file. Because private visibility limits the scope to the current
file, a lack of any local usage means the function is dead code.
Rationale
Unused private functions accumulate over time as code evolves — they may be leftover from a refactoring or a feature that was never completed. They add noise to the codebase, increase compile time, and can confuse readers who wonder whether the function is "important but not called yet."
class Calculator {
fun add(a: Int, b: Int): Int = a + b
// Bad — never called
private fun legacyCompute(x: Int): Int { // FLAW
return x * 2
}
}
Remediation
Remove the unused function, or, if it is still needed, add a call site or promote it to internal / public visibility.