Skip to content
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

Call uniq on spell checker corrections #84

Closed
wants to merge 1 commit into from

Conversation

laynemcnish
Copy link

I have noticed duplications in suggestions when ActiveSupport's TimeWithZone objects using the Comparable mixin are called with a misspelled method.

=> Time.zone.now.between(1.hour.ago, 1.hour.from_now)
NoMethodError: undefined method `between' for Fri, 24 Mar 2017 15:30:47 UTC +00:00:Time
Did you mean?  between?
Did you mean?  between?

I am having trouble testing the fix locally and would love advice on how to test that my change has made a difference.

@yuki24
Copy link
Member

yuki24 commented Mar 24, 2017

I have seen the same issue and it is definitely an issue that should be fixed. However, I'm not convinced that this is a bug in the spell checker, as the entire message (Did You mean? X) gets duplicated. This may possibly be because of the DYM gem being loaded twice, that would result in monkey-patching NameError twice.

Do you have gem 'did_you_mean' in the Gemfile or explicitly require 'did_you_mean' somewhere in your app?

@yuki24 yuki24 added the Bug label Mar 24, 2017
@laynemcnish
Copy link
Author

@yuki24 I don't have the gem in the gemfile or explicitly required. I made an empty rails 5 project here: https://github.com/laynemcnish/test_project When using the rails console, I have the same issue occur when using: Time.zone.now.between(1.hour.ago, 1.hour.from_now).

I haven't been able to get it to happen with other methods so I'm wondering if it has something to do with how Rails using the TimeWithZone & Comparable mixin.

@yuki24
Copy link
Member

yuki24 commented Mar 24, 2017

Thanks for taking your time on making a test app! I'll look into it.

@yuki24 yuki24 closed this in 98e2c4b Mar 25, 2017
yuki24 added a commit that referenced this pull request Mar 25, 2017
Currently, the `NameError#to_s` method attempts to append a suggestion
each time a NoMethodError is raised, which results in showing
duplicate suggestions. This commit changes the `#to_s` method to look
at the 'cause' exception to figure out whether it should append a
suggestion or not.

closes #84.
yuki24 added a commit that referenced this pull request Mar 25, 2017
Currently, the `NameError#to_s` method attempts to append a suggestion
each time a NoMethodError is raised, which results in showing
duplicate suggestions. This commit changes the `#to_s` method to look
at the 'cause' exception to figure out whether it should append a
suggestion or not.

closes #84.
@yuki24
Copy link
Member

yuki24 commented Mar 25, 2017

The root cause was the NameError#to_s method that used to always attempt to append a suggestion even after a NoMethodError is re-raised (or raised multiple times). I have just pushed a fix and cut two new releases 1.1.3 and 1.0.3. Thanks for reporting the issue!

@laynemcnish
Copy link
Author

Thanks for the explanation and the fix! I really appreciate it!

@laynemcnish laynemcnish deleted the uniquify-corrections branch March 25, 2017 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

None yet

2 participants