🚌 How big is the bus factor for Forem's most complicated files?
Tags: meta, techtalks
Published: 2021-06-18 19:33:01

---
title: 🚌 How big is the bus factor for Forem's most complicated files?
published: true
description: 
tags: 
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z95fein7skk32cc7hmi0.png
---
Ever since watching Adam Tornhill's excellent talk on [prioritizing technical debt as if time and money matters](https://www.youtube.com/watch?v=fl4aZ2KXBsQ), I've wanted a simple way to analyze my own repos. I wanted to replicate Adam's process of identifying code hotspots based on each file's code complexity, change frequency, and recency of the last change. I also wanted to see if I could recreate his "bus factor" analysis to see which files would be most adversely affected if a primary developer was hit by a bus, won the lottery, or just plain quit.

I was able to create a simplified Python version that generated the hotspot data along with other basic git log metrics. I expected some high bus factor files knowing how many initial file commits Ben made to Forem. Surely there were plenty of complicated files that only he touched!


![Top forem committers over time showing the old timers: Ben, Mac, Molly, Michael, and rhymes](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5y7cuzi2k17pu6v8e8jt.png)

The hotspot list shows some intuitive hotspots for a Rails app like schema.rb and routes.rb which are used to manage the database and url routing. It also shows how user.rb and article.rb are hotspots for Forem which make sense given its focus on content publishing. 

```
🔥 Hotspots 
Commits  Comp.   Age    Score  File
  388    63589     1    100.0  db/schema.rb
  427    29318     1     50.7  config/routes.rb
  157    65260     2     41.5  app/javascript/chat/chat.jsx
  359    24357     1     35.4  app/models/user.rb
   98    72604    20     28.8  app/views/admin/configs/show.html.erb
  290    24093     6     28.3  app/models/article.rb
  169    34455     3     23.6  spec/models/user_spec.rb
  154    37107     7     23.2  spec/models/article_spec.rb
   69    48449    59     13.5  spec/requests/api/v0/articles_spec.rb
  177    17235     2     12.4  app/controllers/stories_controller.rb
```

So how susceptible are these hotspots to losing a team member? To analyze the bus factor, you can see how many different authors touched the file in the last 365 days.

![Histogram showing that most hotspots have had lots of authors touch it](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jlzmrukcee115rub7coy.png)

Luckily, most hotspots have had at least 10 unique authors touch the file. This might be another big benefit of taking Forem open: many people have touched the code and that collective body of knowledge now has 20+ unique authors committing per month.


 ![Forem has 20+ unique authors committing per month](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mjkktcekwsjvviawphlv.png)

The good news is that the bus factor with Forem is low and the project should be able to weather changes in contributors. 

If you want to learn more, you can see all of the [analytics](http://nerdthoughts.net/git_analysis/forem/output/results.html) on the repo and view the [source code](https://github.com/stevezieglerva/git-log-analytics) on GitHub. 



Happy Coding!