DocsContributingCode reviews

Code reviews

Our code review process ensures code quality, knowledge sharing, and maintainability.

Pull request guidelines

1. Title format

PR Title Format
# Format
<type>(<scope>): <description>
 
# Examples
feat(payments): implement Wave payment provider
fix(webhooks): handle timeout errors
docs(api): update authentication guide

2. Description template

PR Description Template
## Changes
- Added Wave payment provider integration
- Implemented webhook signature verification
- Updated API documentation
 
## Testing
- Unit tests added for payment processing
- Integration tests for webhook handling
- Manual testing with test credentials
 
## Screenshots
[If applicable]
 
## Related issues
Closes #123

Review process

1. Self review

Terminal - Self Review Checks
# Run tests
npm test
 
# Check linting
npm run lint
 
# Build documentation
npm run docs:build

2. Code review

  • Request reviews from relevant team members
  • Address feedback promptly
  • Re-request review after changes

3. CI checks

  • All tests must pass
  • Code coverage requirements met
  • No security vulnerabilities
  • Documentation updated

Review checklist

1. Code quality

  • Follows coding standards
  • No duplicate code
  • Proper error handling
  • Efficient implementation

2. Testing

  • Unit tests added/updated
  • Integration tests if needed
  • Edge cases covered
  • Test coverage maintained

3. Security

  • Input validation
  • Authentication/Authorization
  • Sensitive data handling
  • Security best practices

4. Documentation

  • Code comments
  • API documentation
  • README updates
  • Changelog entry

Best practices

1. As a submitter

Submitter Example (Good vs Bad)
// DO: Small, focused changes
function validatePayment(amount: number): boolean {
  return amount > 0 && amount <= 1000000;
}
 
// DON'T: Multiple unrelated changes
/*
function validateAndProcessPayment() {
  // Mixed concerns
}
*/

2. As a reviewer

Reviewer Example (Good vs Bad Feedback)
// Good feedback
// Consider using a type guard for better type safety
function isValidAmount(amount: unknown): amount is number {
  return typeof amount === 'number' && amount > 0;
}
 
// Unhelpful feedback
// // This is wrong

3. Code examples

Code Example (Before/After)
// Before
/*
function process(data) {
  if (data) {
    return data.value;
  }
}
*/
 
// After
function process(data: InputData): OutputData {
  if (!data) {
    throw new Error('Data is required');
  }
  return data.value;
}

Review comments

1. Constructive feedback

Constructive Feedback Example
// Instead of:
// // This is messy
 
// Better:
// Consider extracting this logic into a separate function
// for better reusability and testing:
function validateWebhookSignature(
  payload: string,
  signature: string
): boolean {
  // Implementation
}

2. Suggestions

Suggestion Example
// Instead of:
// // Use better names
 
// Better:
// Consider more descriptive names:
// - `processPayment` -> `validateAndProcessPayment`
// - `data` -> `paymentData`

After review

1. Addressing feedback

Terminal - Addressing Feedback
# Update branch
git fetch origin
git rebase origin/develop
 
# Make changes
git add .
git commit -m "fix: address review feedback"
 
# Force push if needed
git push --force-with-lease

2. Merging

Terminal - Merging Strategies
# Squash and merge
git checkout develop
git merge --squash feature/payment-method
 
# Or rebase and merge
git checkout develop
git rebase feature/payment-method

Next steps