Skip to main content

Commits > Lines deleted

Tom Williams avatar
Written by Tom Williams
Updated over 2 weeks ago

Dataset: Commits from pull requests

Entity: Commit

Field ID: deletions

Type: Integer

Description: The number of lines of code deleted in the commit.

Source: App

From:

Github (Commits)

deletions

Gitlab (Commits)

N/A

Bitbucket (Commits)

N/A

Azure DevOps (Commits)

Calculated from a git-based code diff

Jira

N/A

ClickUp

N/A

Trello

N/A

Why are lines of code not fetched for Bitbucket and GitLab?

Bitbucket and GitLab do not expose the number of lines of code changed on the commit API. To fetch the lines of code per commit, one must make an additional API call per commit (fetch the commit individually or the diff stats).
​
We do it for pull requests because the number of additional API calls remains reasonable (several thousand). However, commits could generate many additional API calls (several tens or hundreds of thousands), which would, in turn, contribute to reaching the Bitbucket throttling quota more quickly, potentially hindering data hydration (because the quota gets reached regularly).
​
So for now, the lines of code per commit are not retrieved for Bitbucket and GitLab. This decision might be revisited later on.

Reporting Use Cases

The Deletions field from the Commits dataset provides a detailed, commit-by-commit view of code removal and refactoring activities. It is a powerful numeric field for analyzing the nature of your team's changes, quantifying cleanup efforts, and identifying specific refactoring events within a pull request.

  • Filtering for Refactoring and Cleanup: You can create reports that specifically target commits involving code removal.

    • Find "Removal-Only" Commits: Isolate commits that only remove code (e.g., deleting a deprecated file or feature) by using a filter where Deletions > 0 and Additions = 0. This is a great way to track and quantify cleanup efforts.

    • Identify Large Refactors: You can find individual commits that represent a significant refactoring effort by filtering for Deletions > 500.

  • Analyzing Contribution Patterns: You can aggregate this field to understand the volume of code removal and refactoring work.

    • Cleanup Effort per Author: A bar chart with Author as the dimension and a SUM(deletions) metric will show the total volume of code each developer has removed, highlighting who is most involved in maintenance and technical debt reduction.

  • Custom Formulas for Advanced Code Health Metrics: This field is a critical component for calculating refactoring ratios at a granular, commit-by-commit level.

    • Commit-Level Refactoring Ratio: In a list of commits, you can add a custom dimension to see the refactoring ratio of each individual commit with the formula ROUND(deletions / IF_ZERO(additions, 1) * 100, 2). This allows you to distinguish between commits that are adding new functionality and those that are primarily focused on refactoring existing code, even within the same pull request.

Did this answer your question?