Lesson 12
Catch bugs, share knowledge, and enforce standards through structured review
Code review is one of the most effective quality practices in software engineering. It is not about finding fault โ it is about building better software together.
The goal is not to prove the code is wrong. The goal is to ensure the code is correct, maintainable, secure, and aligned with team standards.
A thorough code review examines multiple dimensions of quality:
| Dimension | What to Check | Key Questions |
|---|---|---|
| SOLID Compliance | Single Responsibility, dependency direction, interface segregation | Does this class do one thing? Are dependencies injected? |
| Clean Code | Naming, function size, DRY, readability | Can I understand this in 30 seconds? Are names intention-revealing? |
| Test Quality | Coverage, edge cases, test readability | Are tests testing behavior, not implementation? Are edge cases covered? |
| Security | Input validation, auth checks, data exposure | Is user input sanitized? Are secrets hardcoded? |
| Performance | N+1 queries, unnecessary loops, memory leaks | Will this scale? Are there obvious bottlenecks? |
| Architecture | Layer boundaries, coupling, dependency direction | Does this follow our architecture? Are boundaries respected? |
Every finding in a code review is assigned a severity level. This removes ambiguity โ everyone knows which issues block a merge and which are suggestions.
| Severity | Label | Action Required | Examples |
|---|---|---|---|
| ๐ด S0 | Critical | Blocks merge. Must fix immediately. | Security vulnerability, data loss risk, broken functionality |
| ๐ S1 | High | Blocks merge. Must fix before approval. | SOLID violation, missing tests for new logic, race condition |
| ๐ก S2 | Medium | Should fix. Won't block merge if acknowledged. | Naming improvement, minor code smell, missing edge case test |
| ๐ต S3 | Low | Optional. Nice to have. | Style preference, minor refactor suggestion, documentation tweak |
Any ๐ด S0 (Critical) or ๐ S1 (High) finding blocks the PR from being merged. These must be resolved and re-reviewed before approval.
Code review is not a one-shot event. It is an iterative process that continues until the code meets the team's quality bar.
If S0/S1 findings are discovered during review, the author must fix them and the reviewer re-reviews. This loop repeats until all blockers are resolved.
๐ S1: This database query runs inside a loop, creating an N+1 problem.
Each iteration hits the DB, so 100 items = 100 queries.
Consider batch-loading all items upfront:
const items = await repo.findByIds(allIds); // 1 query
const lookup = new Map(items.map(i => [i.id, i]));
This drops N+1 queries down to 1.
Studies show that review effectiveness drops dramatically after 400 lines. If your PR is larger, split it into smaller, logical chunks. Each PR should represent one coherent change.
A PR cannot be merged if any of the following are true:
Code review is one component of the Definition of Done. Before marking a story as "Done," verify the full checklist:
## Definition of Done Checklist
- [ ] Code implements all acceptance criteria
- [ ] Unit tests written and passing
- [ ] Integration tests written (if applicable)
- [ ] Code reviewed โ zero S0/S1 findings
- [ ] CI pipeline green
- [ ] Documentation updated (if API changed)
- [ ] No hardcoded secrets or credentials
- [ ] Backward compatible (or migration provided)
- [ ] Approved by at least one reviewer
Code review is a skill. Great reviewers are specific, respectful, and severity-aware. Great authors make reviewing easy by keeping PRs small, descriptive, and well-tested. Together, they build a codebase the whole team can trust.
Which severity levels block a PR merge?