Skip to main content
Table of Contents

Understanding the Differences Between PR Size and Code Changes in LinearB

Understand the key differences between PR Size and Code Changes in LinearB to accurately measure development effort, track modifications, and optimize your engineering workflows.

Steven Silverstone
Updated by Steven Silverstone

LinearB provides two distinct metrics for evaluating pull requests: PR Size and Code Changes. While they may seem similar, they serve different purposes and are calculated using different methodologies. This article explains the key differences and the factors that contribute to discrepancies between these two metrics.

PR Size vs. Code Changes: Key Differences

PR Size

PR Size is calculated as the final difference between the head branch and the base branch when the pull request is created. It reflects the net change in the code after all modifications have been applied.

PR Size considers:

  • The total number of lines added, modified, or removed.
  • The final snapshot of the changes before merging.
  • Exclusions of specific files based on customer configurations.
Code Changes

Code Changes represent the cumulative sum of modifications made across all commits within the branch's lifecycle. This metric tracks every change made along the way, including additions and removals, before reaching the final PR Size.

Code Changes consider:

  • Every commit made on the branch.
  • The accumulation of all modifications over time.
  • Changes that may have been later reverted.

Example:

Commit

Added

Removed

Total Code Changes

Commit 1

+10 lines

0

10

Commit 2

0

-5 lines

15 (cumulative)

Commit 3

+2 lines

o

17 (cumulative)

Final PR Size: 7 (Net effect after changes).

Total Code Changes: 17 (Sum of all changes made).

Factors That Cause Differences Between PR Size and Code Changes

1. Different Calculation Methods

  • PR Size only reflects the final state of the code in the pull request.
  • Code Changes accumulate all modifications across commits, even those later reverted.

2. Git Diff Similarity Threshold

LinearB applies a similarity threshold to prevent minor modifications (such as a single-character change within a line) from being counted toward Code Changes.

What happens?

Small character edits are ignored, meaning their commits do not contribute to the Code Changes total.

These commits are stored as `commit.activity.total = 0` in branch statistics.

Example:

A commit that only changes a single letter in a comment may not be counted in Code Changes.

3. Code Change Size Thresholds

To prevent inflated Code Changes, LinearB enforces upper limits on the number of changes counted per commit.

Current thresholds:

  • MAX_PATCHES: 1,000 (per commit)
  • MAX_HUNKS: 2,500 (per patch)
  • MAX_HUNK_LINES: 5,000 (per hunk)

Definitions:

  • Patch: A complete set of differences that may span multiple files and hunks.
  • Hunk: A block of changes within a patch.
  • Hunk Line: An individual line added, removed, or modified within a hunk.

If a commit exceeds these limits, its changes are not fully counted toward the Code Changes metric.

4. Excluded “Ineffective” Commits

Certain types of commits are excluded from Code Changes calculations because they do not represent meaningful modifications.

Exclusions include:

  • Cherry-picked commits where the author and committer are different.
  • Bot-generated commits that are ignored in LinearB.
  • Merge commit changes that do not contain direct code modifications.

Example:

A bot-generated commit adding an automated log entry will not contribute to the Code Changes total.

5. Old Commits Not Counted

Due to Git shallow cloning, commits older than 120 days from the branch’s creation date are not counted in Code Changes.

Impact:

  • Older changes may appear missing from the Code Changes metric.
  • PR Size is unaffected because it only considers the final state of the branch.

Example:

If a developer reuses an old branch with changes from 5 months ago, those modifications may not appear in Code Changes.

6. Target Branch Updates Affect PR Size

If the target branch (e.g., `main`) is updated after a pull request is created, some changes may already exist due to another merged PR.

What happens?

  • Code Changes retain all modifications originally made in the branch.
  • PR Size only reflects changes not already present in the updated target branch.

Example:

If another PR adds the same function before the current PR is merged, PR Size will be smaller because the function already exists in the target branch.

Summary: Why These Differences Matter

Understanding the differences between PR Size and Code Changes helps teams:

  • Measure work effectively by knowing which metric applies to different use cases.
  • Identify true workload contributions—Code Changes reflect effort over time, while PR Size shows final impact.
  • Reduce misinterpretations of PR sizes that might seem smaller than expected.

By leveraging both metrics, teams can make better engineering decisions and improve their development workflows.

🔗 PR Maturity Metric Overview

🔗 Understanding Code Churn Metrics

🔗 GitHub vs. LinearB Contributions

How did we do?

Understanding Code Changes

What are LinearB Burnout Indicators?

Contact