Placeholder Identifier Name

ID

go.naming_placeholder_identifier

Severity

info

Remediation Complexity

trivial

Remediation Risk

medium

Remediation Effort

low

Resource

Naming Convention

Language

Go

Tags

naming

Description

Reports identifiers — local variables, function and method parameters, and function / method names — whose name matches a configurable placeholder list (foo, bar, baz, tmp, temp, stuff, 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
foo := 1
tmp := ""
func bar() {}

// Good
amount := 1
greeting := ""
func renderInvoice() {}

Exceptions

  • package-level variable declarations — exported names are part of the package API and may legitimately use domain words;

  • method receivers — receiver names follow the receiver-naming convention;

  • test files (names ending in _test.go) — placeholder-name nits in throw-away test scaffolding are noise.

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.