Skip to content

Commit

Permalink
[Fixes rubocop#7979] SpellChecker may not be available
Browse files Browse the repository at this point in the history
In rubocop#7979 it was reported
that DidYouMean::SpellChecker may not always be available. We can work
around it by doing a feature check before using the SpellChecker class.
  • Loading branch information
bquorning committed Jun 12, 2020
1 parent 3b0552b commit 752bf8e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -11,6 +11,7 @@

* [#8115](https://github.com/rubocop-hq/rubocop/issues/8115): Fix false negative for `Lint::FormatParameterMismatch` when argument contains formatting. ([@andrykonchin][])
* [#8124](https://github.com/rubocop-hq/rubocop/issues/8124): Fix a false positive for `Lint/FormatParameterMismatch` when using named parameters with escaped `%`. ([@koic][])
* [#7979](https://github.com/rubocop-hq/rubocop/issues/7979): Fix "uninitialized constant DidYouMean::SpellChecker" exception. ([@bquorning][])

## 0.85.1 (2020-06-07)

Expand Down
6 changes: 6 additions & 0 deletions lib/rubocop/name_similarity.rb
Expand Up @@ -12,6 +12,12 @@ def find_similar_name(target_name, names)
end

def find_similar_names(target_name, names)
# DidYouMean::SpellChecker is not available in all versions of Ruby, and
# even on versions where it *is* available (>= 2.3), it is not always
# required correctly. So we do a feature check first.
# See: https://github.com/rubocop-hq/rubocop/issues/7979
return [] unless defined?(DidYouMean::SpellChecker)

names = names.dup
names.delete(target_name)

Expand Down

0 comments on commit 752bf8e

Please sign in to comment.