behaviorbot / sentiment-bot

Replies to toxic comments with a maintainer designated reply and a link to the repo's code of conduct
https://github.com/apps/sentiment-bot
MIT License
83 stars 12 forks source link

Don't show CoC link if there isn't one #12

Closed hiimbex closed 7 years ago

hiimbex commented 7 years ago

I thought https://github.com/behaviorbot/sentiment-bot/blob/3b0aff3ff3bbbb141fb5e0c305aa299f1ba4e78c/index.js#L17-L19 and https://github.com/behaviorbot/sentiment-bot/blob/3b0aff3ff3bbbb141fb5e0c305aa299f1ba4e78c/index.js#L38-L42 would handle this however, due to https://github.com/github/github/issues/73388 that's not true.

This is something I'll be fixing later this week for my team 😆 crazy how everything is connected.

cc/ @benbalter @bkeepers for interesting things :)

hiimbex commented 7 years ago

I could fix this just by checking for codeOfConduct.name and codeOfConduct.url but I think the larger fix will be cleaner code wise, so I'll hold off on this for now.

hiimbex commented 7 years ago

Actually, might as well add this in since it probably won't get updated for a bit, since I'm using a different API than the community profile one, and the node-github support for that is behind.

Opening this up to hacktoberfest! Basically You need to add a check here: https://github.com/behaviorbot/sentiment-bot/blob/3b0aff3ff3bbbb141fb5e0c305aa299f1ba4e78c/index.js#L38

to make sure that codeOfConduct.name and codeOfConduct.url also exist.

This check should probably occur inside the initial if statement, because I think one day this may be fixed, where the current check is sufficient and I wouldn't want it to break (ie if codeOfConduct does not exist, checking for codeOfConduct.name would cause an error.

hiimbex commented 7 years ago

Closed via #15