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

VariableForce exception thrown (Partial interaction with SaveBang) #4264

Closed
jfelchner opened this issue Apr 11, 2017 · 0 comments
Closed

VariableForce exception thrown (Partial interaction with SaveBang) #4264

jfelchner opened this issue Apr 11, 2017 · 0 comments
Labels

Comments

@jfelchner
Copy link
Contributor

jfelchner commented Apr 11, 2017

Running rubocop on my codebase throws an error in the VariableForce cop.

An error occurred while VariableForce cop was inspecting /path/to/my/file.rb.
undefined method `method?' for "s(:pair,\n  s(:sym, :json),\n  s(:lvar, :foo))":RuboCop::AST::PairNode
Did you mean?  method
               methods

Steps to Reproduce

The following is the minimal code that caused the issue:

class MyClass
  def my_method
    foo = Foo.create()

    render json: foo
  end
end

This definitely is partially caused by an interaction with the SaveBang cop. If I disable that cop, I get no error with the above code. Additionally if I remove the json: part of the render call I get no error. Or if I leave SaveBang enabled but change create to create! I get no error.

RuboCop version

0.48.1 (using Parser 2.4.0.0, running on ruby 2.4.0 x86_64-darwin16)
@bbatsov bbatsov added the bug label Apr 12, 2017
Drenmi added a commit to Drenmi/rubocop that referenced this issue Apr 25, 2017
…g assigned variable in a hash

This cop would raise an exception when the assigned variable was used as
a value in a hash, e.g.:

```
foo = Foo.create

render json: foo
```

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

No branches or pull requests

2 participants