YUSoMean? A code review tool to help you be nicer

3 min read Original article ↗

Jeremy Nagel

Inspired by I ruin developers’ lives with my code reviews and I’m sorry and Why don’t you just.. I built a little tampermonkey script to give real-time feedback on code review comments. YUSoMean works with GitHub and BitBucket — it analyses the comments you write and helps you craft code reviews that are encouraging rather than demotivating.

Press enter or click to view image in full size

Press enter or click to view image in full size

Press enter or click to view image in full size

Why?

I’ve been on the receiving end (and regrettably on the giving end) of code review comments that feel like more of an attempt to prove who’s the king of the jungle than actually create rock solid, maintainable code. I think there’s something about the medium of text based comments that makes us more likely to say things in a snide, caustic manner that we probably wouldn’t say in person.

Not only is this discouraging for the person on the receiving end but it also makes it less likely that the code review feedback will be actioned. A study at Microsoft found that code review comments were more likely to be considered “useful” if they had a neutral or positive tone.

YUSoMean

YUSoMean is a Tampermonkey script that uses the empath sentiment analysis library to analyse the tone of pull request comments.

As you saw in the screenshots above, it gives you feedback as you are typing your comments. If you want more detailed feedback, you can click on the banner to reveal which words/phrases are problematic:

Press enter or click to view image in full size

The code is simple to allow you to adjust/hack it to suit your own needs. It’s not a super polished solution. I smooshed the frontend together in a couple of hours. The sentiment analysis library is hand-rolled using ̶n̶e̶u̶r̶a̶l̶ ̶n̶e̶t̶w̶o̶r̶k̶s̶ ̶a̶r̶t̶i̶f̶i̶c̶i̶a̶l̶ ̶i̶n̶t̶e̶l̶l̶i̶g̶e̶n̶c̶e̶ a bunch of if statements and a long word list. I wanted something that would work in the browser with zero latency and that I could easily tweak.

How You Can Help

Test It Out

This is a very rough first draft that needs a lot of work. I’m pretty sure there will be tons of false positives/negatives where the library says your comment is mean/nice when it’s actually not.

Please test it out by:

  1. Installing tampermonkey
  2. Create a new user script for YUSoMean by copying and pasting the code from https://github.com/jeznag/yusomean
  3. Report bad sentiment decisions

Improve The Code

I’d appreciate your (polite) code reviews and pull requests! One of the most pressing needs is to figure out how to get this working with GitHub without having to inline the sentiment analysis library. (See this issue for more details)

Keep Writing Nice Code Reviews!