I think what you have experienced is very real. Code (and most forms of expression) are a way to externalize your state of mind.
I've seen it with my own emotional states but also with coworkers when they are going trough a rough time.
This is also why it is difficult to understand others ppl code. And it gets easier as you build a relation/get to know them better. The better you know someone, the easier and faster you can understand their code.
I feel like that is why coding standards, code reviews etc make a codebase more maintainable. You strip the code emotions away or at least reset it to a common level across the team.