Code review is a systematic check of changes by other people before they reach the main branch. The author posts the changes for review, colleagues read them and point out what to fix. As a result fewer bugs reach the codebase, and the team keeps a consistent style and shares knowledge.
How a review goes
| Stage | What happens |
|---|---|
| Submitting for review | the author prepares a pull request (PR) with a small number of changes and describes what was done and why |
| Reading and comments | the reviewer reads the code and leaves comments: what to fix, what to clarify, where there is a simpler option |
| Fixes | the author replies or reworks the code; disputed points are discussed, and a third developer is brought in if needed |
| Decision | on Git hosting services such as GitHub, the reviewer leaves Comment, Approve or Request changes; once approved, the pull request is merged into the main branch |
What is checked
- Soundness of the solution: how the change fits into the system and whether it duplicates existing mechanisms; for a reviewer this matters more than small style points.
- Correctness: whether the code solves the task and whether there are logic errors or unhandled cases.
- Security: handling of user input, handling of secrets, access rights.
- Clarity: clear names, a consistent style, no unnecessary complexity.
- Tests: whether they are added in the same change and whether they catch real bugs rather than passing only on paper.
How much code and how much time
The smaller the change, the more carefully it is reviewed. In Google’s code review guide, a reasonable size is around a hundred lines, and a change of a thousand lines is usually too large: the reviewer may ask for it to be split into parts. The response to a review request is limited there to one working day: long waits slow down the whole team and push authors to look for ways around the process.
Forms of review
One of the first formalised review procedures was Michael Fagan’s inspection at IBM, which he described in a 1976 paper as a formal meeting with defined roles and a checklist-based search for defects. Today the main form is reviewing pull requests on a Git hosting service; there are also group walkthroughs and pair programming, where two people write the code together from the start. Perfection is not required in review: a change is approved if it improves the state of the codebase, and minor comments are marked Nit:, meaning they do not have to be fixed.
Sources
the term is written from these pages- Google Engineering Practices — The Code Review Guidelinesgoogle.github.io/eng-practices/review/(opens in a new tab)
- GitHub Docs — Pull request reviewsdocs.github.com/en/pull-requests/reference/pull-request-reviews(opens in a new tab)
- М. Фаган. Design and Code Inspections to Reduce Errors in Program Development (IBM Systems Journal, 1976)doi.org/10.1147/sj.153.0182(opens in a new tab)
Verified 9 Nov