I used to be much more of a curmudgeon about wanting to clean up
existing code on sight but a few bits of reality seeped in over time, such as:
0. Existing code is probably working fine, and making changes (for any reason) risks adding a bug. Worse, reviewing code with a bunch of reformatting is tedious and the reviewer may assume you’ve only done reformatting and not notice the accidentally-changed behavior either.
1. You have to merge, a lot. And “fixes” that do little except reformat or redo are a pain to deal with when all you really care about is getting functionality in. This multiplies across branches and team members, and might require multiple manual merges.
2. There is a decent chance the code you’re not pleased with will be ripped out entirely as part of some bigger change, at which point all effort to fix unclean parts is moot.
3. Far more people than you are familiar with how it used to be, warts and all. The “cleaned” version now looks alien to everyone else and might slow them down.
That said, there is a time to clean things up; it just has to be at a well-defined point in the project. It involves a combination of things from the article (e.g. talk to the team) and the above (e.g. do it when many features are merged in and there are few branches to deal with).