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

Rails/ContentTag incorrectly autocorrects interpolated string inside config/puma.rb #636

Closed
nevans opened this issue Feb 4, 2022 · 0 comments · Fixed by #637
Closed
Labels
bug Something isn't working

Comments

@nevans
Copy link

nevans commented Feb 4, 2022

Expected behavior

  1. config/puma.rb is never a rails view or helper and should be ignored by Rails/ContentTag
  2. Auto correct should not convert tag "dynamic-#{interpolated}-string", even if it were in a rails view

For context: https://puma.io/puma/Puma/DSL.html#tag-instance_method

Actual behavior

  1. config/puma.rb is reported and autocorrected by Rails/ContentTag
  2. Auto correct converted tag "dynamic-#{interpolated}-string" into tag.dynamic-#{interpolated}-string

Steps to reproduce the problem

  1. Inside a rails project, add the following to config/puma.rb:
env_cfg = ENV.fetch("RAILS_ENV") { "development" }
tag "app-name-#{env_cfg}"
  1. Run rubocop -a --only Rails/ContentTag
  2. ????
  3. Profit!!!!

RuboCop version

$ [bundle exec] rubocop -V
1.25.1 (using Parser 3.1.0.0, rubocop-ast 1.15.1, running on ruby 2.6.8 x86_64-linux)
  - rubocop-performance 1.13.2
  - rubocop-rails 2.13.2
@koic koic added the bug Something isn't working label Feb 4, 2022
koic added a commit to koic/rubocop-rails that referenced this issue Feb 4, 2022
Fixes rubocop#636.

This PR fixes a false positive for `Rails/ContentTag`
when using `tag` method in config/puma.rb.
@koic koic closed this as completed in #637 Feb 19, 2022
koic added a commit that referenced this issue Feb 19, 2022
…ent_tag

[Fix #636] Fix a false positive for `Rails/ContentTag`
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