Check that spelling, please! (code review chronicles)
Tags: codequality, codereviews, collaboration, beginners
Published: 2019-09-18 12:28:51

---
title: Check that spelling, please! (code review chronicles)
published: true
cover_image: https://thepracticaldev.s3.amazonaws.com/i/vd5dn6m6po6zlq9fyhh3.png
description: Finding spelling mistakes in code can be funny or annoying, pointing them out in code review might be nitpicking. Is it necessary? How to prevent them?
tags: #codequality, #codereviews, #collaboration, #beginners
---
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!](https://media.giphy.com/media/YsOpzCbCfLJfO/giphy.gif)

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](https://github.com/xojs/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](https://eslint.org/docs/rules/no-undef))
- `isMantenance´ would be seen as not used (see [No-Unused-Vars](https://eslint.org/docs/rules/no-unused-vars).

#### IDE Spell checkers

When it comes to Emails and Documents (or Blog Posts)  I personally use [Grammarly](https://www.grammarly.com), 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](https://thepracticaldev.s3.amazonaws.com/i/8ox074lllfibvx35rohs.png)
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](https://thepracticaldev.s3.amazonaws.com/i/k94hwbotsueg5m3o4woy.png)

For **Visual Studio** I quickly googled and found 

- [VisualStudio SpellChecker](https://marketplace.visualstudio.com/items?itemName=EWoodruff.VisualStudioSpellCheckerVS2017andLater)
- [Code Spell checker](https://marketplace.visualstudio.com/items?itemName=streetsidesoftware.code-spell-checker)

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?](https://s3.amazonaws.com/lowres.cartoonstock.com/music-lunchbreak-lunch_break-lunch_break-musician-composer-rde9004_low.jpg)

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

{% youtube iyLdoQGBchQ %}

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](https://unsplash.com/@celinen?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText) on Unsplash