Scott Watermasysk
Suggestions For Not Forgetting To Remove Unused Code
I am working on a significant update/rewrite of part of KickoffLabs. I had a task to work through what we do in a Sidekiq worker. It was late on Friday when I got to this part of the code, and I decided to punt on it until Monday.
Monday morning, I grab a cup of coffee and sit down to finish this section off and see a comment I missed (and had missed for a long time).
Outside the screenshot, there is an if statement, ensuring this code was not executed in the last four years. Still, it was frustrating that we had missed removing it for so long.
I figured ChatGPT would have a good solution to stay on top of this, but it mostly just tried to explain to me how to use comments. :)
Next up, I asked on Twitter (and Ruby.Social):
Any suggestions (other than search) to ensure code like this gets cleaned up?
From there, I got a lot of good suggestions.
Two Ruby gems looked interesting:
If I had to choose, I would go with todo_or_die since it would cause a failure/notification locally. I would rather not wait until there was a pull request/etc.
The rest of the suggestions included if statements and date checks. My favorite, and the one I will likely adopt going forward, is to wrap it in a test that fails after a specific date.