Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DidYouMean::SpellChecker may not be available #8143

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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)
bquorning marked this conversation as resolved.
Show resolved Hide resolved

names = names.dup
names.delete(target_name)

Expand Down