Reading Code Reviews from the Azure DevOps API
| September 8, 2021 | in
Code reviews are one of the best things you can use as a proxy for how things are going on a project. Just the lack of code reviews is very telling. But how long it takes to do code reviews can also be telling, as can the size of code reviews. If you have to review 100 items, that is not a good sign.
Code reviews are part of any modern process and any modern source control management system. Many times, they will be referred to as pull requests.
Getting good code review metrics from systems such as DevOps or GitHub requires a little bit of work. In this post, we are going through pulling some code review data from DevOps.
The first step is getting the right NuGet packages.
Next, we must set up our client.
Then we must get the reviews. We can use the GetReviewsAsync method to achieve this.
After we have the reviews, we have things like the title, status, and start/end dates to calculate the total time open.
Getting the number of changes is a little tricker. It requires looping through all of the iterations to get the number of changes. Note in the code below: if there are more than 5,000 changes, we won’t get them all; we are stopping at 5,000. If a code review has 5,000 files changed, you have a big problem.
The Azure DevOps API allows for receiving a lot of information about your code and processes, which allows for combining that information with something like GitHub’s SPACE framework.