Bad program code is actively harmful. It's not just that a specific piece of functionality is flawed and/or hard to maintain. Badness tends to spill over into the surrounding code, because maintainers get confused, demotivated and/or frustrated into producing more of it. This is known as “Bit Rot”. Developers should [not feel comfortable|no-broken-windows] around bad code.
All bad code has an author, or authors as the case may be. It's tempting to associate the author with the code. Don't. We criticize bad code, we don't criticize people. Fix the code, discuss the problem with the team and show them how it can be done better. Prevent the same sort of badness from entering the system again.
This approach yields multiple benefits: better code, fewer repetitive mistakes, more knowledge exchange.