Skip to the content ForoHackers
Log inJoin

Code review: start here

Code review
#3357 · · Quote · 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

You are not logged in, so this goes up anonymously: no account, no name and no address is stored with it, and it may carry no link and no image. Log in or join to post under your name. Our web server's logs keep the address and time of every request for up to 14 days; to keep yours out of them, use Tor. To reach the staff in confidence, use the drop. Sign as a returning source (a key kept only in this browser)

Sending takes a few seconds here: your browser first works out a proof of work against spam.

Reply