Six refactors that caught real bugs
7 min read
I had a working scraper. A few thousand articles, an embedding model, some analysis scripts. It ran, it produced numbers, and it was riddled with the sort of smells you tell yourself you'll clean up later: a boolean flag here, a bare tuple there, a two-hundred-line main().
So I cleaned them up, expecting a cosmetic hour. Instead, four of the six refactors uncovered a bug that was live in the code at that moment, and the other two made a class of bug unrepresentable. The smells weren't cosmetic. They were the places where the code was vague about what it meant, and the bugs had moved into exactly those places.