-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Use did_you_mean instead of jaro_winkler #7931
Conversation
rubocop-rails uses So although this PR only changes internal API, it is actually a breaking change. Hmm, any suggestions on how to fix that? |
The API is possibly used by third party cop that rubocop-hq org does not managed. |
This isn't the typical kind of breaking change that impacts the end user. It is a breaking change that potentially impacts other libraries that add onto RuboCop. It will be important to note that this is a breaking change for them. This could impact an end user if a RuboCop extension allows for too high of a version of RuboCop to be included. I'm not sure of the best way to handle this. |
One possible way of handling it would be to leave the current implementation intact, with a deprecation warning. Then add this new implementation of -def find_similar_name(target_name, scope)
+def find_similar_name(target_name = nil, names = nil, name: nil, candidates: nil)
+ warn "deprecated" if target_name && names && name.nil? && candidates.nil? …something along those lines. |
@bquorning I don't this we need to overdo this. As @koic said the impact of the change is going to be small (if any). I'd rather us removed this before the 1.0 release. Just update the changelog and we're good to go. |
By explicitly passing the collection of "possible names" when calling `NameSimilarity.find_similar_name`, the calling class doesn't need to implement a `.collect_variable_like_names` method.
Change `NameSimilarity#find_similar_name` into `NameSimilarity.find_similar_name`, since it no longer needs to call back to a method in the same context.
Simplify `NameSimilarity#find_similar_name` by using the built-in `did_you_mean` gem instead of `StringUtil.similarity`.
Removing `StringUtil` as well, by adding a `NameSimilarity.find_similar_names` method.
Done |
Thanks! |
FYI, the edge RuboCop Rails has been independence from |
The
did_you_mean
gem has been a part of Ruby since v2.3, so if we can use that instead of thejaro_winkler
gem our users will have 1 less dependency.Before submitting the PR make sure the following are checked:
[Fix #issue-number]
(if the related issue exists).master
(if not - rebase it).bundle exec rake default
. It executes all tests and RuboCop for itself, and generates the documentation.