26
๐ How big is the bus factor for Forem's most complicated files?
Ever since watching Adam Tornhill's excellent talk on prioritizing technical debt as if time and money matters, 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!
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.
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.
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 on the repo and view the source code on GitHub.
Happy Coding!
26