Where parallels cross

Interesting bits of life

Emacs as your code-compass: how much code did we produce for this repository lately?

Too long; didn't read

Use code-compass c/show-code-churn to keep an eagle eye on what happened on your repository by checking how much more or less code entered your repository. The more the new lines the more you need to maintain!!

The problem

Git can tell you how much code you added or removed from your repository over the last commits. However that requires a bit of terminal-fu: can Emacs tell us that in a more human readable way?

It is a problem indeed

Actually code churn is more than just a curiosity. Sometimes you may discover a spike of additions over the history of the repository. Probably because you were adding some new functionality. And that spike may be a warning to finally split the repository in two, so that responsibility is organized more clearly and maybe you can end up reusing it better!

Another thing you may want to look for is that the amount of removed code increases as well: if you keep adding without deleting, you are making things harder to maintain! Ideally lines of code should keep decreasing, indicating that we are finding simpler and smarter ways to do the same things (even testing!).

And there is a solution

Well, code-compass has a command for that: c/show-code-churn.

If you call that, you will see a graph like the following:


In the picture above you can see that on the 2020-09 somebody added more that 900 lines of code without deleting much. On 2020-11 there was an addition of more than 1k lines but also a similar number of removed lines which would make me feel less concerned.

This graph gives a high level warning that something atypical has happened, but by itself leaves us unaware about what kind of change happened on the repository (for example, a lot of documentation may have entered the repository. So any finding obtained from this analysis is a starting point for further investigation. Ideally, you will see deleted lines spikes which indicate some lovely engineers taking care of the codebase with their refactoring.


If you are curious to see the code churn for your repository, just get code-compass and run c/show-code-churn!

Happy eagle-viewing!