I'm an open source project maintainer, working on the projects associated with joind.in, and recently we added a Code of Conduct to all our projects (we have quite a few as you can see from our GitHub organisation page https://github.com/joindin).
I feel the same way about codes of conduct for open source projects as I do about codes of conduct for events. You can absolutely run a totally safe and effective event without one, but by having one you make very clear what your expectations are - and in turn this manages the expectations of the people attending that event.
For an open source project, I think exactly the same thing applies. By stating our principles out loud, I believe that this sends a message to outsiders who may feel reassured that this is a safe place to participate in open source. More importantly, it sends a message to the insiders. It causes us to think about our code of conduct, what our intent is for people involved in the project, and about how we can make sure we run our project along whatever lines we decide to advertise.
Having a code of conduct hurts nobody, and supports (often marginalised groups of) people to participate. I literally can't see a reason why any of this would be a bad idea.
On a more personal note, the process of adding a code of conduct to joind.in was utterly fabulous and a great example of the power of the community. I managed to have dinner with @akrabat (this never happens, we're normally in a conference crowd) and asked him what his thoughts were. He looked at me like I was crazy and we agreed we'd add the code of conduct.
With a recommendation from @snipeyhead we looked into and then adopted the Contributor Covenant, which really felt like a great fit for our projects. Rob got the ball rolling by opening a pull request to add the code of conduct.
I know we did the right thing and we put our project in a stronger place. I am also proud of that moment for all of us to reflect on what we mean our project to be, and to resolve to continue, intentionally and with shared purpose.