Interesting. Does it happen often in practice?
> I bet it's the same for all civilized countries.
The US doesn't have such laws. Whether you consider the US civilised, is another matter. :) Do you want to exclude contributors from uncivilised countries?
> CoCs have nothing to do with the rest of the things you're saying. They are not enforceable by law, they won't get you any kind of conviction. Best case scenario, you shun the person that didn't adhere by it. Which guess what? You can do that anyways, without any CoC in place.
The goal of a CoC is to have a set of rules that the community agrees upon and to foster a certain culture. E.g. no personal attacks, constructive criticism only, be civil in your interaction with others on the project. The consequences of violating the CoC can be to ban the violator from the project.
Wether you agree with those goals or not, it is the right of a community to decide which culture they like. And different communities will attract different kinds of people. Quite a few people choose not to contribute to the Linux kernel because of the abrasive leadership style of Linus. You might choose to not contribute to the Golang project.
You argued that you don't need a CoC because the laws already cover the same ground. If your goal is to foster a certain culture, it is simply not feasible to use the law to enforce it.
Hacker News has guidelines which are not dissimilar to a CoC, but less formalised: https://news.ycombinator.com/newsguidelines.html. Are they useless too in your opinion?