-
Notifications
You must be signed in to change notification settings - Fork 4
Code Review Process
AlexZorkin edited this page May 13, 2025
·
1 revision
This document outlines the code review process for the LCFS project. Effective code reviews are crucial for maintaining code quality, sharing knowledge, and fostering a collaborative development environment. This addresses requirements for ticket #2410.
- Improve Code Quality: Catch bugs, logical errors, and deviations from coding standards.
- Ensure Readability & Maintainability: Verify that code is clear, understandable, and easy to maintain.
- Knowledge Sharing: Help team members learn about different parts of the codebase and new techniques.
- Mentorship: Provide opportunities for junior developers to learn from senior developers, and vice-versa.
- Collective Ownership: Foster a sense of shared responsibility for the codebase.
- Validate Against Requirements: Ensure the implemented solution meets the intended requirements of the feature or bug fix.
Before submitting a Pull Request (PR) for review, the author should:
- Self-Review: Review your own code first. Check for typos, obvious errors, and adherence to style guides.
-
Test Thoroughly: Ensure all Testing Procedures have been followed:
- Relevant unit and integration tests are written and pass.
- E2E tests (if applicable to the changes) pass.
- Manual testing of the feature/fix has been performed.
- Ensure CI Checks Pass: All automated checks in the CI pipeline (linters, formatters, automated tests, builds) must be passing.
-
Clear PR Description: Write a clear and concise PR description:
- Explain what changes were made and why.
- Link to the relevant issue(s) in the issue tracker.
- Provide clear steps for reviewers to test or verify the changes.
- Include screenshots or GIFs for UI changes.
-
Keep PRs Focused and Manageable:
- Submit small, focused PRs where possible. Large PRs are difficult and time-consuming to review effectively.
- If a feature is large, break it down into smaller, logical PRs.
-
Check for Debugging Code: Remove any temporary debugging code (e.g.,
console.log,printstatements not intended for production).
Reviewers should aim to provide constructive, respectful, and timely feedback.
- Read the PR description and linked issues to understand the context and purpose of the changes.
- Try to understand the overall approach before diving into line-by-line details.
-
Functionality: Does the code work as intended and meet the requirements?
- If possible, pull down the branch and test the changes locally.
- Correctness: Are there any logical errors, race conditions, or edge cases missed?
- Readability & Simplicity: Is the code clear, concise, and easy to understand? Could it be simpler?
- Maintainability: Is the code well-structured? Will it be easy to modify or debug in the future?
- Adherence to Standards: Does the code follow Coding Standards and Conventions?
- Testing: Are there sufficient tests for the changes? Do the tests cover important scenarios and edge cases? (Testing Procedures)
- Security: Are there any potential security vulnerabilities introduced? (See Security Guidelines for Developers)
- Performance: Are there any obvious performance bottlenecks or inefficiencies?
- Documentation: Is new code adequately commented? Is any related documentation (e.g., READMEs, other wiki pages) updated if necessary?
- Naming: Are variables, functions, and classes named clearly and appropriately?
- Error Handling: Is error handling robust and user-friendly (if applicable)?
- Be Specific: Refer to specific lines of code or files.
- Be Constructive: Offer suggestions for improvement rather than just criticism.
- Explain Your Reasoning: If you suggest a change, explain why it's better.
- Distinguish Importance: Differentiate between critical issues, important suggestions, and minor nits (e.g., use prefixes like "Nitpick:" or "Suggestion:").
- Use GitHub's Review Tools: Add comments directly to the code in the PR. Use "Request changes," "Approve," or "Comment" appropriately.
- Be Timely: Aim to review PRs within a reasonable timeframe (e.g., 1-2 business days, as per team agreement).
- Acknowledge Feedback: Respond to comments, indicating whether you agree or want to discuss further.
- Make Necessary Changes: Address the feedback by making code changes, pushing new commits to the same PR branch.
- Clarify if Needed: If you disagree with a suggestion or don't understand it, discuss it respectfully with the reviewer.
- Re-request Review: Once changes are made, notify the reviewer(s) that the PR is ready for another look (GitHub often does this automatically when you push to the PR branch).
- Approval: Typically, at least one approval (or as per team policy) is required before a PR can be merged.
- CI Checks: All CI checks must be passing.
-
Merging: Once approved and checks pass, the PR can be merged into the target branch (e.g.,
mainordevelop).- Refer to Git Workflow and Branching for preferred merge strategies (e.g., squash and merge).
- Delete Branch: The feature branch should be deleted after the PR is merged.
- Action: Define the team's policy on the number of reviewers required (e.g., one for most PRs, two for critical changes).
A positive and collaborative code review culture is key to a healthy and productive development team. Treat reviews as a learning opportunity for everyone involved.