What is Pull Request Size?
Pull Request Size measures the number of lines changed within each pull request submitted for review.
Why does Pull Request Size matter?
Reviewing pull requests can be one of the most time consuming activities of a team’s software development process.
Making smaller pull requests is the best way to speed up time spent reviewing your peer’s work. By applying the discipline to break down pull requests into smaller, manageable batches of code, it’s much quicker for reviewers to understand the context, reason with the logic and detect defects that need remediation.
Small pull requests also make it more likely for code to be thoroughly reviewed before approval. It helps to speed up the review, reduces risk of introducing bugs into the codebase, helps not to block other developers and speeds up the process to finalise and ship the team’s product to customers for feedback.
Large pull requests tend to be glazed over and rubber stamped, limiting the effectiveness of defect detection.
What does ‘good’ Pull Request Size looks like?
Common practice suggest developers should review Pull Requests no more than 200-400 lines of code (LOC) at a time. This is because the brain can only process so much information at a time. Beyond 400 LOC, the ability to find defects diminishes.
Research also indicates that a review of 200-400 LOC over 60-90 minutes should yield a 70-90% defect discovery rate.
How Umano measures Pull Request Size
Umano measures Size of Pull Request through:
Number of files changed
Number of lines added and/or removed
Practices that influence Pull Request Size
Number of lines added in a PR
Number of lines removed in a PR
Number of issues addressed in a PR
Number of comments made by reviewers
Number of tasks created by reviewers
What’s included?
Each model looks at specific activities within the tools. Below is a list of activities that contribute to Pull Request Size and activities that do not have an impact on this metric.
Included | Not included |
All Pull Requests in selected repositories | Number of files per Pull Request |
Tips for improving Pull Request Size
Review fewer than 400 lines of code at a time for effective defect detection
Code reviews in reasonable quantity, at a slower pace for a limited amount of time results, done frequently throughout the sprint is the most effective code review practice.
Acknowledge Pull Requests that delete lines of code in your code base as this usually indicates authors are cleaning-up the code base, removing technical debt and improving maintainability of your code base.
Resources
Dias, H., The anatomy of a perfect pull request, 2018, <The anatomy of a perfect pull request >
Osepchuk, B., Optimal pull request size, 2017, <https://smallbusinessprogramming.com/optimal-pull-request-size/>
Riosa, B. The (written) unwritten guide to pull requests, 2016, <The (written) unwritten guide to pull requests - Work Life by Atlassian >
Dias, H., The anatomy of a perfect pull request, 2018, <https://opensource.com/article/18/6/anatomy-perfect-pull-request>
Hewa, G., How Big is Your Pull Request?, 2017, <https://hackernoon.com/how-big-is-your-pr-32c4d67ad76c>
Yu, Y., Wang, H., Filkov, V., Devanbu, P. and Vasilescu, B., 2015, May. Wait for it: Determinants of pull request evaluation latency on GitHub. In Mining software repositories (MSR), 2015 IEEE/ACM 12th working conference on (pp. 367-371). IEEE.