Code Churn Data Plugins

I know this has been a question that has been asked many times in the past, but hasn’t been brought up recently. I also understand that sonar doesn’t have default support nor doesn’t plan to support code churn metrics, but I wanted to reach out to the community to see if anyone has either written a plugin or found a way to pull code churn metrics from SonarQube.

We are looking for a churn metrics for that specifically looks at how much the code has been reworked in the first 2-3 weeks after it is initially added to the codebase. The below metrics are specifically what we are trying to pull.

  1. Change Count: This is the measure of the number of times the development team made changes to a file in the version control.
  2. Lines Added: This is the number of lines of code the developers added to files for the code that was added within the time window.
  3. Lines Deleted: This metric is the measure of the number of lines of code that were deleted from files by the developers within three weeks of writing the code (i.e. A line added on Day 1 that was deleted on day 14).
  4. Lines Modified: This metric is the measure of the number of lines of code that were modified by the developers within 3 weeks of writing the code. (Doe git support this?)

We understand the implications that could come from pulling these metrics and how they can be weaponized against developers in a negative way. The team working on metrics isn’t planning on handing raw churn metrics to management and saying this dev cant write good code the first time. They are planning on wrapping them and pointing to resolution measure rather than blame game.

Hi,

Welcome to the community!

As you say, Sonar doesn’t have anything for this.

And I nonetheless wanted to ask:

Are you talking about after a PR is merged, or are you going to include pre-merge ‘churn’, while the code is basically still being written?

 
Ann

No, we are looking primarily at post merge metrics with a case in helping determine areas that teams might need to put more effort. IE, requirements, code review standards and instances like that. We want to see if the code that has made it past the review process needs to be reworked.

1 Like