Skip to content

Code Review

In one line

Code review is peer review of code before merge — catches bugs, improves quality, shares knowledge, enforces standards.

In simple words

Code review is the practice of having other developers review your code before it's merged. It's one of the most effective quality assurance practices in software development.

What code review catches:

  1. Bugs — logic errors, edge cases, race conditions
  2. Security issues — injection vulnerabilities, auth flaws
  3. Performance — inefficient algorithms, N+1 queries
  4. Readability — unclear naming, complex logic, missing comments
  5. Standards — style violations, pattern inconsistencies
  6. Test coverage — missing tests, inadequate assertions
  7. Design — tight coupling, missing abstraction, API design

Code review process:

  1. Author creates a PR/MR with the changes
  2. Reviewers examine the diff, leave comments
  3. Author addresses feedback, pushes updates
  4. Reviewers approve → merge; or request changes → iterate

Best practices:

  • Small PRs — review 200-400 lines at a time (beyond that, quality drops)
  • Specific feedback — point to the issue, suggest a fix
  • Kind tone — critique the code, not the person
  • Ask questions — "why this approach?" teaches and reveals issues
  • Approve when done — don't leave PRs hanging

Tools: GitHub PRs, GitLab MRs, Gerrit, Crucible.

Example

text
Code Review Checklist
====================

Functionality:
[ ] Does the code do what the PR description says?
[ ] Are edge cases handled? (null, empty, max, min)
[ ] Are error cases handled gracefully?

Tests:
[ ] Are there tests for the new code?
[ ] Do tests cover happy path AND error cases?
[ ] Are assertions meaningful (not just "doesn't throw")?

Security:
[ ] Is user input validated and sanitized?
[ ] Are there any hardcoded secrets/credentials?
[ ] Are auth checks in place?

Performance:
[ ] Any N+1 query patterns?
[ ] Any unnecessary loops or allocations?
[ ] Is the algorithm complexity acceptable?

Readability:
[ ] Are names clear and consistent?
[ ] Is complex logic explained?
[ ] Could this be simpler?

Design:
[ ] Does this change fit the existing architecture?
[ ] Is the code properly separated (single responsibility)?
[ ] Are the public APIs well-designed?

A code review checklist ensures consistent quality. Reviewers check functionality, tests, security, performance, readability, and design. Small, focused PRs make reviews more effective.

Common confusions

  • Confused with: static analysis

    The difference: Code review is human peer review — it catches design issues, logic errors, and shares knowledge, but is subjective and limited by human attention. Static analysis is automated tool analysis — it catches style violations, type errors, and known patterns deterministically, but can't understand intent or design. Code review and static analysis are complementary — use both.

Related terms

Related Resources

Related Lessons

Decode error messages

Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.

View errors

← Back to glossary