-
-
Notifications
You must be signed in to change notification settings - Fork 270
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
Rails/FreezeTime cop erroring out #762
Labels
bug
Something isn't working
Comments
9 tasks
koic
added a commit
to koic/rubocop-rails
that referenced
this issue
Sep 9, 2022
Fixes rubocop#762. This PR fixes an error for `Rails/FreezeTime` when using `travel_to` with an argument of `current` method without receiver.
lazy bug report, following #714 An error occurred while Rails/FreezeTime cop was inspecting spec/policies/newsletter_policy_spec.rb:58:14.
undefined method `send_type?' for nil:NilClass
.bundle/vendor/ruby/3.0.0/gems/rubocop-rails-2.16.0/lib/rubocop/cop/rails/freeze_time.rb:57:in `current_time?'
.bundle/vendor/ruby/3.0.0/gems/rubocop-rails-2.16.0/lib/rubocop/cop/rails/freeze_time.rb:47:in `on_send'
.bundle/vendor/ruby/3.0.0/gems/rubocop-1.35.0/lib/rubocop/cop/commissioner.rb:136:in `public_send'
.bundle/vendor/ruby/3.0.0/gems/rubocop-1.35.0/lib/rubocop/cop/commissioner.rb:136:in `block (2 levels) in trigger_restricted_cops'
.bundle/vendor/ruby/3.0.0/gems/rubocop-1.35.0/lib/rubocop/cop/commissioner.rb:160:in `with_cop_error_handling'
.bundle/vendor/ruby/3.0.0/gems/rubocop-1.35.0/lib/rubocop/cop/commissioner.rb:135:in `block in trigger_restricted_cops'
.bundle/vendor/ruby/3.0.0/gems/rubocop-1.35.0/lib/rubocop/cop/commissioner.rb:134:in `each'
.bundle/vendor/ruby/3.0.0/gems/rubocop-1.35.0/lib/rubocop/cop/commissioner.rb:134:in `trigger_restricted_cops'
.bundle/vendor/ruby/3.0.0/gems/rubocop-1.35.0/lib/rubocop/cop/commissioner.rb:70:in `on_send'
.bundle/vendor/ruby/3.0.0/gems/rubocop-ast-1.21.0/lib/rubocop/ast/traversal.rb:153:in `on_block'
.bundle/vendor/ruby/3.0.0/gems/rubocop-1.35.0/lib/rubocop/cop/commissioner.rb:71:in `on_block'
.bundle/vendor/ruby/3.0.0/gems/rubocop-ast-1.21.0/lib/rubocop/ast/traversal.rb:157:in `on_block'
.bundle/vendor/ruby/3.0.0/gems/rubocop-1.35.0/lib/rubocop/cop/commissioner.rb:71:in `on_block'
.bundle/vendor/ruby/3.0.0/gems/rubocop-ast-1.21.0/lib/rubocop/ast/traversal.rb:136:in `block in on_dstr'
.bundle/vendor/ruby/3.0.0/gems/rubocop-ast-1.21.0/lib/rubocop/ast/traversal.rb:136:in `each'
.bundle/vendor/ruby/3.0.0/gems/rubocop-ast-1.21.0/lib/rubocop/ast/traversal.rb:136:in `on_dstr'
.bundle/vendor/ruby/3.0.0/gems/rubocop-1.35.0/lib/rubocop/cop/commissioner.rb:71:in `on_begin'
.bundle/vendor/ruby/3.0.0/gems/rubocop-ast-1.21.0/lib/rubocop/ast/traversal.rb:157:in `on_block'
.bundle/vendor/ruby/3.0.0/gems/rubocop-1.35.0/lib/rubocop/cop/commissioner.rb:71:in `on_block'
.bundle/vendor/ruby/3.0.0/gems/rubocop-ast-1.21.0/lib/rubocop/ast/traversal.rb:136:in `block in on_dstr'
.bundle/vendor/ruby/3.0.0/gems/rubocop-ast-1.21.0/lib/rubocop/ast/traversal.rb:136:in `each'
.bundle/vendor/ruby/3.0.0/gems/rubocop-ast-1.21.0/lib/rubocop/ast/traversal.rb:136:in `on_dstr'
.bundle/vendor/ruby/3.0.0/gems/rubocop-1.35.0/lib/rubocop/cop/commissioner.rb:71:in `on_begin'
.bundle/vendor/ruby/3.0.0/gems/rubocop-ast-1.21.0/lib/rubocop/ast/traversal.rb:157:in `on_block'
.bundle/vendor/ruby/3.0.0/gems/rubocop-1.35.0/lib/rubocop/cop/commissioner.rb:71:in `on_block'
.bundle/vendor/ruby/3.0.0/gems/rubocop-ast-1.21.0/lib/rubocop/ast/traversal.rb:136:in `block in on_dstr'
.bundle/vendor/ruby/3.0.0/gems/rubocop-ast-1.21.0/lib/rubocop/ast/traversal.rb:136:in `each'
.bundle/vendor/ruby/3.0.0/gems/rubocop-ast-1.21.0/lib/rubocop/ast/traversal.rb:136:in `on_dstr'
.bundle/vendor/ruby/3.0.0/gems/rubocop-1.35.0/lib/rubocop/cop/commissioner.rb:71:in `on_begin'
.bundle/vendor/ruby/3.0.0/gems/rubocop-ast-1.21.0/lib/rubocop/ast/traversal.rb:157:in `on_block'
.bundle/vendor/ruby/3.0.0/gems/rubocop-1.35.0/lib/rubocop/cop/commissioner.rb:71:in `on_block'
.bundle/vendor/ruby/3.0.0/gems/rubocop-ast-1.21.0/lib/rubocop/ast/traversal.rb:136:in `block in on_dstr'
.bundle/vendor/ruby/3.0.0/gems/rubocop-ast-1.21.0/lib/rubocop/ast/traversal.rb:136:in `each'
.bundle/vendor/ruby/3.0.0/gems/rubocop-ast-1.21.0/lib/rubocop/ast/traversal.rb:136:in `on_dstr'
.bundle/vendor/ruby/3.0.0/gems/rubocop-1.35.0/lib/rubocop/cop/commissioner.rb:71:in `on_begin'
.bundle/vendor/ruby/3.0.0/gems/rubocop-ast-1.21.0/lib/rubocop/ast/traversal.rb:157:in `on_block'
.bundle/vendor/ruby/3.0.0/gems/rubocop-1.35.0/lib/rubocop/cop/commissioner.rb:71:in `on_block'
.bundle/vendor/ruby/3.0.0/gems/rubocop-ast-1.21.0/lib/rubocop/ast/traversal.rb:136:in `block in on_dstr'
.bundle/vendor/ruby/3.0.0/gems/rubocop-ast-1.21.0/lib/rubocop/ast/traversal.rb:136:in `each'
.bundle/vendor/ruby/3.0.0/gems/rubocop-ast-1.21.0/lib/rubocop/ast/traversal.rb:136:in `on_dstr'
.bundle/vendor/ruby/3.0.0/gems/rubocop-1.35.0/lib/rubocop/cop/commissioner.rb:71:in `on_begin'
.bundle/vendor/ruby/3.0.0/gems/rubocop-ast-1.21.0/lib/rubocop/ast/traversal.rb:157:in `on_block'
.bundle/vendor/ruby/3.0.0/gems/rubocop-1.35.0/lib/rubocop/cop/commissioner.rb:71:in `on_block'
.bundle/vendor/ruby/3.0.0/gems/rubocop-ast-1.21.0/lib/rubocop/ast/traversal.rb:136:in `block in on_dstr'
.bundle/vendor/ruby/3.0.0/gems/rubocop-ast-1.21.0/lib/rubocop/ast/traversal.rb:136:in `each'
.bundle/vendor/ruby/3.0.0/gems/rubocop-ast-1.21.0/lib/rubocop/ast/traversal.rb:136:in `on_dstr'
.bundle/vendor/ruby/3.0.0/gems/rubocop-1.35.0/lib/rubocop/cop/commissioner.rb:71:in `on_begin'
.bundle/vendor/ruby/3.0.0/gems/rubocop-ast-1.21.0/lib/rubocop/ast/traversal.rb:157:in `on_block'
.bundle/vendor/ruby/3.0.0/gems/rubocop-1.35.0/lib/rubocop/cop/commissioner.rb:71:in `on_block'
.bundle/vendor/ruby/3.0.0/gems/rubocop-ast-1.21.0/lib/rubocop/ast/traversal.rb:136:in `block in on_dstr'
.bundle/vendor/ruby/3.0.0/gems/rubocop-ast-1.21.0/lib/rubocop/ast/traversal.rb:136:in `each'
.bundle/vendor/ruby/3.0.0/gems/rubocop-ast-1.21.0/lib/rubocop/ast/traversal.rb:136:in `on_dstr'
.bundle/vendor/ruby/3.0.0/gems/rubocop-1.35.0/lib/rubocop/cop/commissioner.rb:71:in `on_begin'
.bundle/vendor/ruby/3.0.0/gems/rubocop-ast-1.21.0/lib/rubocop/ast/traversal.rb:20:in `walk'
.bundle/vendor/ruby/3.0.0/gems/rubocop-1.35.0/lib/rubocop/cop/commissioner.rb:86:in `investigate'
.bundle/vendor/ruby/3.0.0/gems/rubocop-1.35.0/lib/rubocop/cop/team.rb:155:in `investigate_partial'
.bundle/vendor/ruby/3.0.0/gems/rubocop-1.35.0/lib/rubocop/cop/team.rb:77:in `investigate'
.bundle/vendor/ruby/3.0.0/gems/rubocop-1.35.0/lib/rubocop/runner.rb:311:in `inspect_file'
.bundle/vendor/ruby/3.0.0/gems/rubocop-1.35.0/lib/rubocop/runner.rb:255:in `block in do_inspection_loop'
.bundle/vendor/ruby/3.0.0/gems/rubocop-1.35.0/lib/rubocop/runner.rb:289:in `block in iterate_until_no_changes'
.bundle/vendor/ruby/3.0.0/gems/rubocop-1.35.0/lib/rubocop/runner.rb:282:in `loop'
.bundle/vendor/ruby/3.0.0/gems/rubocop-1.35.0/lib/rubocop/runner.rb:282:in `iterate_until_no_changes'
.bundle/vendor/ruby/3.0.0/gems/rubocop-1.35.0/lib/rubocop/runner.rb:251:in `do_inspection_loop'
.bundle/vendor/ruby/3.0.0/gems/rubocop-1.35.0/lib/rubocop/runner.rb:134:in `block in file_offenses'
.bundle/vendor/ruby/3.0.0/gems/rubocop-1.35.0/lib/rubocop/runner.rb:159:in `file_offense_cache'
.bundle/vendor/ruby/3.0.0/gems/rubocop-1.35.0/lib/rubocop/runner.rb:133:in `file_offenses'
.bundle/vendor/ruby/3.0.0/gems/rubocop-1.35.0/lib/rubocop/runner.rb:124:in `process_file'
.bundle/vendor/ruby/3.0.0/gems/rubocop-1.35.0/lib/rubocop/runner.rb:105:in `block in each_inspected_file'
.bundle/vendor/ruby/3.0.0/gems/rubocop-1.35.0/lib/rubocop/runner.rb:104:in `each'
.bundle/vendor/ruby/3.0.0/gems/rubocop-1.35.0/lib/rubocop/runner.rb:104:in `reduce'
.bundle/vendor/ruby/3.0.0/gems/rubocop-1.35.0/lib/rubocop/runner.rb:104:in `each_inspected_file'
.bundle/vendor/ruby/3.0.0/gems/rubocop-1.35.0/lib/rubocop/runner.rb:90:in `inspect_files'
.bundle/vendor/ruby/3.0.0/gems/rubocop-1.35.0/lib/rubocop/runner.rb:47:in `run'
.bundle/vendor/ruby/3.0.0/gems/rubocop-1.35.0/lib/rubocop/cli/command/execute_runner.rb:26:in `block in execute_runner'
.bundle/vendor/ruby/3.0.0/gems/rubocop-1.35.0/lib/rubocop/cli/command/execute_runner.rb:52:in `with_redirect'
.bundle/vendor/ruby/3.0.0/gems/rubocop-1.35.0/lib/rubocop/cli/command/execute_runner.rb:25:in `execute_runner'
.bundle/vendor/ruby/3.0.0/gems/rubocop-1.35.0/lib/rubocop/cli/command/execute_runner.rb:17:in `run'
.bundle/vendor/ruby/3.0.0/gems/rubocop-1.35.0/lib/rubocop/cli/command.rb:11:in `run'
.bundle/vendor/ruby/3.0.0/gems/rubocop-1.35.0/lib/rubocop/cli/environment.rb:18:in `run'
.bundle/vendor/ruby/3.0.0/gems/rubocop-1.35.0/lib/rubocop/cli.rb:72:in `run_command'
.bundle/vendor/ruby/3.0.0/gems/rubocop-1.35.0/lib/rubocop/cli.rb:79:in `execute_runners'
.bundle/vendor/ruby/3.0.0/gems/rubocop-1.35.0/lib/rubocop/cli.rb:48:in `run'
.bundle/vendor/ruby/3.0.0/gems/rubocop-1.35.0/exe/rubocop:19:in `block in <top (required)>'
ruby-3.0.3/lib/ruby/3.0.0/benchmark.rb:308:in `realtime'
.bundle/vendor/ruby/3.0.0/gems/rubocop-1.35.0/exe/rubocop:19:in `<top (required)>'
.bundle/vendor/ruby/3.0.0/bin/rubocop:25:in `load'
.bundle/vendor/ruby/3.0.0/bin/rubocop:25:in `<main>'
.rvm/rubies/ruby-3.0.3/bin/ruby_executable_hooks:22:in `eval'
.rvm/rubies/ruby-3.0.3/bin/ruby_executable_hooks:22:in `<main>'
An error occurred while Rails/FreezeTime cop was inspecting spec/policies/newsletter_policy_spec.rb:70:12.
Errors are usually caused by RuboCop bugs.
Please, report your problems to RuboCop's issue tracker.
https://github.com/rubocop/rubocop/issues
Mention the following information in the issue report:
1.35.0 (using Parser 3.1.2.1, rubocop-ast 1.21.0, running on ruby 3.0.3 x86_64-darwin21)
Finished in 0.8817499997094274 seconds
code there is let!(:now) do
Time.utc(2021, 4, 16, 10, 5)
end
it "does not permit" do
travel_to now do
expect(policy).not_to permit(user, record)
end
end |
koic
added a commit
that referenced
this issue
Sep 10, 2022
[Fix #762] Fix an error for `Rails/FreezeTime`
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Rails/FreezeTime
cop errors out when processing a spec file as below:Running with
-d
flag, it seems to break with the error:The problem seems to be with how the
current
argument is passed totravel_to
- if changed to some time passed directly like:travel_to(Time.zone.local(2021, 3, 4, 9)) do
No errors occur
RuboCop version
The text was updated successfully, but these errors were encountered: