Project Files
samples / code-review / language-notes.md
Reference this file during code review for language-specific pitfalls.
def f(x=[]) - the list is shared across all calls. Fix: def f(x=None): x = x or []except: catches SystemExit and KeyboardInterrupt. Always use except Exception: at minimum.is vs == - is checks identity, not equality. Never use is to compare strings or integers outside of None checks.open() without with - file handles leak. Always use context manager.f"{counter.increment()}" - avoid.threading.Thread without daemon=True blocks process exit.== instead of - always use strict equality.context.Context propagation in long-running operations - no cancellation support.defer inside a loop runs at function exit, not loop iteration - causes resource leaks.v := m[k] - v is zero value if missing..unwrap() in production code - should be ? or explicit error handling..clone() used to satisfy the borrow checker instead of fixing the ownership model.unsafe blocks without a safety comment explaining the invariants.SELECT * in production code - columns added later silently break assumptions.DELETE or UPDATE without WHERE clause.===async functions that are not awaited silently swallow errors.Promise.all fails fast - unhandled rejections in parallel tasks crash the whole batch.JSON.parse without try/catch throws on malformed input.Array.prototype.sort() without comparator sorts lexicographically, not numerically.any types that could be unknown - forces callers to narrow before use.time.Sleep in tests - use channels or sync.WaitGroup instead.