Calculate code churn rate from lines added, modified and deleted over time.
Code churn measures how much of the codebase is being rewritten rather than net-added. Formula: churn% = (lines_added + lines_deleted) / total_lines × 100. High churn concentrated in recently-written code often indicates unclear requirements or insufficient upfront design; high churn spread evenly can simply reflect active, healthy maintenance.
churn_percent = (lines_added + lines_deleted) / total_codebase_lines × 100
Not inherently — refactoring, dependency upgrades, and legitimate iteration all produce churn. It becomes a concern when churn concentrates in code that was merged very recently, suggesting rework rather than planned evolution.
Use `git log --numstat --since=<date>` to sum added/deleted lines per commit, or tools like `git-quick-stats` and code analytics platforms (e.g. CodeScene, LinearB) that compute this automatically.
It varies by codebase maturity — under 10-15% churn per period is typical for stable, mature systems, while early-stage projects can run 30-50%+ as design settles without it being a red flag.
Research (e.g. Microsoft's code churn studies) has found correlation between high churn in specific files/modules and higher post-release defect density, making churn useful for targeting review or testing effort.