Placeholder Identifier

ID

kotlin.naming_placeholder_identifier

Severity

low

Remediation Complexity

trivial

Remediation Risk

medium

Remediation Effort

low

Resource

Naming Convention

Language

Kotlin

Tags

naming

Description

Reports identifiers — local variables, function parameters and function names — whose name matches a configurable placeholder list (foo, bar, baz, tmp, temp, obj, …​). Placeholder names survive from quick prototyping and communicate nothing about the value’s role.

Rationale

A good identifier name documents intent at every use site. Placeholders force the reader to scroll back to the declaration or — worse — to infer the meaning from context, with the risk of mis-reading.

// Bad
val foo = 1
var tmp: String = ""
fun bar() {}

// Good
val amount = 1
var greeting: String = ""
fun renderInvoice() {}

Exceptions

  • class / object members — domain types may legitimately use words like data;

  • names that match the declared type (case-insensitive) — data: Data, error: Error are descriptive bindings;

  • primary-constructor parameters declared with val/var — those are class properties, not locals;

  • bodyless function declarations (interface / abstract methods) — their parameter names belong to an external contract.

The match is case-insensitive but exact, so dataSource and temperature are not flagged.

Parameters

placeholderNames

List of names treated as placeholders. Defaults to [foo, bar, baz, qux, tmp, temp, xyz, myVar, obj, stuff, thing].

Remediation

Rename the identifier to a descriptive term that communicates intent.