Treat code mess with the same techniques you would treat RL mess. Sometimes you sweep it under the rug. You can toss it in a closet or attic. You can buy a shelf or box and toss everything in there.
You can clean it up seasonally, like set aside a sprint for it.
Some kinds of messes are hazardous and absolutely should not be tolerated - this is similar to leaving milk out or trash piling. Many people make this mistake of assuming that because some messes are very dangerous, all of it is too.
Most messes will slow you down, but cost more to clean up. Overall, I've seen documentation do more harm than help - it's often faster to interrupt a colleague doing something than for that colleague to spend weeks documenting and updating documentation on something that gets thrown away.
Some will take more time to fix later than now - this is what people mean by tech debt. But it's less common than it seems.
With a lot of mess piles, the important parts float to the top and the less important ones sink at the bottom. God classes are mess piles.
Once the mess becomes a burden, it's a good time to clean up.
You may need a few janitors and landscapers, especially for a large code base.
Some people place much higher priority on cleanliness than others. Be respectful of them but you don't have to be like them.