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
App Mapping
Github (Commits) |
|
Gitlab (Commits) | N/A: always 0, see below |
Bitbucket (Commits) | Cloud Calculated by summing
Data Center
|
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 GitLab?
GitLab does not return the number of lines of code changed when listing the commits of a merge request. To fetch the lines of code per commit, one must make an additional API call per commit.
We do it for merge 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 GitLab rate limit more quickly, potentially slowing down data imports.
So for now, the lines of code per commit are not retrieved for GitLab, and this field is always 0 on GitLab commits. This decision might be revisited later on.
Reporting Use Cases
The Lines deleted 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
Lines deleted > 0 and Lines added = 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
Lines deleted > 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
Authoras the dimension and aSUM(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.
