Awesome Reviewers

Reviewer · Null Handling

Deliberate nil handling

Be explicit and intentional about nil, missing, and zero-value cases rather than adding ad-hoc or redundant checks. When a method is meant to tolerate a nil receiver or argument, document that contract and guard it explicitly at the point of use, e.g.:

Instruction

Be explicit and intentional about nil, missing, and zero-value cases rather than adding ad-hoc or redundant checks. When a method is meant to tolerate a nil receiver or argument, document that contract and guard it explicitly at the point of use, e.g.:

// record notes that the cut-off would have failed the query. It is safe to call on a nil tracker.
func (t *cutoffTracker) record() {
	if t != nil {
		t.fired.Store(true)
	}
}

Where possible, prefer a non-nil default/sentinel value over a nullable field so callers don’t need to scatter nil checks, e.g. use encoding.Nop instead of a nil *encoding.Decoder so downstream code can call it unconditionally.

After type assertions or lookups that are expected to always succeed (e.g. decoding a column, casting an interface to a known type), validate the result and fail loudly instead of silently proceeding with a nil/zero value — silent nil propagation on misconfiguration (e.g. a configured sharded-index prefix that can’t be cast) hides bugs that should surface immediately.

When a value’s zero value is ambiguous with “unset” (e.g. protobuf fields), document this ambiguity and decide explicitly whether the zero value is an acceptable default or whether presence must be tracked separately.

Conversely, avoid defensive nil/zero checks that don’t change behavior for valid inputs — if a guard added “just in case” has no effect on any realistic code path, remove it along with its explanatory comment, and add a regression test for the real edge case instead. Likewise, remove nil checks that are already guaranteed by an earlier check in the same scope to keep the code free of redundant conditions.