Glossary termPractice

Code Review

Also known as: Peer code review, Code inspection

Practice in which developers examine each other's source code changes to find defects, share knowledge and keep the codebase consistent.

Code review is the systematic examination of source code by people other than its author, usually before the code is merged. Reviewers read a proposed change looking for bugs, security problems, unclear logic, missing tests and departures from the project's conventions, then approve it, request changes or ask questions. In most teams review happens on a pull request, where comments can be attached to specific lines. Reviews range from a quick look by one colleague to multi-person sign-off required for sensitive systems.

Formal review has a long history. Michael Fagan at IBM described a structured inspection process in a 1976 paper, with defined roles, checklists and meetings, and reported that inspections caught many defects early, when they were cheapest to fix. Later practice became lighter and tool-based: open source projects reviewed patches on mailing lists, and review then moved to web platforms such as GitHub and Gerrit. The open-source maxim known as Linus's law expresses the hope that broad public review makes bugs easier to find.

Beyond catching defects, review spreads knowledge of the codebase across a team, improving its bus factor and helping newer developers learn. Studies of review at large companies have found that much of its value lies in knowledge transfer and code improvements rather than in finding bugs alone. Reviews can also become bottlenecks or sources of friction, and reviewers miss subtle problems, as the long survival of some security flaws in widely used open-source code shows. Automating style checks with linters lets human reviewers focus on design and correctness.

Key points

  • Code review has other developers examine changes for bugs, security issues, clarity and consistency.
  • Michael Fagan formalized code inspections at IBM in a 1976 paper.
  • Review spreads knowledge of the codebase and reduces dependence on individual developers.
  • Automated linters and tests free reviewers to concentrate on design, correctness and security.

Related entries

Glossary term

Pull Request

ProgrammingFOSS

Proposal to merge a set of code changes from one branch or fork into another, used as the focal point for review and discussion.

Glossary term

Linting

Programming

Automated checking of source code for likely errors, suspicious constructs and style violations using a tool called a linter.

Glossary term

Static Analysis

ProgrammingCybersecurity

Examination of source code or binaries without executing them, using automated tools to find bugs, security flaws and quality issues.

Glossary term

Unit Testing

Programming

Practice of verifying that small, individual pieces of code, such as single functions or classes, behave correctly when tested in isolation.

Glossary term

Principle, named after Linus Torvalds, that with enough reviewers and testers almost every software bug will be found quickly and easily fixed.

Glossary term

Bus Factor

FOSSDevOps

Minimum number of team members whose sudden loss would leave a project unable to continue, a measure of concentrated knowledge risk.

Glossary term

Version Control

ProgrammingDevOps

System that records changes to files over time so that people can track history, revert mistakes and collaborate on the same codebase.

Technology

GitHub

ProgrammingFOSS

Web platform owned by Microsoft for hosting Git repositories and collaborating on software through pull requests, issues and automation.

Featured in guides

Referenced by

Other entries that discuss or point to Code Review.