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

VariableName cop raises "undefined method `loc'" #957

Closed
roberts1000 opened this issue Jul 7, 2020 · 3 comments · Fixed by #958
Closed

VariableName cop raises "undefined method `loc'" #957

roberts1000 opened this issue Jul 7, 2020 · 3 comments · Fixed by #958

Comments

@roberts1000
Copy link

The VariableName cop is raising this error:

An error occurred while RSpec/VariableName cop was inspecting /home/dev/Projects/my_project/spec/libs/foo/foo_spec.rb:68:4.
undefined method `loc' for #<Parser::Source::Range:0x0000000003abdbe8>
/home/dev/.rvm/gems/ruby-2.7.1/gems/rubocop-0.87.1/lib/rubocop/cop/cop.rb:41:in `find_location'
/home/dev/.rvm/gems/ruby-2.7.1/gems/rubocop-0.87.1/lib/rubocop/cop/cop.rb:29:in `add_offense'
/home/dev/.rvm/gems/ruby-2.7.1/gems/rubocop-0.87.1/lib/rubocop/cop/mixin/configurable_formatting.rb:13:in `check_name'

This code triggers the error:

let(:one_OC) { [] }

This works:

let(:one_oc) { [] }
$ rubocop -V
0.87.1 (using Parser 2.7.1.4, rubocop-ast 0.1.0, running on ruby 2.7.1 x86_64-linux)
$ gem list rubocop-performance

*** LOCAL GEMS ***

rubocop-performance (1.7.0)
@reidab
Copy link

reidab commented Jul 7, 2020

Same issue here; this is also triggered by:

let(:'canonical-record-id') { 123 }

@bquorning
Copy link
Collaborator

I haven’t attempted to reproduce the issue, but it looks like it may be caused by some Changes to RuboCop’s internal API in version 0.87.0. We’re looking to fix this incompatibility in #955

@jtannas
Copy link
Contributor

jtannas commented Jul 9, 2020

+1; being triggered by

let(:'id[]') { ['foo', 'bar', 'baz'] }

P.S. The weird variable name is explained in Issue #941. I'll be working on a PR for the feature once this issue is resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants