Code review is the examination of source code by someone other than, or in addition to, its author to assess correctness, maintainability, security, and suitability for a software system. In contemporary software engineering, it usually concerns a proposed change rather than an entire program: reviewers inspect a patch, discuss its implications, and either request revisions or approve it for integration. The term also encompasses structured inspections, informal peer checking, and specialized examinations of existing code.
Review complements software testing by evaluating properties that execution alone may not reveal, such as whether a design is unnecessarily complicated, an interface expresses the intended contract, or an implementation relies on an undocumented assumption. It also distributes knowledge about a system and creates a record of technical decisions. Its effectiveness depends on the review process, reviewer expertise, the size and presentation of changes, and the relationship between human judgment and automated checks. Approval is evidence that a change has undergone examination, not proof that it is free of defects.
Historical development and major forms
Systematic examination of programs predates modern online collaboration platforms. An influential formalization was Michael E. Fagan’s 1976 paper, “Design and Code Inspections to Reduce Errors in Program Development,” which described inspection practices developed at IBM. Fagan treated inspection as an organized engineering activity with defined roles, preparation, defect recording, and follow-up. The approach applied to design documents as well as code, reflecting the principle that defects can be detected before a program is executed.
A traditional software inspection separates several activities that informal review may combine. Participants prepare individually; a moderator manages the process; a reader may present or paraphrase the work; and identified defects are recorded for correction. Discussion is directed toward finding problems rather than redesigning the system during the meeting. Entry and exit criteria help determine whether an artifact is ready for inspection and whether identified issues have been addressed. These procedures offer traceability but require scheduling and administrative effort.
Lightweight peer review developed around less ceremonial practices: a colleague examining a patch, comments exchanged through email, or a short discussion at a workstation. The growth of open-source software made asynchronous review particularly important because contributors were often geographically dispersed. Mailing-list review remains significant in projects such as the Linux kernel, where patches, explanations, and successive revisions are discussed in public threads. In that setting, review is closely tied to subsystem maintainership and the conventions of patch submission.
Modern review platforms connect discussion directly to version control. Systems such as Gerrit and the review facilities of GitHub and GitLab display differences between revisions, attach comments to specific lines, and record approval states. A pull request, also called a merge request on some platforms, packages a proposed integration together with discussion and automated results. The request is a collaboration object; review is one of the activities performed through it.
Other practices overlap with review without being identical to it. In pair programming, two developers work together during implementation, providing continuous scrutiny rather than a separate retrospective examination. A walkthrough often emphasizes explanation and shared understanding, whereas an inspection emphasizes defect detection. A security audit may inspect code independently of its development history. These forms differ in timing, independence, and required evidence; none is simply a more elaborate version of every other form.
Objectives, scope, and limits
The most immediate objective of review is to identify defects before they become part of a shared system. Reviewers compare an implementation with requirements, interface contracts, and the behavior expected by surrounding code. A function can produce the right result for ordinary inputs yet mishandle an empty collection, fail after a partial operation, or violate an assumption made by its callers. Review is especially valuable when the relevant requirement is implicit or spread across several components.
Maintainability is a separate objective. Reviewers assess whether names communicate meaning, abstractions correspond to real concepts, and control flow can be understood without reconstructing hidden reasoning. A correct implementation may still introduce duplication or couple unrelated components. Such changes can create technical debt: design or implementation conditions that increase the cost of later work. Review does not require eliminating every imperfection; it distinguishes problems introduced by the current change from pre-existing conditions that may belong in separate work.
The proper unit of examination is often broader than executable statements. Tests, documentation, build definitions, configuration, database migrations, and deployment instructions can all determine whether a change works. A modification to an application programming interface may require coordinated changes to clients and compatibility guarantees. A configuration change that reduces a timeout can alter production behavior more substantially than a much larger refactoring.
Review also checks consistency with software architecture. For example, a module intended to isolate storage details should not expose a database-specific object through its public interface. A local shortcut may work immediately while undermining the boundary on which other components rely. Conversely, architectural review should not become an unrestricted opportunity to redesign unrelated parts of the system. The distinction between necessary correction and optional improvement is central to keeping review bounded.
Code review has fundamental limits. A reviewer sees selected artifacts and may lack production workloads, operational history, or complete requirements. Source inspection cannot by itself establish measured performance or demonstrate behavior under every possible execution. Formal verification can establish specified properties under explicit assumptions, whereas ordinary review provides expert judgment without such a proof. Even formal results leave questions about specification adequacy and deployment conditions. Review therefore belongs within a broader assurance process rather than serving as a universal quality gate.
Change-based workflow and approval semantics
A typical review begins with an author preparing a coherent change and explaining its purpose. The explanation identifies the problem, the chosen approach, relevant constraints, and evidence from testing. A useful change description distinguishes intended behavior from incidental implementation details. Reviewers otherwise have to infer the goal from the patch, which makes it harder to recognize a technically plausible implementation of the wrong requirement.
The author selects reviewers or a system suggests them using ownership rules and development history. Selection involves different kinds of expertise: familiarity with the affected component, understanding of the business requirement, and knowledge of a specialized concern such as security or storage. A maintainer responsible for an area need not be the person most qualified to assess every aspect of a change. Some projects therefore distinguish ordinary comments, domain-specific approval, and permission to integrate.
The reviewer examines the proposed revision against its base version, often using Git history and surrounding files to reconstruct context. Comments may identify defects, ask questions, request evidence, or suggest alternatives. These categories have different consequences. A question can expose a genuine ambiguity without implying that the implementation is wrong, while a blocking finding indicates that a condition must be resolved before acceptance. Explicit severity and rationale reduce uncertainty about what the author is expected to change.
Revision creates a second review problem: determining what has changed since the earlier examination. Review tools may display incremental differences, mark earlier comments as outdated, or preserve discussion across rewritten commits. An approval usually refers to a particular state of the change. If new commits substantially alter behavior, the earlier approval may no longer constitute meaningful review. Branch policies can require renewed approval, but their exact behavior depends on repository settings.
Integration is distinct from approval. A change may receive favorable review yet remain blocked by failed checks, a conflicting update, or a release restriction. Conversely, a successful automated build does not supply human approval. Systems may require specified reviewers, passing checks, or an up-to-date base before merging. The reviewed content must remain connected to the content actually integrated; merge conflict resolutions can introduce code that no reviewer previously examined.
Post-integration review is also possible, especially for urgent repairs or workflows organized around continuous submission. It shifts the timing of risk rather than eliminating review. The process must then account for what happens when a serious issue is discovered after deployment, including correction, rollback, and examination of related changes.
How reviewers reason about code
Effective examination combines local reading with reconstruction of system behavior. A line-by-line scan can reveal a suspicious expression, but many important defects arise from relationships between files or operations. Reviewers commonly begin with the purpose of the change, locate its entry points, and trace the data and control flow through affected components. This creates a model against which individual implementation choices can be assessed.
One technique is to identify invariants: properties that must remain true before and after an operation. In a transfer operation, for example, preserving the total balance is insufficient if an intermediate state becomes externally visible or if a retry repeats only one side of the transfer. Review then extends to transaction boundaries, error handling, and repeated execution. For an algorithm, the reviewer may inspect a loop invariant or examine whether termination and boundary conditions follow from the implementation.
Boundary analysis concentrates attention on cases that ordinary examples omit. Typical questions concern zero elements, one element, maximum values, malformed input, unavailable dependencies, and interrupted operations. In the C programming language, an expression can be mathematically sensible yet behave differently because of signed integer overflow or an invalid memory access. Review requires reasoning about the actual language semantics rather than an idealized arithmetic interpretation.
Concurrency requires reasoning about possible interleavings. In concurrent computing, code that is correct when executed alone may fail when another execution changes shared state between a check and an update. Reviewers examine ownership, synchronization, lock ordering, and object lifetime. Acquiring two locks in inconsistent orders can introduce deadlock even if each protected operation is individually correct. Tests may not reproduce the problematic scheduling frequently enough to expose it.
Performance review similarly distinguishes plausible concern from evidence. A nested scan can change the growth of work from approximately to , but the practical significance depends on input sizes and execution frequency. Reviewers may identify the need for measurement without claiming to predict exact latency from source code. An extra query inside a loop, for example, can matter because of network round trips rather than processor instruction count.
The surrounding tests are themselves review material. Reviewers inspect whether assertions express the intended contract, whether failure paths are covered, and whether fixtures accidentally exclude relevant cases. A test that merely duplicates implementation logic may reproduce the same mistake instead of independently checking behavior. Readable examples and explicit expected results can therefore contribute more than a large number of superficially distinct test cases.
Tool support and automated checks
Review platforms reduce the mechanical cost of comparing revisions and coordinating discussion. Their central display is usually a diff showing added, removed, and unchanged lines. Other features include file navigation, suggested edits, threaded comments, reviewer assignment, and a history of decisions. These facilities make distributed collaboration practical, but the interface also shapes attention: reviewers may focus on highlighted lines and overlook unchanged code whose assumptions have been invalidated.
Automated checks remove repetitive tasks from human review. A compiler can reject many syntactic and type errors; formatters impose consistent layout; and linters detect selected suspicious patterns. Static program analysis examines code without executing the particular program under review, using methods ranging from simple syntax rules to data-flow analysis. For example, an analyzer may track whether an untrusted value can reach a sensitive operation without passing through an appropriate check.
These techniques have different guarantees. Some analyses approximate possible behavior conservatively and can report paths that cannot occur in practice. Others deliberately use narrower heuristics to keep results actionable and may miss real defects. A clean report therefore means that the configured analysis did not report a problem, not that the program contains no problems. Reviewers need to understand the tool’s scope rather than treating every automated result as equivalent evidence.
Continuous integration connects changes to repeatable builds and tests. A review page may aggregate unit-test results, compatibility checks, security scans, and packaging outcomes. The environment and configuration matter: a passing test on one operating system does not establish compatibility with every supported platform. Changes to the checks themselves also require scrutiny, because disabling a test or excluding a directory can make a defective change appear healthy.
Testing tools can deepen the available evidence. Mutation testing modifies program behavior in controlled ways to see whether tests detect the changes. Fuzzing explores many inputs, often guided by execution feedback, to discover crashes or other failures. Neither replaces review: mutation results require interpretation, and a discovered fuzzing input does not necessarily explain the architectural cause of the failure. Their outputs give reviewers concrete questions to investigate.
Automation also creates administrative risks. Bot comments can overwhelm a discussion if duplicated or poorly prioritized. Check configurations may become stale, and a trusted-looking status can conceal that the relevant job never ran. Separating mechanical failures, suspected defects, and advisory findings helps preserve the meaning of review. In a continuous delivery system, this distinction is especially important because approval and successful checks may lead quickly to release.
Security review and trust boundaries
Security review examines how a change behaves when inputs, callers, dependencies, or execution conditions are adversarial. Ordinary functional review asks whether authorized behavior works; security review also asks whether unauthorized behavior becomes possible. Its scope is informed by a threat model identifying protected assets, attacker capabilities, and trust boundaries. Without that context, a reviewer may concentrate on familiar coding patterns while missing the operation that actually exposes sensitive data or authority.
Input handling is a common focus. In code that constructs SQL commands, reviewers distinguish data passed through parameter binding from data concatenated into executable query syntax. Escaping is not a universal substitute for preserving this separation. Similar reasoning applies to operating-system commands, generated markup, and file paths. The relevant question is how the receiving interpreter treats the value, not whether it looks harmless in the language that constructed it.
Authorization errors often appear in otherwise correct application logic. Authentication establishes an identity, whereas access control determines what that identity may do. A handler can authenticate a caller and still expose another user’s record if it fails to check ownership or tenant boundaries. Review therefore follows authority through the complete operation, including indirect calls, background jobs, and alternate entry points, rather than looking only for a login check.
Memory and resource management introduce different risks. A buffer overflow may arise from incorrect length calculations, while an object-lifetime error may leave a reference usable after its storage has been released. Resource exhaustion can occur even in memory-safe languages: unbounded input expansion, excessive work per request, or unlimited connection creation can enable a denial-of-service attack. Security review consequently includes algorithmic and operational behavior, not only dangerous library calls.
Changes involving cryptography require attention to established constructions, key handling, randomness, and protocol context. The presence of a recognized algorithm does not establish that its use is secure. A reviewer may need specialized expertise to assess nonce requirements or whether a signature covers all security-relevant fields. Diagnostic logging also deserves examination because credentials or personal data can escape through a path unrelated to the main function’s return value.
Finally, review is itself part of a trust process. A malicious change may be disguised as maintenance, spread across revisions, or accompanied by misleading tests. Separation between author and approver, controlled repository permissions, and review of build and dependency changes reduce opportunities for unnoticed modification. Human approval is not an authentication mechanism for every upstream artifact, however, and cannot substitute for a broader software supply-chain security process.
Collaboration, ownership, and decision-making
Code review is both a technical examination and an organizational negotiation over shared software. Authors possess detailed knowledge of the implementation they have just produced; reviewers may know historical constraints, operational failures, or future plans that the author has not encountered. Productive discussion makes these different sources of knowledge explicit. A comment explaining that a client relies on a particular behavior conveys more durable information than an unexplained instruction to change it.
Review comments vary in authority. Some express correctness requirements, others enforce an agreed convention, and others offer personal preference. Confusing these categories can prolong discussion without improving the software. Projects often distinguish blocking issues from optional suggestions and defer formatting to tools. This does not remove judgment, but it narrows debate to questions for which human interpretation is useful.
Ownership structures influence both quality and throughput. Requiring approval from a component owner can preserve local expertise and accountability. Excessively concentrated ownership can also create queues and leave a project dependent on a few individuals. Broader reviewer participation distributes understanding, although less experienced reviewers may need assistance on subtle changes. A reviewer can assess a specific concern without being expected to certify every aspect of the system.
The interaction has an educational role. Review exposes contributors to unfamiliar modules, design conventions, and debugging techniques through concrete work. It can also reveal where code is difficult to understand. If a competent reviewer repeatedly misreads an operation, the problem may lie in the implementation or documentation rather than solely in the reader. An explanation written only in the review thread may be insufficient when future maintainers need the same information.
Asynchronous work introduces delay and communication constraints. A short comment can lose the context available in a conversation, while a synchronous meeting can exclude participants in other time zones. Teams therefore use a mixture of written review and direct discussion. When a discussion moves elsewhere, recording the technical decision alongside the change preserves its usefulness for people who were not present.
Disagreement is not necessarily evidence of a failed process. It can expose a requirement that was never settled or a trade-off between compatibility and simplicity. Resolution depends on project governance: a designated maintainer, architectural decision process, or documented convention may determine the outcome. Counting approvals does not automatically settle a technical issue, and review does not become more rigorous merely by adding participants who all assume that someone else has examined the difficult part.
Empirical evaluation and process design
Research on review distinguishes formal inspections from contemporary, tool-supported peer review. Alberto Bacchelli and Christian Bird’s 2013 study, “Expectations, Outcomes, and Challenges of Modern Code Review,” examined industrial practice and emphasized that review serves purposes beyond defect discovery, including knowledge transfer and team awareness. Caitlin Sadowski and colleagues’ 2018 study, “Modern Code Review: A Case Study at Google,” described a large-scale implementation of lightweight review. Such studies document specific environments rather than establishing one universally optimal procedure.
Measuring effectiveness is difficult because important outcomes are partly invisible. A defect corrected during review may never appear in an issue tracker. A reviewer may influence the author to simplify a design without leaving a comment that can be classified as a defect. Conversely, a discussion containing many comments may reflect unclear requirements or mechanical corrections rather than unusually thorough examination. Comment count is therefore a weak standalone measure of review quality.
Common operational measures include time to first response, elapsed time to integration, revision count, and the fraction of changes receiving review. These describe different phenomena. A long integration interval may reflect reviewer availability, difficult implementation work, or a deliberate release hold. The active time spent reading cannot reliably be inferred from the difference between submission and approval timestamps. Treating elapsed time as reviewer effort can consequently distort comparisons.
Defect-based measures also require care. Studies may associate review coverage or reviewer participation with later defect reports, but the relationship is affected by change complexity, component maturity, contributor experience, and risk-based selection. Difficult changes may receive more scrutiny precisely because they are more likely to contain defects. Observational associations do not automatically establish that adding reviewers or comments will improve outcomes in another setting.
Change size is an important process variable because reviewers have limited attention and working memory. Small, coherent changes generally make intent and consequences easier to examine than patches mixing refactoring, behavior changes, and formatting. Nevertheless, line count is only a proxy for difficulty. A short modification to a concurrency protocol may demand more reasoning than a large, repetitive update. Arbitrary size thresholds cannot account for every kind of change.
Evaluation therefore combines quantitative indicators with examination of actual cases. A process can be assessed through escaped defects, review delays, participant experience, and whether decisions remain understandable later. Incentives matter: rewarding rapid approvals can encourage superficial review, while rewarding comment volume can generate unnecessary objections. The relevant unit is the quality and cost of the engineering decision, not simply the amount of recorded activity.
AI-assisted review and generated changes
Artificial intelligence can support review by summarizing changes, proposing comments, locating related code, and suggesting tests. Contemporary systems often use a large language model to interpret a patch together with instructions and selected repository context. Unlike a fixed rule that identifies a specific syntax pattern, such a model can produce explanations about apparent intent and cross-cutting behavior. This flexibility also makes its outputs less predictable.
Context is a central limitation. A patch may refer to contracts defined in another repository, generated interfaces, deployment settings, or operational practices absent from the model’s input. Even a long context window does not guarantee that the relevant evidence has been selected or interpreted correctly. An automated reviewer may confidently object to behavior that is intentional, or overlook an invariant that is not locally documented.
Model-generated findings require verification. AI hallucination can produce references to nonexistent functions, unsupported claims about a library, or explanations that sound plausible but do not match the code. A useful assessment distinguishes a stylistic suggestion from a reproducible failure or a well-supported reasoning chain. Compilation, tests, and inspection of the cited definitions can validate parts of a finding, although successful execution still does not prove every claim.
Reviewing AI-generated code creates related challenges for human reviewers. Generated implementations may be syntactically polished while relying on obsolete interfaces, inappropriate assumptions, or unnecessary complexity. The review burden does not disappear because the code was produced quickly. Where an AI coding agent can change multiple files and run tools, the object of review includes its modifications to tests, configuration, and dependencies, not merely the main implementation.
Automated reviewers also operate across information-security boundaries. Repository files, issue descriptions, and comments can contain untrusted instructions. If a model treats such material as authoritative directions rather than data, prompt injection can interfere with its behavior. Tool permissions, access to secrets, and the destination of submitted code therefore affect the risks of deploying the reviewer itself. These concerns are separate from whether its technical comments are accurate.
Evaluation of AI review must distinguish convincing language from useful defect detection. Relevant questions include whether reported issues are real, whether important defects are missed, whether findings duplicate existing tools, and how much human time is spent dismissing incorrect comments. Repository-specific testing is important because languages, frameworks, and review conventions differ. Assigning merge authority to an automated system adds a further governance decision: the responsibility for accepting a change remains distinct from the mechanism that generated the recommendation.