Back to all reviewers

Use descriptive names

traefik/traefik
Based on 7 comments
Go

Choose names that clearly express the purpose, behavior, or semantic meaning of variables, functions, and types. Avoid ambiguous or generic names that require additional context to understand their role.

Naming Conventions Go

Reviewer Prompt

Choose names that clearly express the purpose, behavior, or semantic meaning of variables, functions, and types. Avoid ambiguous or generic names that require additional context to understand their role.

Key principles:

  • Make boolean nature explicit: regexisRegex
  • Describe actual functionality: ParseDomainsAndRegexParseHostMatchers
  • Clarify behavior over generic terms: CustomResponseWriterStatusRecorder
  • Distinguish between similar concepts: FailTimeoutFailureWindow (time window vs timeout duration)
  • Be explicit about quantities: MaxFailsMaxFailedAttempts
  • Align with actual logic: downup when variable represents “up” status
  • Use explicit constants over magic values: defaultCacheDuration instead of cache.DefaultExpiration

Example:

// Ambiguous - what kind of timeout?
type PassiveHealthCheck struct {
    FailTimeout ptypes.Duration
    MaxFails    int
}

// Clear - describes the time window and explicit count
type PassiveHealthCheck struct {
    FailureWindow      ptypes.Duration
    MaxFailedAttempts  int
}

This approach reduces cognitive load, prevents misunderstandings, and makes code self-documenting.

7
Comments Analyzed
Go
Primary Language
Naming Conventions
Category

Source Discussions