comments_per_pull_request

Category: KPIs Library.

Software development is a team effort, and collaboration is king. Every coder knows the significance of code reviews, but how often do we delve into the metrics that measure this collaboration? One such metric, often overlooked but immensely insightful, is ‘comments per pull request.’ Discover why it might be the magic number your team needs.

What are Comments Per Pull Request?

Simply put, comments per pull request denote the number of comments a pull request (PR) receives during the code review process. It’s not just about the quantity but the quality of the dialogue between developers and reviewers.

Why Should You Care?

  • Improved Code Quality
    A higher number of constructive comments usually represent active engagement, feedback, and suggestions that refine the code.
  • Enhanced Collaboration
    More comments promote a culture of open communication where everyone feels involved in the project’s success.
  • Early Bug Detection
    Collaborative PRs often lead to early identification of potential bugs or issues and a higher likelihood of catching an oversight.
  • Learning and Growth
    Newer developers benefit from detailed feedback, which helps them understand mistakes, better practices, and alternative solutions.

However, it’s essential to strike a balance. While having zero or very few comments might indicate a lack of thorough review, an exceedingly high number might suggest confusion, ambiguity, or disagreements. The goal isn’t to achieve a specific ‘golden’ number but to foster a culture where constructive feedback is encouraged and every comment adds value.

Boosting Quality Conversations

To make the most of comments per pull request

  • Encourage Constructive Feedback
    Comments should be actionable and specific. Avoid vague feedback.
  • Promote Respectful Interaction
    While criticisms are part of the review process, they should always be constructive and never personal.
  • Empower Junior Developers
    Encourage newer team members to ask questions and seek clarification.
  • Use Tools to Your Advantage
    Leveraging tools that streamline the review process can help maintain the quality of comments while reducing unnecessary back-and-forths.
Steve Jobs

Everyone should know how to program a computer, because it teaches you how to think!

Steve Jobs

Calculating Comments Per Pull Request

Step-by-Step Guide

  1. Gather Data
    Collecting the total number of comments made on pull requests over a specified period. This can be a week, a month, a sprint cycle, or any other duration relevant to your workflow.
  2. Count the Pull Requests
    Count the total number of pull requests made during the same time frame.
  3. Divide and Derive
    To calculate the average number of comments per pull request, divide the total comments by the number of pull requests.

cppr
Example
Let’s say that over a month, your team had
Total Comments = 320
Total Pull Requests = 40
Using this formula, we get:
CPPR = 320/40 = 8

This means, on average, each pull request received 8 comments.
Calculate this metric consistently over regular intervals for a more accurate representation. This will help you track trends and identify increased or decreased collaboration periods. While the metric gives a quantitative perspective, always delve deeper into the content and quality of the comments to get a comprehensive view of the collaboration.

Here’s how the OKR can be applied to improve both collaboration and code quality

  1. Setting Clear Objectives: For instance, “Improve the quality of collaborative code reviews.” This objective emphasizes the collaborative aspect of code reviews, guiding the team towards a unified goal.
  2. Defining Quantifiable Key Results: Examples include “Achieve an average of ‘X’ comments per pull request by the end of the quarter” or “Ensure 90% of comments are constructive and actionable.” By laying out these measurable outcomes, you give your team tangible goals to work toward.
  3. Tracking and Accountability: By monitoring ‘Comments Per Pull Request’ weekly or monthly, teams can assess if they are on track to meet their key results. If numbers are lagging, corrective actions can be taken in real time.
  4. Encouraging Constructive Feedback: OKRs allow the team to shift focus from quantity to quality. This approach can lead to more enriching discussions and better code outcomes.
  5. Promoting Continuous Learning: By tying the metric to team development goals, the emphasis on comments ensures skill enhancement and knowledge sharing.
  6. Iterative Improvement: After each OKR cycle, teams can reflect on achieved results, extract insights, and refine their objectives for the next cycle.

To learn more about OKRs, sign up for a free demo with Profit.co

Sign up Today

OKR Example to Enhance Comments Per Pull Request KPI

Objective: Enhance collaborative code reviews to foster higher code quality and team engagement.

Key Results 1

Increase the average ‘Comments Per Pull Request’ from 6 to 10 by the end of the quarter.

Initiatives

  • Host weekly code review workshops focusing on best practices.
  • Introduce pair programming sessions to foster more collaborative coding habits.
  • Allocate dedicated time blocks for code reviews to ensure team members have ample time to review and comment.

Key Results 2

Achieve 80% of comments being constructive feedback, offering actionable insights or suggestions.

Initiatives

  • Organize monthly training sessions on giving and receiving constructive feedback.
  • Implement a peer recognition program to reward team members who consistently offer high-quality feedback.
  • Provide team members with templates or guidelines for what constitutes constructive feedback.

Key Results 3

Reduce the percentage of pull requests with zero comments to less than 5% by the end of the quarter.

Initiatives

  • Implement a review buddy system, where team members are paired to ensure each pull request gets at least one review.
  • Set up automated reminders or alerts for pull requests that haven’t received comments after a certain period.
  • Create a dashboard where team members can quickly see unreviewed pull requests and jump into the review process.

Conclusion

By integrating the OKR methodology with the ‘Comments Per Pull Request’ metric, teams can foster a more collaborative environment, set and track tangible collaboration goals, and continuously evolve their code review processes. In essence, OKRs provide the structure and direction to ensure that comments per pull request lead to tangible improvements in code quality and team collaboration.

Ready to start your KPI journey today?

Book a free demo

Related Articles