You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using an application with Ruby 3.0 (3.0.1 in my case), the autocorrect output of the Rails/ContentTag generates tags which either produce an exception or ignore the passed options. I've been using the tags in the controller via view_context.
Using rubocop --auto-correct --only Rails/ContentTag on the following code samples produces invalid ruby code:
The code fails with an ArgumentError: wrong number of arguments (given 4, expected 1..2). Please note, that the last argument false to disable escaping of the content is a keyword argument in the tag method, i.e. this needs to be converted into a keyword argument.
When using an application with Ruby 3.0 (
3.0.1
in my case), the autocorrect output of theRails/ContentTag
generates tags which either produce an exception or ignore the passed options. I've been using the tags in the controller viaview_context
.Using
rubocop --auto-correct --only Rails/ContentTag
on the following code samples produces invalid ruby code:Using
content_tag
with escaping:Using
content_tag
, disabling escaping by passing infalse
as last param:Using the test added by PR Fix auto correction for
Rails/ContentTag
whencontent_tag
is called with options hash and block #270:Expected behavior
The cop should generate Ruby code which is valid in Ruby 3.0+, i.e. it should produce the following:
Either one of the two variations:
Either one of the two variations:
Either one of the two variations:
Actual behavior
The cop generates the following code:
The code fails with an
ArgumentError: wrong number of arguments (given 3, expected 1..2)
The code fails with an
ArgumentError: wrong number of arguments (given 4, expected 1..2)
. Please note, that the last argumentfalse
to disable escaping of the content is a keyword argument in thetag
method, i.e. this needs to be converted into a keyword argument.This variant does not fail, but the generated HTML is incorrect. The generated code is:
which generates the following HTML:
i.e. the
class
option is ignored.Steps to reproduce the problem
Use any of the above mentioned versions in a Rails 6.1.4 App using Ruby 3.0.1, and run
rubocop --auto-correct --only Rails/ContentTag
.Please let me know if you need more informations or when I should create a Demo Repo to reproduce the issue.
RuboCop version
The text was updated successfully, but these errors were encountered: