We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Auto-correction of Rails/LinkToBlank produces syntactically incorrect code when link_to is used with parentheses.
Rails/LinkToBlank
link_to
, rel: 'noopener' is expected to be inserted before the closing parenthesis.
, rel: 'noopener'
link_to('name', 'http://example.com', target: '_blank', rel: 'noopener')
, rel: 'noopener' is inserted after the closing parenthesis.
link_to('name', 'http://example.com', target: '_blank'), rel: 'noopener'
Example file(test.rb)
test.rb
link_to('name', 'http://example.com', target: '_blank')
$ rubocop -R -a test.rb Inspecting 1 file E Offenses: test.rb:1:39: C: [Corrected] Rails/LinkToBlank: Specify a :rel option containing noopener. link_to('name', 'http://example.com', target: '_blank') ^^^^^^^^^^^^^^^^ test.rb:1:56: E: Lint/Syntax: unexpected token tCOMMA (Using Ruby 2.2 parser; configure using TargetRubyVersion parameter, under AllCops) link_to('name', 'http://example.com', target: '_blank'), rel: 'noopener' ^ 1 file inspected, 2 offenses detected, 1 offense corrected
$ rubocop -V 0.63.1 (using Parser 2.6.0.0, running on ruby 2.4.5 x86_64-linux)
The text was updated successfully, but these errors were encountered:
Thanks for the feedback. I opened a PR #6743.
Sorry, something went wrong.
[Fix rubocop#6737] Fix an incorrect auto-correct for Rails/LinkToBlank
810c92f
Fixes rubocop#6737. This PR fixes an incorrect auto-correct for `Rails/LinkToBlank` when `link_to` method arguments are enclosed in parentheses.
Merge pull request #6743 from koic/fix_incorrect_autocorrect_for_rail…
24e2c79
…s_link_to_blank [Fix #6737] Fix an incorrect auto-correct for `Rails/LinkToBlank`
Successfully merging a pull request may close this issue.
Auto-correction of
Rails/LinkToBlank
produces syntactically incorrect code whenlink_to
is used with parentheses.Expected behavior
, rel: 'noopener'
is expected to be inserted before the closing parenthesis.Actual behavior
, rel: 'noopener'
is inserted after the closing parenthesis.Steps to reproduce the problem
Example file(
test.rb
)RuboCop version
The text was updated successfully, but these errors were encountered: