Getting Started with Review Board

By Sandeep Rawat
    Advance your knowledge in tech with a Packt subscription

  • Instant online access to over 7,500+ books and videos
  • Constantly updated with 100+ new titles each month
  • Breadth and depth in over 1,000+ technologies

About this book

How would you feel if the world's craftiest programmer went through every line of code that you wrote before it appeared on the user's screen? Everyone is not lucky enough to have a person to go through their code! Reviewboard is a powerful web-based code review tool that offers developers an easy way to handle code reviews. It scales well from small projects to large companies and offers a variety of tools to take much of the stress and time out of the code review process.

Based on the philosophy that "Merely using a tool is one thing, using it right is another", Getting Started with Review Board will guide you on a journey to mastering Reviewboard by teaching you how to publish a code review request through the Reviewboard web UI or command line. It will help you become an ace Reviewboard administrator as you'll learn how to manage users, review groups, default reviewers, repositories, and much more.

This practical, example-oriented book covers the code review workflow in detail. It also talks about the various features in Reviewboard which make your life a lot easier as a code author, reviewer, and administrator.

You will start the journey by looking at the different ways of sharing the code changes (diff) with your team which will also cover integration with a repository. Then, you will look at how a code review can be performed and how you can provide your input on the code changes or on the whole diff. You will also look at the user dashboard, which provides an overview of the review requests and user/group activities which the user is a part of. Finally the administration of Reviewboard application and admin dashboard will be explored. You will end the book by learning advanced tips and tricks to get the best out of Reviewboard.

Publication date:
February 2014
Publisher
Packt
Pages
116
ISBN
9781783281992

 

Chapter 1. Introduction to Review Board

With this chapter, we will start our journey by getting acquainted with Review Board. First of all, we will look at pre-commit and post-commit code reviews, which are different ways of performing code reviews depending upon whether the review is done before or after pushing the updated code to the code repository. We will then briefly look at the various features of Review Board, such as creating and publishing review requests with code diff and integration with the version control system (VCS), which will be covered in detail in the forthcoming chapters. As a code reviewer, you can view the code diff, add review comments, and create issues for a review request.

Note

Every time you visit search.yahoo.com, you use code that has been reviewed on Review Board.

 

Code review – power-charging your code


How would you feel if the world's craftiest programmer went through every line of code that you wrote before it appeared on the user's screen (or maybe in a cold, dark machine running on a server farm on a remote island)? Good, right?

But everyone is not so lucky to have such a person go through their code! Yet, you can (and possibly do) have a good set of peers who can go through your code and help you improve it. They might not be as good as the world's craftiest programmer, but having your code pass through a different set of eyes and the feedback that it will generate will help you fine-tune your code, improving its correctness and quality significantly. This process is called code review.

Thus, code review helps you in identifying and resolving potential problems in your code that could otherwise be caught by a tester (bad for your ego), or even worse, appear in production (bad for your reputation).

Code review is beneficial for the following reasons:

  • It is far more effective in detecting defects as compared to unit, functional, or integration testing

  • It can play a significant role in helping you release your software on time (or even earlier)

  • It can help you create very high-quality and reliable software

  • It can help transform your team from being a mere development team to a quality development team

Guess what? The preceding points will also help you save a considerable amount of money while developing your software.

Some people think that code review is an overhead and slows down development. In reality though, many teams that perform code reviews have proven that it helps the organization to save a lot of time on bug fixing and speeds up the development, which leads to a better quality product and faster shipping.

 

Code review best practices


Now that you are familiar with what code review is, you will be itching to try to implement it. Hold on, aspiring code review ninja! You will be able to extract the maximum benefit out of code review only when you do it the right way. Keeping in mind the following points will be of help:

  • Remember, small is beautiful. Code review works best when done in small chunks. Ideally, code review should not exceed 30 minutes, and the number of lines in a code review should not be more than 200.

  • There should be a common code review checklist so that all of the code is evaluated with the same yardstick.

  • It must be ensured that the outcome of each code review is sewn back into the code.

  • Code review should target code, not people.

  • Be egoless; you are not your code.

  • Review findings should not be limited to a group of people. Rather, they should be visible to everyone in the organization. This would also help avoid duplication of similar coding mistakes across development teams.

Thus, code review is not a process of only identifying the coding problems; it also helps in manifesting a culture of writing high-quality code. To successfully implement the process of code review in your organization, you would need each and every programmer to be egoless.

 

Ways of performing code review


A few years ago in our team, the following was how we performed a code review:

  1. Schedule a meeting for code review.

  2. Provide the print of the code on paper in advance so that reviewers can go through the code and prepare their suggestions.

  3. Discuss the review comments of each reviewer in the meeting, and record the suggested improvements as Minutes of Meeting (MoM).

  4. The author would incorporate the improvements and notify at least one of the reviewers to verify it.

  5. The review was closed only once it was verified.

This kind of code review is known as a heavyweight code review or a formal code review. Although this process worked to get the job done, it had lots of overheads and consumed a lot of resources. It also had lengthy cycles of review feedback.

If you think that heavyweight code review is not suited for you because of its slowness, take it easy, aspiring code review ninja! Lightweight code review is here to rescue you! It typically requires lesser overhead than formal code inspections, though it can be equally (or even more) effective when done properly.

Because there is no formal defined rule of performing lightweight code review, you can devise your own methods of practicing it. The only thing you have to keep in mind is that it should not block people within your team.

A few of the common known ways of performing lightweight code review are as follows:

  • Over-the-shoulder: As soon as you feel you have a piece of code ready, invite one or more peers over to your desk and walk them through the code to get it reviewed there itself.

  • E-mail pass-around: Send your piece of code in an e-mail to your peers (two or three of them) to get their opinion.

  • Pair programming: You and your developer friend can develop code together at the same workstation. This helps eliminate a lot of waste even before it appears. This is common practice in agile development methodologies.

  • Tool-assisted code review: You'll use specialized tools designed for peer code review. One such tool is Review Board.

Another categorization of code review can be done on the basis of whether code review is happening before or after committing (pushing) the code to the code repository. The next section will talk about two types of code review (pre-commit and post-commit code review), the work flow that one can follow, and the pros and cons of following these code review processes.

Pre-commit code review

As the name suggests, pre-commit code review enforces that the code be committed to the code repository if and only if it has passed through the full code review cycle. The full code review cycle will ensure that the code meets the required quality standards and that all of the suggested changes have been incorporated. The pre-commit code review cycle is illustrated in the following diagram:

Pre-commit code review is a strict code review process as it acts as an ultimate funnel that doesn't allow a single line of code to be shared among team members unless it has been fully certified as quality code. The major challenge with this kind of review process is that it slows down the team as the multiple cycles of review become additional steps before the code reaches fellow developers.

To have a fairly successful pre-commit code review, the team members (or potential code reviewers) must always have "yes" as an answer to the question: do you have time for code review?

Post-commit code review

An alternate practice called post-commit review tries to tackle the challenge posed by pre-commit review by making the code review happen after the code becomes available to fellow developers. Thus, it doesn't prevent people from continuing with their work. The following diagram illustrates the post-commit code review cycle:

As Spiderman's uncle Ben said, "With great power, comes great responsibility",and the same applies to the post-commit review process. Because the developers have the power to make their code public even before it has passed the review process, the onus lies on them to ensure that they get the code reviewed later and incorporate the suggested changes.

On the cons' side, it might so happen that the other team members have already made the changes to the original code pushed by the author to the code repository by the time the author wants to incorporate the review comments. It may not be that big of a challenge though; it would depend on the team size.

 

Why Review Board?


Review Board is a user-friendly code review tool. The following are some of its best characteristics:

  • Open source

  • Web-based

  • Integrates well with most version control systems such as Subversion, Git, Mercurial, Perforce, and CVS

  • Can be set up in any web server; it works very well with Apache and lighttpd

  • Supports automatic posting of code reviews either through a REST Web API or Python script

 

What people are saying about Review Board


User feedback is always a good way to separate a great tool from the average ones. Review Board has been the most used tool for code review for many teams.

Tip

You can find a list of happy users on the Review Board site at http://www.reviewboard.org/users/.

 

Features of Review Board


As a first step towards our learning of Review Board, let's go through its features that make teams feel happy and confident about Review Board being the right tool for code review. A more detailed walkthrough of each feature will follow in the upcoming chapters.

Publishing

A basic requirement for any code review tool is that a user should be able to share the review request with the team. Review Board supports the creation of a review request through the web interface or command-line tools to push the review requests to Review Board. It requires bare minimum efforts to create and push the review request to Review Board.

Easy code review

The next most important thing after publishing the code review request is the ease with which a review can be performed. The smartest thing that can be done to make code reviewing easy is to highlight the differences introduced in the code, and that's exactly what Review Board does.

Comments

As a reviewer, you would want to add comments to the code under review to ask questions, provide suggestions, and appreciate a good implementation. Also, as an author of the code, you might want to further add comments to answer the questions asked by reviewers and explain why a particular suggestion should (or shouldn't) be incorporated. Review Board provides multiple ways to add these review comments on the code and also fulfills all of the following requirements:

  • Comment on an individual line

  • Comment on a group of lines or a selection of text

  • Comment on an existing comment

Intuitive diff viewer

It becomes easier to review the code if the differences in the code, before and after the changes, are visible and highlighted. Review Board comes with a very intuitive diff viewer to highlight the differences with the following features:

  • A side-by-side diff view is presented to see what has been changed in a particular code commit

  • Code addition, modification, and deletion are highlighted in different colors for quick identification

  • The changed content of a line is highlighted to show exactly what has changed in the line

  • You can choose to perform a single or multiple diffs

Great tracking

One of the major parameters that teams have to weigh a code review tool is how easy it is to track the review requests. If code review is done manually, it can consume a lot of time tracking all of the review requests and their progress. Also, you might have to keep chasing people to get the review done. With Review Board, one can track the review requests just as user stories and bugs are tracked in other tools. Additionally, Review Board has the following features:

  • It starts tracking the review request as soon as it is posted

  • An e-mail is sent to all of the reviewers upon the publishing of a review request

  • The user dashboard in Review Board presents a list of pending reviews that includes submitted and "to be done" reviews

Integration with all major version control systems

Many code review tools are tied to a specific version control system. This is not the case with Review Board. Review Board can be integrated with Git, Subversion (SVN), Perforce, and Mercurial in a seamless manner.

Not limited to code files

Another good feature of Review Board is that you are not limited to reviewing only the code files. You can upload many other types of files and file formats too.

Admin control

Review Board makes life easy not only for its users, but also for its administrators. Review Board makes it possible to manage almost everything through its web GUI. The following is the list of features that makes an administrator's life easier:

  • A very intuitive web GUI to configure users and repositories

  • All of the system-related statistics (for example, usage and server health parameters) are present on the dashboard

  • It is possible to manage the database from the web GUI

 

Summary


With the setup of Review Board, we come to the end of our first chapter. In this chapter, we learned about pre-commit and post-commit code reviews, various features of Review Board, and how those features help both the author and the code reviewers to do their work efficiently and effectively.

The next chapter will talk about how you will work with Review Board as an author of code who will be publishing the code to Review Board for code review.

About the Author

  • Sandeep Rawat

    Sandeep Rawat is a passionate DevOps consultant who has extensive knowledge of build and release automation along with skills to manage a secure and scalable cloud infrastructure. He is an expert at streamlining build and release processes, and he has used them to achieve multiple, smooth build and releases per day at one of India's popular e-commerce website, Snapdeal. Currently, he is associated with Mettl, an online assessment solution for testing technical, aptitude, and psychometric skills. He works there as a DevOps consultant.

    Sandeep is also an avid blogger. He blogs at http://sandy4blogs.blogspot.in/. In his spare time, he loves to work on various utilities; these can be found on his GitHub profile at https://github.com/sandy724.

    His recent technology love is Puppet and Cloud Hosting.

    Browse publications by this author
Book Title
Unlock this book and the full library for FREE
Start free trial