loading...
Cover image for Check that spelling, please! (code review chronicles)

Check that spelling, please! (code review chronicles)

dvddpl profile image Davide de Paolis ・3 min read

Are you an annoying, picky, pedant code reviewer?
I guess I sometimes am.

No, I don´t argue about tabs or semicolons ( we use a linter for that).
And I don´t ask to rewrite code only because I would have written it slightly differently.

Why then?
Well, I will give you a bit of context:

Out of 9 people in my team, none is a native English speaker.

Can you already imagine what I mean?

In such a working environment - with developers from India, Egypt, Italy, Poland, Russia, China, Bulgaria - with different languages and alphabets - it can happen very often that you drop or find a spelling mistake.

Maybe the code is absolutely fine, nice implementation and unit tests are there, but here you go:

const analiseData = (data)=> //awesome code here

my eyes bleed!

What do you do?
Do you reject the Merge Request ( or Pull Request - if you are using github) just because of that?

Or maybe the MR is already spotted with comments and requests of modifications, do you add typos on top of all that?

Wouldn´t it be nitpicky?

As much as I don´t want to hurt people feelings, to sound like a boring English teacher or simply to slow down our sprint by becoming a bottleneck for all the tickets in Approval for a MR, I really believe typos should be eliminated from the code.

Code must be human-readable and must be written for your coworkers and your future self.

If you allow a method named loadCampaings to pass the code review and make it into the master code, this could happen:

  • other devs not aware of that bad spelling might invoke a missing function or access a property that is not there, leading to bugs.
  • or they will have to add some cognitive load and domain project burden having to remember that that function is not called loadCampaigns but really loadCampaings.
  • if you remember there was such a function and search for it / grep it you won´t be able to find it ( assuming you are spelling it correctly).

So, imho, typo should be pointed out ( with the usual care and sensibility required in every Code Review ) because they could lead to bugs and hard-to-maintain code.

But how to avoid or improve the process?

Linters

Some linters (we used XO and we love it) help to spot immediately missing functions or properties because:

  • you try to access the correct isMaintenance property - which was not declared (see No-undef)
  • `isMantenance´ would be seen as not used (see No-Unused-Vars.

IDE Spell checkers

When it comes to Emails and Documents (or Blog Posts) I personally use Grammarly, but when writing code in IntelliJ IDEA I have the Typo Inspections activated so that spelling mistakes are marked with a green squiggly line ( you can define the level of "notification" you prefer and eventually set it as "warning" or "error", so that it stands out even more and no spelling errors slip in)

Typo inspections
Besides the immediate visual aid in the file you are editing you can also run a project wise analysis just by running Analyze / Inspect Code.

Alt Text

For Visual Studio I quickly googled and found

I am pretty sure there are plenty more, same for any other IDE you might be using.


These are a couple of spelling mistakes I found recently during our code reviews - and I could not resist pointing them out to the author with a funny link ( sent privately on slack - not in the official MR comment!).

const timestampUnit = "minuets"

minuets or minutes?

The purpose of this **Lambada** function is to ..... (inside a README.md)

Was I too mean?
Have you ever find something funny?

By the way - assuming you are not english speaker, and your team is not multicultural - do you code in english anyway or in your native language?


Photo by Celine Nadon on Unsplash

Posted on by:

dvddpl profile

Davide de Paolis

@dvddpl

Sport addicted, productivity obsessed, avid learner, travel enthusiast, expat, 2 kids. 🏂✈🚞🌍📷🖥🤘👨‍👩‍👦‍👦🚀 (Opinions are my own)

Discussion

markdown guide
 

I'm based in Germany. We have several German only projects with only German colleagues, as well as many international projects with colleagues from other sites and different languages.
We always code in english no matter what language the project is in or what the native language of the participants is.
I'm also a fan of pointing out and correcting those mistakes. I am thankful when someone points these out for me as well.
So I agree with you!
The reason is simple: as non native it is an opportunity to get better at it and for all of us to be more professional.

I was reading an article about why it is hard for Germans to get the English grammar right recently.
The German and English languages are related. They are both Germanic languages. This makes it difficult for Germans, because certain wrong sentences sound right to us.
Example: I hear "I'm doing Homeoffice" quite often in the office. Everybody will get what's meant but correct would be "I'm working from home".

There's this very interesting article (written in German) which explains the similarities and the pitfalls:
google.com/amp/s/t3n.de/news/busin...

 

thanx for your comment. I read the article and is very interesting! I will look for something similar for Italian. With Italian I often see there is a mix with german and English mistakes: sometimes the false friend is in German, but works in English sometimes it's the other way around.
Many years ago in a small web-agency in Italy I remember we were coding in Italian, it was awful, (especially because many methods and props ended up being a mix because English is often shorter or less verbose... ) and when I started working here I was very relieved coding in English - until I found some old pieces of code - or worst - comments and documentation written in German ( still I enjoyed that because it helped me to learn quickly the Sprache!)

 

I see, even the italian language is a romanic language, there are some pitfalls when translating from/to German.
As a German it feels natural to read some documentation or code in German (I guess it's the same as an Italian?) but especially with technical topics and terms I tend to go with english because often there is no good transaltion for english terms regarding technologies and is clearer to use the english word. Also to prevent misunderstandings. So for learning another language it could be beneficial, but to build a common understanding of things, english is preferred.
Just as you stated in your post, it is very important to point out even the slightest mistakes :)