summaryrefslogtreecommitdiff
path: root/lib/did_you_mean/spell_checkers/name_error_checkers/variable_name_checker.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/did_you_mean/spell_checkers/name_error_checkers/variable_name_checker.rb')
-rw-r--r--lib/did_you_mean/spell_checkers/name_error_checkers/variable_name_checker.rb5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/did_you_mean/spell_checkers/name_error_checkers/variable_name_checker.rb b/lib/did_you_mean/spell_checkers/name_error_checkers/variable_name_checker.rb
index 3e51b4fa3a..9a6e04fe64 100644
--- a/lib/did_you_mean/spell_checkers/name_error_checkers/variable_name_checker.rb
+++ b/lib/did_you_mean/spell_checkers/name_error_checkers/variable_name_checker.rb
@@ -8,6 +8,7 @@ module DidYouMean
NAMES_TO_EXCLUDE = { 'foo' => [:fork, :for] }
NAMES_TO_EXCLUDE.default = []
+ Ractor.make_shareable(NAMES_TO_EXCLUDE) if defined?(Ractor)
# +VariableNameChecker::RB_RESERVED_WORDS+ is the list of all reserved
# words in Ruby. They could be declared like methods are, and a typo would
@@ -62,6 +63,8 @@ module DidYouMean
__ENCODING__
)
+ Ractor.make_shareable(RB_RESERVED_WORDS) if defined?(Ractor)
+
def initialize(exception)
@name = exception.name.to_s.tr("@", "")
@lvar_names = exception.respond_to?(:local_variables) ? exception.local_variables : []
@@ -76,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