Docs
Code Churn Percentage

Code Churn Percentage

Is the percentage of code that is replaced by the author of the code within 3 weeks of merge. High churn impacts Efficiency & captures churning of the code base. Some level of churn is normal and should be expected.

Code-churn-percentage

Code churn breakdown

  1. New Work: Code that is newly added and not replacing/rewriting existing code.

  2. Refactor: Code that is modified after 21 days. This is usually an acceptable change needed for maintenance and is therefore separated out from code churn so as not to raise flags.

  3. Churn: Code that is deleted/rewritten within 21 days of merging is called code churn or rework.

  4. Helping Others: code that is replaced by engineers other than the author of the original code within 21 days of merging. This helps you measure to what extent developers are helping their teammates to improve code quality and delivery.

Computation of the metric

  1. Initial and final lines of code (LOC) in the repository are determined for comparison.
  2. Additions, modifications, or deletions during a specific timeframe are noted.
  3. The overall code churn is computed by subtracting initial LOC from final LOC.

Dashboards where this metric is used

  1. Developer Summary
  2. Dev Metric Grid
  3. Dev Throughput

Use cases of this metric

  1. Code churn of 5-8% is normal, consistently higher value indicates that the rework is high and should be investigated further.
  2. Look for sustained patterns of high rework, high refactoring across teams & repos.
  3. Teams that are undertaking significant overhaul or clearing up debt are expected to show high refactoring rates.