Code Churn

Code churn is a measure that tells you the rate at which your code evolves. Code churn has several usages:

  • Visualize your development process: Your code churn signature in the diagrams below mirrors the practices you use to deliver code. You may want to watch out for regular spikes, which may hint at a mini waterfall going on in your daily work
  • Reason about delivery risks: Code churn is a good predictor of post-release defects. Thus, it’s a warning sign if you approach a deadline while your code churn increases. That’s a sign that the code gets more and more volatile the closer you get to your deadline. You want the opposite. You want to stabilize more and more code the closer you get to delivery.
  • Track trends by task: CodeScene lets you inspect the size and impact of your tasks. Use the information to see if your project management tasks are on an appropriate level or if each one of them implies a mini big bang in terms of code changes.

CodeScene provides several churn measures. They’re all described in this guide and you typically investigate all of them to get the overall trend in your codebase.

Use the Commit Activity as the Pulse of your Codebase

The commit activity chart shows the number of commits and contributing authors over time as illustrated in Fig. 39.

Commit and Author activity

Fig. 39 The commit activity chart.

The number of commits and authors over time is a different kind of churn. This metric will typically correlate well with your other Code Churn metrics described below. However, you want to look out for potential productivity issues like an increase in authors without a corresponding increase in commits and churn; Such a trend often indicates that you’ve more programmers contributing than the software architecture (and/or organization) can support.

Inspect The Level of your Tasks

It’s a challenge to strike the right level when you partition your work into individual tasks. Too large tasks are hard to reason about, verify and plan. Small and well-focused tasks are preferrable.

CodeScene lets you inspect the impact of your project management tasks on the codebase in terms of both code churn and collaboration (that is, how many authors worked together to solve the task?) as illustrated in Fig. 41.

Code Churn by Ticket ID

Fig. 41 Inspect the code churn on a task level.

CodeScene uses your Ticket ID to group individual commits into tasks.