Code Review Best Practices

matt
Matthew Gros · Sep 13, 2025

TLDR

Review the code, not the person. Explain why, not just what. Keep PRs small. Automate style checks.

Code Review Best Practices

Reviews Should Improve Code and People

Not just find bugs.

For Reviewers

Be kind:

// Bad
"This is wrong"

// Good
"This might cause issues because... Consider..."

Explain why:

// Bad
"Use const instead of let"

// Good
"Since this value never changes, const makes that intent clear"

Ask questions:

"What happens if user is null here?"
"Could this race with the other update?"

For Authors

Keep PRs small:

  • Under 400 lines ideally
  • One logical change per PR
  • Split refactoring from features

Write good descriptions:

## What
Add pagination to user list

## Why
Page was timing out with 10k+ users

## Testing
- Tested with 50k users locally
- Added unit tests for edge cases

What to Look For

  1. Logic errors - Edge cases, off-by-one
  2. Security - Injection, auth bypass
  3. Performance - N+1, missing indexes
  4. Readability - Naming, complexity
  5. Tests - Coverage, edge cases

Automate the Boring Stuff

Don't argue about style. Use tools:

  • Linting: ESLint, PHP CS Fixer
  • Formatting: Prettier
  • Types: TypeScript, PHPStan
# Run automatically on PR
- npm run lint
- npm run test
- npm run typecheck

Approve and Move On

Perfect is the enemy of good. If it:

  • Works correctly
  • Has tests
  • Doesn't introduce debt

Ship it. Iterate later.

About the Author

matt

I build and ship automation-driven products using Laravel and modern frontend stacks (Vue/React), with a focus on scalability, measurable outcomes, and tight user experience. I’m based in Toronto, have 13+ years in PHP, and I also hold a pilot’s license. I enjoy working on new tech projects and generally exploring new technology.