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

FreezeTime cop conflicts with local variable travel_to #809

Closed
mikdiet opened this issue Oct 12, 2022 · 0 comments · Fixed by #810
Closed

FreezeTime cop conflicts with local variable travel_to #809

mikdiet opened this issue Oct 12, 2022 · 0 comments · Fixed by #810
Labels
bug Something isn't working

Comments

@mikdiet
Copy link

mikdiet commented Oct 12, 2022

Expected behavior

I have local rspec definition, which named the same as FreezeTime subject method named: travel_to.
I use it with Timecop gem.

let(:travel_to) { 47.hours.ago }

around { |example| Timecop.travel(travel_to) { example.run } }

I expect this won't violate FreezeTime cop

Actual behavior

I'm getting

An error occurred while Rails/FreezeTime cop was inspecting /path/to/test.
undefined method `children' for nil:NilClass

          child_node, method_name, time_argument = *node.first_argument.children
                                                                       ^^^^^^^^^
/Users/mikdiet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/rubocop-rails-2.16.1/lib/rubocop/cop/rails/freeze_time.rb:46:in `on_send'

Steps to reproduce the problem

Just run rubocop on the code snippet provided.

If I change name, error is gone.

RuboCop version

$ [bundle exec] rubocop -V
1.36.0 (using Parser 3.1.2.1, rubocop-ast 1.21.0, running on ruby 3.1.2) [x86_64-darwin21]
  - rubocop-performance 1.15.0
  - rubocop-rails 2.16.1
  - rubocop-rspec 2.13.2
  - rubocop-sorbet 0.6.11
@koic koic added the bug Something isn't working label Oct 12, 2022
koic added a commit to koic/rubocop-rails that referenced this issue Oct 12, 2022
Fixes rubocop#809.

This PR fixes an error for `Rails/FreezeTime`
when using `travel_to` without argument.
koic added a commit to koic/rubocop-rails that referenced this issue Oct 13, 2022
Fixes rubocop#809.

This PR fixes an error for `Rails/FreezeTime`
when using `travel_to` without argument.
@koic koic closed this as completed in #810 Oct 15, 2022
koic added a commit that referenced this issue Oct 15, 2022
[Fix #809] Fix an error for `Rails/FreezeTime`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants