Code Review Best Practices

Chapter 2 · Practice 6 of 6

Read every line you were asked to review, in the context of the whole file

From What to look for in a review

Why it matters

The guide asks reviewers to look at every line of human written code they have been assigned. Data files, generated code and large data structures can be scanned, but logic deserves careful reading. If you cannot understand some code, others will not either, so ask for it to be clarified.

Two habits help:

  • Look at the whole file, not just the diff. A four line change can make a function 50 lines too long, or duplicate a helper ten lines above it.
  • Say what you did not review. If you only reviewed part of the change, for example because a security or database expert should check the rest, write that in your comments so the author knows which parts are still unreviewed.

Finally, the guide reminds reviewers to point out what is good. Telling an author that a test is well structured or a fix is clean is useful feedback too.

Do

  • Expand the diff to see surrounding code before commenting
  • Leave at least one note on what was done well

Avoid

  • Approving after skimming the diff because the tests are green