mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[ruby/did_you_mean] Fixed correction duplicates in VariableNameChecker
https://github.com/ruby/did_you_mean/commit/c3fc412f6f
This commit is contained in:
parent
55b1600987
commit
f67ab7f30c
2 changed files with 13 additions and 1 deletions
|
@ -79,7 +79,7 @@ module DidYouMean
|
|||
def corrections
|
||||
@corrections ||= SpellChecker
|
||||
.new(dictionary: (RB_RESERVED_WORDS + lvar_names + method_names + ivar_names + cvar_names))
|
||||
.correct(name) - NAMES_TO_EXCLUDE[@name]
|
||||
.correct(name).uniq - NAMES_TO_EXCLUDE[@name]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -137,4 +137,16 @@ class VariableNameCheckTest < Test::Unit::TestCase
|
|||
error = assert_raise(NameError){ foo }
|
||||
assert_empty error.corrections
|
||||
end
|
||||
|
||||
def test_exclude_duplicates_with_same_name
|
||||
error = assert_raise(NameError) do
|
||||
eval(<<~RUBY, binding, __FILE__, __LINE__)
|
||||
bar = 1
|
||||
def bar;end
|
||||
zar
|
||||
RUBY
|
||||
end
|
||||
|
||||
assert_correction [:bar], error.corrections
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue