Skip to content

Commit

Permalink
[Fix #7979] SpellChecker may not be available (#8143)
Browse files Browse the repository at this point in the history
In #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.

Co-authored-by: Bozhidar Batsov <bozhidar@batsov.com>
  • Loading branch information
bquorning and bbatsov committed Jun 12, 2020
1 parent 5de9118 commit e013ef1
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 @@ -13,6 +13,7 @@
* [#8115](https://github.com/rubocop-hq/rubocop/issues/8115): Fix false negative for `Lint::FormatParameterMismatch` when argument contains formatting. ([@andrykonchin][])
* [#8131](https://github.com/rubocop-hq/rubocop/pull/8131): Fix false positive for `Style/RedundantRegexpEscape` with escaped delimiters. ([@owst][])
* [#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][])
* [#8098](https://github.com/rubocop-hq/rubocop/issues/8098): Fix a false positive for `Style/RedundantRegexpCharacterClass` when using interpolations. ([@owst][])

## 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 e013ef1

Please sign in to comment.