How to do Code Review on Github?
let's dive deeper into each step of the code review process on GitHub:
1. For Code Review: Access the Repository and PR:
- Sign in to GitHub with your username and password.
- Go to the main page of the repository by searching for it or accessing it through your organization.
- After that, navigate to the “Pull Requests” tab
- Choose the PR you want to Review.
2. Understanding the Context:
Now, let’s delve into understanding the context.
- Read the PR’s title and description. This provides you with a high-level understanding on why code needs to be changed.
- Examine any related issues that may provide additional context or explain why these changes are required.
3. Code Review Checklist:
- Familiarize yourself with the project’s coding guidelines and standards. These might be documented in the repository or communicated by the team.
- Consider aspects such as code formatting, variable naming conventions, function structure, and overall code quality.
4. Reviewing Code:
- Select the “Files Changed” tab to compare the code changes side by side.
- Examine the codebase for additions, changes, and deletions.
- If the changes include new functionality, try to understand how it works and, if possible, test it.
- Check that the new changes haven’t broken any existing functionality.
5. Adding line comments:
- Learn about the project’s coding guidelines and standards. These may be recorded in the repository or communicated by the team.
- Take into account code formatting, variable naming conventions, function structure, and overall code quality.
- To add a comment, select the line of code you want to comment on.
- Highlight problems, propose alternatives, or recognize well-executed sections.
- Provide overall feedback about the architecture, design decisions, or code organization in the PR’s comment section.
- Discuss the big picture and how these changes fit into the overall goals of the project.
6. Discussion and Approval:
- Participate in discussions with the PR author and other reviewers. Address any reservations, request clarification, and provide context for your feedback.
- If the PR author makes changes based on your feedback, review the PR to see if the issues have been adequately addressed.
- Approve the PR if you are satisfied with the changes. If not, choose “Request changes” and describe what needs to be changed.
- In larger projects, specific parts of the codebase may have designated code owners. Respect their expertise and, if necessary, seek their advice.
- Look for automated CI checks in the PR description or comments, such as tests and code analysis. Check that these checks pass.
- Keep in mind that the goal is to collaborate, not to criticize. Give constructive feedback and explain your suggestions.
8. Closing PR:
- The PR can be approved once all feedback has been addressed and the code meets the required standards.
Now, Time for the final step
- After merging, close the PR with a comment summarizing the review results.
- After the review, consider the process. Discuss with your team how to improve the efficiency and effectiveness of the code review process.