> Firstly, I didn’t talk to the person who wrote it.
This might be an issue in itself sometimes. People identifying with the code they wrote. When you are part of the team, the code belongs to everyone. Everyone should be able to change it if it makes sense and all quality gates are passing.
> When you are part of the team, the code belongs to everyone. Everyone should be able to change it if it makes sense and all quality gates are passing.
Yes, but actually no. Context is important here. If that code had been written six months ago or even a couple of weeks ago? Have at it. But, the OP states "My colleague has just checked in the code that they’ve been writing all week." then "It was already late at night (I got carried away)."
If spent all week on something, working out the all the details, checked it in at 5pm, and then came in the next morning to discover that someone stayed up rewriting it rather than waiting till the next morning to talk to me about it first, I'd be absolutely livid.
sure everyone should be able to change the code, but somebody is immediately refactoring new code to align with their own opinions and making it worse in the process is not ok. i would immediately revert the commit if somebody did that to me (and then tell them why of course)
well obviously both, but it just isn't a very good point. by making changes to the shared code in that specific way, you are undermining and insulting the developer who is supposed to be part of your team. you can't just pretend that the team aren't humans and that social conventions and etiquette don't apply.
Context is very important. If this happens overnight and out of nowhere/excess pro-activity, it's definitely an issue.
But the reality is usually more nuanced. Even saying that because of this particular situation clean code is bad, it's an exageration.
This might be an issue in itself sometimes. People identifying with the code they wrote. When you are part of the team, the code belongs to everyone. Everyone should be able to change it if it makes sense and all quality gates are passing.