Back to all reviewers

Consistent descriptive naming

prometheus/prometheus
Based on 13 comments
Go

Ensure variable, function, and type names are consistent, descriptive, and follow Go naming conventions. Names should clearly convey their purpose and maintain consistency across related components.

Naming Conventions Go

Reviewer Prompt

Ensure variable, function, and type names are consistent, descriptive, and follow Go naming conventions. Names should clearly convey their purpose and maintain consistency across related components.

Key principles:

  • Use descriptive names that accurately reflect functionality rather than generic terms
  • Maintain consistent naming patterns across related components (e.g., EnableTypeAndUnitLabels vs AddTypeAndUnitLabels)
  • Follow Go conventions: omit “Get”/”List” prefixes for accessors, use camelCase for JSON fields, proper casing for initialisms
  • Avoid misleading names where the name doesn’t match the actual behavior

Examples:

// Bad: Generic and inconsistent
func validateAttributes(attrs []string) // actually modifies input
var DefaultRegistry = prometheus.NewRegistry() // in main.go, shouldn't be exported
func handleOtlp(...) // inconsistent casing of initialism

// Good: Descriptive and consistent  
func sanitizeAttributes(attrs []string) // clearly indicates modification
var registry = prometheus.NewRegistry() // unexported, no misleading "Default"
func handleOTLP(...) // consistent initialism casing
func BlockMetas() []BlockMeta // follows Go getter convention
func parseGoDuration(d string) time.Duration // accurately describes return type

This approach reduces cognitive load, improves code maintainability, and ensures the codebase follows established Go idioms.

13
Comments Analyzed
Go
Primary Language
Naming Conventions
Category

Source Discussions