A private function or property is never used in its file

tx0/kotlin:private-member-never-usedrecommendedwarningmaintainability/dead-codedepth fastsmell

What it finds

A private declaration can only be used in its file. When its name appears nowhere else in the file, not even in a callable reference or a string template, it is dead code. Declarations with annotations, which frameworks may call by reflection, and operator, override and serialization functions are left alone.

From the rule's source, unused_private_member.rs.

Example from the rule's tests
class Service {    private val used = 1    private val unused = 2tx0 reports: the private property unused is never used    private fun helper() = usedtx0 reports: the private function helper is never used    private fun referenced() = 3    @Inject    private lateinit var injected: Any    private val serialVersionUID = 1L     fun run() = listOf(1).map { it + referenced() }} private fun topLevel() = 1tx0 reports: the private function topLevel is never usedprivate fun byReference() = 2val reference = ::byReference
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/kotlin:private-member-never-used" = "warning"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/kotlin:private-member-never-used] reason="..."

tx0 explain tx0/kotlin:private-member-never-used shows the same in the terminal. Found a false positive? Report it.