Skip to the content ForoHackers
Log inJoin

Code review: start here

Code review
#851 · Ophuscado · · Report

Code review is having someone other than the author read a change before it is merged. It catches bugs and design problems early, spreads knowledge of the codebase, and keeps style consistent. Done well it is a conversation about the code, never about the person, and it is a skill for the reviewer as much as for the author.

Key concepts

  • Small changes: a review of a few hundred lines gets real attention; a huge one gets a rubber stamp.
  • What to look for: correctness, tests, design, naming, security, and whether the change does what it claims.
  • Automate the rest: formatters, linters and CI handle style so humans can think about meaning.
  • Tone: ask questions, explain the reason, separate "must fix" from "nit", and praise what is good.
  • Author's duty: describe the why, review your own diff first, and answer comments without defensiveness.

Vocabulary

  • Pull request: a proposed change, with its discussion, before it is merged.
  • Nit: a minor, optional remark about style.
  • LGTM: "looks good to me", an approval.
  • Linter: a tool that flags suspicious or non-idiomatic code.

What to study, in order

  1. Review your own diff line by line before asking anyone, and note what you would flag.
  2. Read reviews on a well-run open source project and note how they are worded.
  3. Write a checklist for your language: error handling, resource cleanup, concurrency, input validation.
  4. Set up a formatter and a linter so the checklist shrinks.
  5. Practise reviewing for design: does this belong here, and will the next person understand it?

Related tags

#version-control #testing #open-source #secure-coding

Log in or join to reply.