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 breakdown
-
New Work: Code that is newly added and not replacing/rewriting existing code.
-
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.
-
Churn: Code that is deleted/rewritten within 21 days of merging is called code churn or rework.
-
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
- Initial and final lines of code (LOC) in the repository are determined for comparison.
- Additions, modifications, or deletions during a specific timeframe are noted.
- The overall code churn is computed by subtracting initial LOC from final LOC.
Dashboards where this metric is used
- Developer Summary
- Dev Metric Grid
- Dev Throughput
Use cases of this metric
- Code churn of 5-8% is normal, consistently higher value indicates that the rework is high and should be investigated further.
- Look for sustained patterns of high rework, high refactoring across teams & repos.
- Teams that are undertaking significant overhaul or clearing up debt are expected to show high refactoring rates.