Keeping code clean is constant effort, to do it well it requires everyone to keep an eye out for cruft and fix it wherever they see it.
This kind of refactoring on a feature branch is awkward because it makes the Big Scary Merge worse.