Awesome Reviewers

Reviewer · Naming Conventions

Semantically precise identifiers

Choose names for functions, methods, variables, constants, and packages that precisely and unambiguously describe what they do or represent, not just a loose approximation. Before naming, check for hidden side effects (mutation, locking requirements, fallback behavior, side-channel writes), units of measurement, and whether the concept already has an...

Instruction

Choose names for functions, methods, variables, constants, and packages that precisely and unambiguously describe what they do or represent, not just a loose approximation. Before naming, check for hidden side effects (mutation, locking requirements, fallback behavior, side-channel writes), units of measurement, and whether the concept already has an established naming pattern elsewhere in the codebase, and reflect all of that in the name.

Specifically:

  • If a function has a side effect beyond what its name implies, either rename it to reveal the effect or split it into a pure part and an effectful part. E.g. a validate() method that also deletes invalid entries should be validateAndClean(); a scan() method that actually schedules/starts compaction jobs should be named compact()/run(); a start() method that only initializes internal state (not a service/goroutine) should be init().
  • When a function must be called under a precondition (e.g. “call only while holding a lock”), prefer an active name like lockThenPush over a passive one like pushLocked, which can be misread as “safe to call while locked” rather than “requires the lock already held.”
  • Include units and qualifiers in names (variables, config flags, metrics) whenever the value could be ambiguous, e.g. use maxRunSizeBytes/uncompressedMaxRunSizeBytes instead of maxRunSize, and loki_dataobj_builder_object_size_compressed_bytes instead of loki_dataobj_builder_object_size_bytes.
  • Follow existing naming conventions for sibling/related identifiers instead of introducing a new scheme: if Overlaps/OverlapsClosed denotes half-open vs. closed ranges, a new Covers method should follow the same pattern (Covers/CoversClosed) rather than inventing CoversOpen.
  • Avoid two identifiers in the same scope that differ only by a prefix/suffix of the same word (e.g. ctx and vctx, or a parameter named index representing an indexRun), as this is easy to misread; pick clearly distinct names instead.
  • When a value’s meaning shifts (e.g. an enum like KindLogs used to represent an object kind, not a cache kind), keep the name aligned with what the value actually represents, and rename if a refactor changes that meaning.
  • For packages, avoid stuttering or redundant names (e.g. logqlmodel/logqlerr); prefer a short, non-redundant name such as errors, using import aliases where collisions could occur.

Apply this as a review checklist: read the name aloud as if you were a new contributor, decide what you’d assume it does, and confirm the implementation matches that assumption exactly.