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

Incorrect autocorrect for Rails/ContentTag cop #261

Closed
tsugimoto opened this issue Jun 15, 2020 · 0 comments · Fixed by #270
Closed

Incorrect autocorrect for Rails/ContentTag cop #261

tsugimoto opened this issue Jun 15, 2020 · 0 comments · Fixed by #270
Labels
bug Something isn't working

Comments

@tsugimoto
Copy link

  def foo(options = {})
    content_tag :div, { class: "strong" }.merge(options) do
      "body"
    end
  end

is auto-corrected to invalid Ruby code by

$ rubocop --auto-correct --only Rails/ContentTag

Expected behavior

  def foo(options = {})
    tag.div({ class: "strong" }.merge(options)) do
      "body"
    end
  end

We must add the parens if content_tag is called with block and the option argument starts with hash literal.

Actual behavior

  def foo(options = {})
    tag.div { class: "strong" }.merge(options) do
      "body"
    end
  end

RuboCop version

$ bundle exec rubocop -V
0.85.1 (using Parser 2.7.1.3, rubocop-ast 0.0.3, running on ruby 2.6.3 x86_64-darwin18)
$ bundle exec gem list rubocop-rails

*** LOCAL GEMS ***

rubocop-rails (2.6.0)
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
2 participants