DEV Community

Cover image for How Reviewpad is Putting the Reviewer Assignment Problem to Rest
Reviewpad for Reviewpad

Posted on • Originally published at reviewpad.com

How Reviewpad is Putting the Reviewer Assignment Problem to Rest

Streamline your code reviews with Reviewpad. Our advanced algorithm suggests the best reviewers for your pull requests, making your workflow faster and more efficient.

Are you tired of manually assigning reviewers to pull requests on GitHub? Do you find it time-consuming and difficult to ensure that each pull request is assigned to the most appropriate reviewer? If so, Reviewpad has the solution for you. With its new Code Reviewer Assignment feature, Reviewpad can help you streamline your code review process and ensure that each pull request is assigned to the right reviewer.

The Problem with Manual PR Reviewer Assignments

For teams working on GitHub, the manual assignment of reviewers to pull requests can be a time-consuming and error-prone process. As development teams grow in size, the need for an automated review assignment mechanism becomes increasingly critical. Without such a mechanism, developers must spend valuable time manually selecting the most relevant and available reviewers for each pull request. This process can take critical time away from development tasks, slow down the review process, and lead to bias in the selection of reviewers.

In addition, it can be challenging to ensure that reviewers have the necessary expertise to review the code in the pull request. This can result in longer review cycles, errors in the code, and delays in the development process.

Reviewpad's Innovative Solution for Effortless Reviews

Reviewpad's Code Author Reviewer Assignment Mechanism aims to solve these problems by automating the assignment of reviewers to pull requests. Reviewpad analyzes the past contribution history of code authors and uses that data to suggest the most appropriate reviewers for each pull request.

In this process, Reviewpad considers two factors when assigning a reviewer. Those are

  • Relevancy and
  • Availability

of the reviewers.

The relevancy evaluation is based on the authorship of the code. It analyzes how many lines of code have been written by possible reviewers in the latest version of the impacted source files.

The availability evaluation is based on the number of open reviews per reviewer, which ensures that reviewers with too many open reviews are considered unavailable.

If there are no reviewers available or identified by the algorithm, a random user within the organization will be assigned as the reviewer for the PR. This fallback mechanism ensures that the pull request does not remain unreviewed and that the code changes are still scrutinized by someone in the organization.

The Crucial Role of assignCodeAuthorReviewers Function

Reviewpad's Code Author Reviewer Assignment Mechanism is powered by the assignCodeAuthorReviewers function, a built-in function that takes several parameters to determine the most relevant and available reviewers for each pull request.

This function is critical as it allows teams to customize the review assignment process to fit their specific needs.

Understanding the Parameters of assignCodeAuthorReviewers

The assignCodeAuthorReviewers() function takes three parameters.

  1. Total (Optional): This parameter specifies the total number of reviewers to assign to a pull request. The default value is one, but you can change it to assign more than one reviewer to a pull request.
  2. Excluded Reviewers (Optional): This parameter is a list of reviewers to exclude from being assigned to a pull request. You can use this parameter to exclude specific reviewers who might not be appropriate for the review.
  3. Max Reviews (Optional): This parameter specifies the maximum number of open reviews per reviewer. If a reviewer has more open reviews than this value, they will be considered unavailable and will not be assigned to the pull request. If we don't specify a value to Max Reviews, the algorithm ignores that parameter and considers reviewers regardless of the number of open reviews they have.

Examples of assignCodeAuthorReviewers at Work

Let's look at an example of how you can use the assignCodeAuthorReviewers function in Reviewpad.

Example 1

$assignCodeAuthorReviewers()
Enter fullscreen mode Exit fullscreen mode

This example uses the default parameters for the assignCodeAuthorReviewers function. It will assign one reviewer to the pull request based on code authorship and availability.

Example 2

$assignCodeAuthorReviewers(3)
Enter fullscreen mode Exit fullscreen mode

This example assigns three reviewers to the pull request based on code authorship and availability.

Example 3

$assignCodeAuthorReviewers(2, ["user1", "user2"])
Enter fullscreen mode Exit fullscreen mode

This example assigns two reviewers to the pull request, but it excludes "user1" and "user2" from being assigned as reviewers.

Example 4

$assignCodeAuthorReviewers(1, [], 2)
Enter fullscreen mode Exit fullscreen mode

This example assigns one reviewer to the pull request, but it limits the number of open reviews per reviewer to two.

A Step-by-Step Guide to Using Reviewpad's Code Author Reviewer Assignment Feature

Now that you have a better understanding of the assignCodeAuthorReviewers function, let's take a look at the steps of the workflow of the Reviewpad's Code Reviewer Assignment Mechanism.

Step 1: Sign up for Reviewpad and integrate it with your GitHub account. (Installation Guide ↗︎)

Step 2: In your repository, create a new workflow with the following code:

workflows:
  - name: Code Author Reviewer Assignment
    if:
      - '!$isDraft()'
    then:
      - $assignCodeAuthorReviewers()
Enter fullscreen mode Exit fullscreen mode

Step 3: Customize the assignCodeAuthorReviewers function to fit your specific needs. You can use the parameters and variables mentioned earlier in this article to customize the review assignment process.

Step 4: Create a draft pull request in your repository.

Step 5: When the pull request is ready for review, move it to the Ready for Review status.

Step 6: Reviewpad's Code Author Reviewer Assignment Mechanism will analyze the relevancy and the availability of the reviewers and suggest the most appropriate reviewers for the pull request.

Discovering the Advanced Functionality of Reviewpad

It's important to note that Reviewpad's Code Author Reviewer Assignment Mechanism is a powerful tool that can help you streamline your code review process. However, it's not a replacement for good code review practices. It's still important to ensure that reviewers have the necessary expertise to review the code in the pull request and to maintain a clear and organized review process.

In addition, Reviewpad provides other powerful features such as automated pull request labeling, automatic pull request merge, and enforcing branch conventions. By using Reviewpad's Code Reviewer Assignment feature in combination with these other features, you can create a robust and efficient code review process that saves time and reduces errors.

Top comments (0)