diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2020-05-12 16:22:41 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2020-05-12 16:27:25 +0900 |
commit | ee518cf077b856fddea7dfae5d85f3c3117dd616 (patch) | |
tree | a78f4d1bbb8745ff3c8e39d28900b7446c858669 /lib/did_you_mean | |
parent | 317fdd6df2fce0fa5538690c6f6547585b494f2e (diff) |
Revert "Sync did_you_mean"
This reverts commit 946dadd3f479198e87873a863d15c7660a8e2b56,
which broke `TestGemRequire` and others.
Diffstat (limited to 'lib/did_you_mean')
-rw-r--r-- | lib/did_you_mean/spell_checkers/method_name_checker.rb | 7 | ||||
-rw-r--r-- | lib/did_you_mean/spell_checkers/require_path_checker.rb | 33 |
2 files changed, 1 insertions, 39 deletions
diff --git a/lib/did_you_mean/spell_checkers/method_name_checker.rb b/lib/did_you_mean/spell_checkers/method_name_checker.rb index 0483127d6f..3a38245f0c 100644 --- a/lib/did_you_mean/spell_checkers/method_name_checker.rb +++ b/lib/did_you_mean/spell_checkers/method_name_checker.rb @@ -43,12 +43,7 @@ module DidYouMean end def corrections - @corrections ||= begin - dictionary = method_names - dictionary = RB_RESERVED_WORDS + dictionary if @private_call - - SpellChecker.new(dictionary: dictionary).correct(method_name) - names_to_exclude - end + @corrections ||= SpellChecker.new(dictionary: RB_RESERVED_WORDS + method_names).correct(method_name) - names_to_exclude end def method_names diff --git a/lib/did_you_mean/spell_checkers/require_path_checker.rb b/lib/did_you_mean/spell_checkers/require_path_checker.rb deleted file mode 100644 index 10239947dd..0000000000 --- a/lib/did_you_mean/spell_checkers/require_path_checker.rb +++ /dev/null @@ -1,33 +0,0 @@ -# frozen-string-literal: true - -require_relative "../spell_checker" -require_relative "../tree_spell_checker" - -module DidYouMean - class RequirePathChecker - attr_reader :path - - INITIAL_LOAD_PATH = $LOAD_PATH.dup.freeze - ENV_SPECIFIC_EXT = ".#{RbConfig::CONFIG["DLEXT"]}" - - private_constant :INITIAL_LOAD_PATH, :ENV_SPECIFIC_EXT - - def self.requireables - @requireables ||= INITIAL_LOAD_PATH - .flat_map {|path| Dir.glob("**/???*{.rb,#{ENV_SPECIFIC_EXT}}", base: path) } - .map {|path| path.chomp!(".rb") || path.chomp!(ENV_SPECIFIC_EXT) } - end - - def initialize(exception) - @path = exception.path - end - - def corrections - threshold = path.size * 2 - dictionary = self.class.requireables.reject {|str| str.size >= threshold } - spell_checker = path.include?("/") ? TreeSpellChecker : SpellChecker - - spell_checker.new(dictionary: dictionary).correct(path) - end - end -end |