Add a code review skill with reference files for memory safety, concurrency, correctness idioms, false positives, cppreference lookup, and report format. Move the coding conventions from AGENTS.md into the skill's project-style reference so reviews enforce them. Co-authored-by: Qwen 3.8 27B <qwen3.8_27b-q3_k_xl@lmstudio.local>
1.7 KiB
1.7 KiB
Correctness & Modern Idioms
Docs: cppreference language/library pages; C++ Core Guidelines.
Errors & exceptions
- Errors aren't silently ignored (unchecked return codes, empty
catch (...)). - Mark functions whose result must be used
[[nodiscard]]. - Exception safety: on throw, no leaks and objects stay valid (RAII gives this for free).
- Destructors and move operations are
noexcept; no throwing from destructors. - Catch exceptions by const reference (
catch (std::exception const& e)). - Consider
std::optional/std::expected(C++23) for expected failures, per project style.
Types & integers
- Fixed-width integers: use the project's aliases (
u32,i64, ...) instead ofstd::uint32_tetc., e.g. for sizes in protocols, files, and hardware. - Signed/unsigned comparison and mixing (
intvssize_t); usestd::cmp_lessetc. (C++20) orstd::ssize. - Narrowing conversions are explicit and checked; prefer
{}initialization to catch them. - No implicit conversions via single-arg constructors; mark them
explicit. enum classover plainenum.
API & classes
constcorrectness: methods, references, and parameters.- Pass cheap types by value, large read-only by
const&, sinks by value +std::move. overrideon virtual overrides;finalwhere intended.- No object slicing (passing derived by value as base).
- Header hygiene: include what you use, no
using namespacein headers.
Modern idioms
- Prefer standard algorithms and range-for over hand-rolled loops.
constexprfor compile-time constants instead of macros.std::string_view/std::spanfor non-owning parameters (watch lifetimes).- New logic has tests; edge cases (empty, max, error path) are covered.