All Case Studies Design Development Interviews Our Way Project Management

Start Fast Code Review With a Single Slack Command

In Netguru we deal with a huge amount of code review, because we consider it a vital step before deployment. Finding a good partner to share your code base with can be a hassle, especially with our 50+ projects on various technology stacks. This is why we created a fast and reliable smart Slack bot to help find great code-review partners. In seconds, with only a single command. Take a look at this magic.

Problem

In a big organisation with a lot of different projects and stacks, it can be hard to find a good code review partner. Ideally, we’d like to share code written in the same language and framework. Also, when checking each other’s code both sides should be doing a similar amount of work. But with lots of different projects in your organization, pull requests tend to differ greatly. For this reason, developers spend a lot of time looking for a decent review partner, only to end up checking code they are not familiar with. This is a problem which can have a huge impact on both the quality of code review and also on the developer’s experience.

How we did it

To address it we created a Slack bot. We use Slack everyday and have a dedicated channel for code review purposes. This channel is now the home of our Slack bot. Slack integrations are a hot topic lately, which is why we’ve been experimenting with the Slack API in many of our internal applications.

We found out that the Slack documentation is awesome and it makes work easy. Its API is quick to use and simple to understand. Overall, it was fun code to deliver. Really enjoyable for the developers.

However, there was also a tricky bit – the algorithm to suggest similar pull requests for review.

When creating the algorithm we had to consider:

  • the number of changes in each pull request – don’t match a pull request with 100 commits with a single-commit pull request
  • the technologies used – the most important thing when comparing pull requests. The easiest way to achieve good suggestions here is to compare the types of files in each pull request (e.g. don’t suggest pull requests with .java files for projects with .rb files)
  • the suggestions – they have to be updated because pull requests can change anytime!  Also, a code review is mostly about the added code, so you can disregard the deletions when calculating suggestions.

Solution

We focused on easy and fast deployment. This is why we built an application that can be set up in three simple steps. You just need to:

  1. Deploy the code to Heroku (you can use the “Deploy to Heroku” button in our repo!)
  2. Set up a Github webhook for your organization and point it at your application endpoint.
  3. Add the integration on Slack

You can find all this in our repo on Github,here. There is also a readme. The app is fully open-source, so we welcome any feedback.

How does it work?

We use it daily in almost all of our projects, and the feedback has been great so far. Check out this example of it in action:

Listing ready-for-review pull requests for a given project:

image00-1.pngDisplaying review suggestions for a single pull request:

image01.pngKey facts

  • Development time: 1 week for a working Slack integration
  • Test coverage: 97%
  • CodeClimate: 4.0
New Call-to-action
Follow Netguru
Join our Newsletter

Scaling SaaS
READ ALSO FROM Slack
Read also
Need a successful project?
Estimate project or contact us