I mean kinda, but also not. CoCs just codify what the moderators think.
Even Hacker news has a CoC: https://news.ycombinator.com/newsguidelines.html its just called a guide.
A community has to have a set of rules which most people agree on. One of the most common attacks in a moderated forum is "Oh but X did Y" and "thats not fair X can do it"
A CoC can be a simple way to "tap the sign" when someone is being a dick.
It also allows communities to set expectations at the start, not after someone has transgressed and pissed in the well.
In an ideal world, you'd just have a thing that says "don't be a dick" but that doesn't work for many and hilarious reasons. Engineers who who either have a god complex, parsing issues or empathy gaps (either learnt or inherent ) are notoriously difficult as a community to keep from getting into frothy arguments that colour everything and give off a bad smell.
CoCs are a tool, that can sometimes help.
I found this:
https://www.reddit.com/r/Python/comments/1ep4dbt/the_shamefu...
Which points to this:
https://chrismcdonough.substack.com/p/the-shameful-defenestr...
This characterizes it as completely unfair, and the /r/python community seems to agree.
Is there a rebuttal from the other side?
No CoC is better than a bad CoC or one where interpretation is centralized to someone with an agenda. But many times a decent CoC can help newcomers in reading the room and support well-intended moderators in making judgement calls.
I also think good CoCs are small and mostly reactive. It's premature social engineering to spend energy on formulating general policies for things that happened once or twice if ever for the project.
Like, maybe wait until you actually had a couple of slop PRs before spending time, energy, and political capital on an AI contribution policy.
An open source project without a CoC on the other hand is quite normal and harmless. Maybe some people sometimes get their feelings hurt, but CoCs obviously don't prevent that anyway. The whole thing is dumb.
But if someone can just drag out a law and vaguely accuse someone else of violating that law and then enforce a punishment with no way for the accused to get a hearing or present their case and have a real chance to prevail, then yes I would say the law is bad.
"If you espouse views I don't like on your personal Twitter, you can't contribute to this entirely unrelated software project."
They are something else hijacking the legitimacy of normal justified functional articulable rules.