Introduction ๐Ÿฆ

As a team, our main objective is to create and deliver high-quality software solutions. Code review plays a crucial role in achieving this objective by ensuring that our code is of the highest possible quality. A code review is an examination of a piece of code by another developer to identify defects and suggest improvements. In this article, we’ll discuss the importance of code review, who should perform it, and the principles that should guide us during the review process.

You can benefit from well used Git Workflow processes to get proper collaboration with your team.

The Importance of Code Review

Code review is a critical process in software development that has several benefits, including:

  • Ensuring that the code is of high quality and meets the requirements
    Identifying defects and security vulnerabilities
    -Sharing knowledge among team members
    Facilitating team collaboration and ownership of the codebase

Who Should Perform Code Review?

Code review should be performed by every developer in the team. It is a collaborative process that helps team members learn from one another and share their expertise.

Principles of Code Review

โฐ Prioritizing Timely Completion

As time doth pass, the risk of erros increase. Hence, finishing the code review process is of paramount importance.

๐Ÿ’ป For the MR Author

As the MR author, you must ensure that the MR can be merged as soon as possible, which should take precedence over other tasks. Address the comments without interrupting a focused task.

Here are some things to keep in mind to complete the review process smoothly:

  • โซ Prioritize MR completion over other work
  • ๐Ÿ“ˆ Respond to comments as soon as possible without losing focus

๐Ÿ•ต๏ธโ€โ™€๏ธ For the Reviewer

As a reviewer, you must prioritize reviewing the MR over your own development tasks. You can also propose another reviewer. However, personal productivity is still important, and you should not interrupt a focused task to perform a review.

Consider these points for a seamless code review process:

  • ๐Ÿš€ Promptly begin reviewing within one business day
  • ๐Ÿ”„ Avoid context switching during the review process
  • ๐Ÿ’ผ Propose another reviewer if unable to review within the deadline

Collaboration is Key

Code review is a collaborative process that should be approached with the goal of learning and helping others learn. It’s an opportunity for the team to come together to create high-quality code that meets the requirements.

You can find our article on the golden rules during a review process in software development.

How to create Merge Request (MR)

You need to follow these steps:

  • Rebase your code from the main branch.
  • Add yourself as the assignee.
  • Select the appropriate MR template.
  • Select a reviewer.

When selecting a reviewer, you should try to choose someone who has some knowledge of the domain that your MR addresses.

It is also a good idea to vary the reviewers so that different people can gain knowledge from reviewing the work.

If you want to add more reviewers, you can choose them or mention them in a comment.

This can be helpful to introduce new developers to the code you are working on while still having an experienced developer perform the review.

Once you have addressed the comments from the reviewers, you should mark them as resolved on the GitLab interface. comments.

When all the reviewers have approved the MR, you are responsible for merging it into the main branch.

Rebasing

Check if there are new commits in the main branch since your last rebase.

GitLab will offer you the option to automatically rebase your branch.

If there are conflicts, you should perform the rebase manually using:
– the git rebase -i origin/main command
– and push your changes using git push -f.

Approving

To Approve or Not to Approve: That is the Question

The process of code review is essential to ensure the quality and reliability of software development projects. Once the review process is complete, it is necessary to approve the Merge Request (MR) before the author can merge it. In this section, we will discuss the importance of approving an MR and the steps involved in the process.

The Significance of Approving an MR

The approval process is a crucial step in the code review process. It indicates that the MR meets the required standards and is ready to be merged. By approving an MR, you are essentially giving the green light for the changes to be integrated into the codebase. It is, therefore, essential to ensure that the MR has undergone thorough scrutiny and meets all the necessary requirements before approval.

The Approval Process

To approve an MR, follow these simple steps:

First, ensure that you have thoroughly reviewed the MR and checked all the items on the reviewer checklist.

If there are any minor issues that require correction, you can still approve the MR and add a comment to inform the author of the changes that need to be made. This approach saves time in the process.

Once you are satisfied with the state of the MR, you can go ahead and approve it.
๐Ÿ’กPro Tip: If you have comments that are trivial but need addressing, you can still approve the MR and let the author perform the correction before merging.

In these cases, make sure to add a comment explaining this to the author.

Merging

You can merge the MR by clicking on the Merge button on the MR interface. If the pipelines are still running, you can use the Merge when pipeline succeeds button. Check the box "Delete source branch" to delete your branch on the remote repository after the merge.

In conclusion, code review is a critical process in modern software development. It helps ensure that the codebase is of high quality, meets industry standards, and is free of defects that could affect the product’s performance. A successful code review process requires the involvement of experienced and skilled reviewers, adherence to established guidelines and standards, and the use of modern code review tools.

This article has explored the art of code review in modern software development, covering the importance of code review, the benefits, best practices, common mistakes to avoid, and how to conduct a successful code review. By following the best practices and guidelines outlined in this article, software development teams can establish a code review process that will improve the quality of their codebase and ultimately lead to better-performing products.

Source Description
Code Review Best Practices SmartBear’s article on code review best practices provides an overview of the benefits of code review, the types of code review, and tips on how to conduct effective code reviews.
Code Review Guidelines for Effective Code Reviews This article outlines a set of code review guidelines that can help developers improve their code review process.
How to Run a Code Review Meeting This article explains how to run a successful code review meeting and provides tips on how to make the process more efficient.
Effective Code Review Techniques This DZone article provides tips and techniques on how to conduct effective code reviews, including how to give and receive feedback and how to ensure that the review process is productive.
Tips for More Effective Code Reviews IBM’s article on effective code reviews provides ten tips for conducting more productive and effective code reviews, including how to involve the right people in the process and how to provide actionable feedback.

Written by

Albert Oplog

Hi, I'm Albert Oplog. I would humbly like to share my tech journey with people all around the world.