[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
@ -79,7 +79,7 @@ module DidYouMean
|
|||||||
def corrections
|
def corrections
|
||||||
@corrections ||= SpellChecker
|
@corrections ||= SpellChecker
|
||||||
.new(dictionary: (RB_RESERVED_WORDS + lvar_names + method_names + ivar_names + cvar_names))
|
.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
|
end
|
||||||
end
|
end
|
||||||
|
@ -137,4 +137,16 @@ class VariableNameCheckTest < Test::Unit::TestCase
|
|||||||
error = assert_raise(NameError){ foo }
|
error = assert_raise(NameError){ foo }
|
||||||
assert_empty error.corrections
|
assert_empty error.corrections
|
||||||
end
|
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
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user