Code Review
Code review is a collaborative method that allows team members to review, discuss, and provide feedback to ensure the quality, readability, and security of the code. Through code reviews, team members can:
- Review code quality: Check if the code meets project standards and best practices.
- Provide feedback: Identify potential issues and suggest improvements.
- Verify functionality: Ensure the correctness of new features or changes.
- Maintain readability: Ensure the code is easy to understand and maintain.
How to Perform a Code Review
- Click on "Pull Requests" on the project page and select the Pull Request you want to review.
Reviewer Comments
The common steps for a reviewer to post comments are as follows:
- On the PR review page, click "Discussion" and scroll to the bottom to send a comment.
- In the file changes, you can click on line numbers or select text, then click the comment button on the right to leave a comment. In the comment, you can provide suggestions, questions, feedback, or point out errors to improve the code.
- The author and reviewers can discuss in the comments to resolve issues or clarify concerns.
Marking Files as Read
The "Mark as Read" feature for Pull Requests can save the progress of a reviewer's viewing of the changes in a Pull Request, effectively distinguishing between read and unread code.
- Click on "File Changes" to view the code comparison view. Click the "Mark as Read" button in the top-right corner to mark the viewing status of the corresponding file.
Checking Differences in Changes
Use the code comparison view to compare changes between different versions, view differences in code changes, and understand which code has been added, deleted, or modified.
- After selecting a "Commit," click on the corresponding commit to view the code comparison view for that commit.
- Clicking "File Changes" will also allow you to view the code comparison view.
- Click the top-right button to choose whether to expand/collapse files, set code display options, choose code comparison Diff mode, and ignore spaces and line breaks in the code.
Approving or Rejecting PRs
Click on "Discussion" at the top to handle PRs, including setting them as drafts, closing them, or merging them.
Set as Draft:
The PR will not be merged temporarily, and "WIP" will appear before the title. Click "Ready" to cancel the draft status, or click "Close" to close the PR.
Close PR:
This PR no longer needs to be processed and will not be merged into the main branch.
Merge:
The submitted modifications will be merged into the main branch.
Code review is an important part of team collaboration and continuous improvement. Effective communication and feedback can enhance the quality of the code and the efficiency of team collaboration.