Question

I have just discovered a variable name that is misspelled. If it were hidden away in the depths of code, that would be fine, but this variable name ends up in a configuration that is stored with visibility to the customer. It's really not a big deal, but I wonder if there is a way to avoid it?

In this case the variable name is a compound word, which I won't reproduce here due to NDA, but imagine it was something like "confirmationRecieved" (the i and e are flipped). Can anyone recommend a code spellchecker that would catch something like this?

Was it helpful?

Solution

If you are using Visual Studio, you can activate Code Analysis.

Code Analysis provides several means to validate you code, not only for typos or mispellings, but also for design and quality.

One of the default analysis is CA1704 : Identifiers should be spelled correctly.

If you're not using Visual Studio, but using .NET you can still use FxCop, which performs the same task as Code Analysis, without the IDE integration.

You can find more about Code Analysis here and about FxCop here.

OTHER TIPS

The closest I have to detecting these problems is for function argument names. I use ReSharper with the AgentSmith plug-in. Then, I use GhostDoc to get a first pass at documentation. The AgentSmith plug-in will detect the spelling error. For example

void SomeFunction(int confirmationRecieved)
{
}

Turns into

/// <summary>
/// Somes the function.
/// </summary>
/// <param name="confirmationRecieved">The confirmation recieved.</param>
void SomeFunction(int confirmationRecieved)
{
}

With a red squiggle under "recieved"

Visual Studio has their Find and Replace tool which could easily be used to search through a selected portion of text, an entire document, or all the files of a project for a specific search string.

As far as an actual spellchecker that would somehow be able to understand compound words, I have never seen anything similar that wasn't custom developed.

You haven't mentioned what IDE or platform you're using. However, if you're on Windows using Visual Studio, there is a great plugin called Visual Assist X which has a spellchecker built in. As far as I know, the spellchecker is intended for correcting spelling mistakes in comments and misspelled symbols (assuming you correctly spelled it the first time). To correct these misspellings, Visual Assist has a very useful feature called "Refactor" which allows you to change a variable/class/method name and it will automatically change all other occurrences of the name within its scope. Very handy when you misspell something or need to change a name globally.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top