Back to all reviewers

Use descriptive identifier names

snyk/cli
Based on 2 comments
Go

Choose specific, descriptive names for variables, functions, types, and parameters that clearly indicate their purpose and avoid generic terms that could be overloaded or ambiguous. Generic names like `Command`, `Config`, or `Data` can become confusing when multiple similar concepts exist in the same codebase.

Naming Conventions Go

Reviewer Prompt

Choose specific, descriptive names for variables, functions, types, and parameters that clearly indicate their purpose and avoid generic terms that could be overloaded or ambiguous. Generic names like Command, Config, or Data can become confusing when multiple similar concepts exist in the same codebase.

When naming identifiers, consider:

  • What specific role or responsibility does this identifier serve?
  • Could this name be confused with other similar concepts in the codebase?
  • Does the name clearly communicate what the identifier contains or does?

Example of improvement:

// Instead of generic name that conflicts with other Command types
type Command struct {
    // ...
}

// Use specific, descriptive name
type NodeCLICommandMeta struct {
    // ...
}

// Instead of ambiguous function name
func GetGlobalConfiguration() []ConfigOption {
    // ...
}

// Use name that clearly indicates what is returned
func GetGlobalConfigurationOptions() []ConfigOption {
    // ...
}

This practice prevents naming conflicts, reduces cognitive load when reading code, and makes the codebase more maintainable as it grows.

2
Comments Analyzed
Go
Primary Language
Naming Conventions
Category

Source Discussions