File
Blob: docs/reference/detail/review-checklist.md
Code Review Checklist
When reviewing workerd C++ code, check for each of these items.
- Always check for STL leaking in:
std::string,std::vector,std::optional,std::unique_ptr, etc. - Never allow raw
new/delete**. Should bekj::heap<T>()or similar - Never use
throwstatements. Should useKJ_ASSERT/KJ_REQUIRE/KJ_FAIL_ASSERT/etc - Never use
noexcept - Always use
noexcept(false)on explicit destructors - Never use
[=]lambda captures - Never use nullable raw pointers. Should be
kj::Maybe<T&> - Never mixed interface and implementation classes. No data members in interfaces, no non-final virtuals in implementations. Intermediate subclasses are ok
- Never use singletons or mutable globals
- Always verify proper use of
.attach()on promises. Objects must stay alive for the promise duration - Always use
.eagerlyEvaluate()with background promises. Lazy continuations may never execute. Co-routines are eager by default. - Never use manual errno checks. Should use
KJ_SYSCALL/KJ_SYSCALL_HANDLE_ERRORS - Avoid
static_castfor downcasting where possible. Should bekj::downcast<T>(debug-checked) - Avoid
dynamic_castfor dispatch where possible. Extend the interface instead - Never use
std::to_stringor+string concatenation** - Never use
/* */block comments. Use//line comments - Always verify naming convention conformance. TitleCase types, camelCase functions/variables, CAPS constants
- Always check for missing braces around blocks. Required unless entire statement is on one line
- Always avoid
boolfunction parameters. Preferenum classorWD_STRONG_BOOLfor clarity at call sites. E.g.,void connect(bool secure)should bevoid connect(SecureMode mode) - Always use
[[nodiscard]]with functions returning error codes,kj::Maybe, or success booleans that callers must check should be[[nodiscard]] - Always prefer coroutines over kj::Promise chains. Nested
.then()chains with complex error handling that would be more readable as a coroutine withco_await. But always avoid suggesting sweeping rewrites - Always check for missing
constexpr/constevalwhere they would be appropriate - Always avoid reinventing utility with custom code duplicating functionality already in
src/workerd/util/(e.g., custom ring buffer, small set, state machine, weak reference pattern). Always check the util directory before suggesting a new abstraction. - Always check for missing
overrideon virtual method overrides. - Always flag magic numbers (Numeric literals) without explanation or named constants.
- Always check for copyright header on new files. Every new
.c++and.hfile must begin with the project copyright/license header using the current year (not copied from older files). Expected format:
Flag any new file that uses a stale year (e.g.,// Copyright (c) <current-year> Cloudflare, Inc. // Licensed under the Apache 2.0 license found in the LICENSE file or at: // https://opensource.org/licenses/Apache-2.02017-2022in a file created in 2026) or omits the header entirely.