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
Add new Style/RedundantHeredocDelimiterQuotes
cop
#11528
Add new Style/RedundantHeredocDelimiterQuotes
cop
#11528
Conversation
# no string interpolation style text | ||
# EOS | ||
# | ||
# # good |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably you should also add a good example for 'EOS', so it's a bit clearer when it should be used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Certainly! I added some examples for that.
Follow up rubocop#11522 (comment). This cop checks for redundant heredoc delimiter quotes. ```ruby # bad do_something(<<~'EOS') no string interpolation style text EOS # good do_something(<<~EOS) no string interpolation style text EOS ```
0e97dc5
to
f3d4931
Compare
Pretty useful cop! Thanks! |
Follow up rubocop/rubocop#11528. This commit suppresses the following new `Style/RedundantHeredocDelimiterQuotes` cop's offenses: ```console % bundle exec rake (snip) Offenses: spec/rubocop/cop/rails/helper_instance_variable_spec.rb:31:24: C: [Correctable] Style/RedundantHeredocDelimiterQuotes: Remove the redundant heredoc delimiter quotes, use <<~RUBY instead. expect_no_offenses(<<~'RUBY') ^^^^^^^^^ spec/rubocop/cop/rails/helper_instance_variable_spec.rb:39:24: C: [Correctable] Style/RedundantHeredocDelimiterQuotes: Remove the redundant heredoc delimiter quotes, use <<~RUBY instead. expect_no_offenses(<<~'RUBY') ^^^^^^^^^ spec/rubocop/cop/rails/helper_instance_variable_spec.rb:50:24: C: [Correctable] Style/RedundantHeredocDelimiterQuotes: Remove the redundant heredoc delimiter quotes, use <<~RUBY instead. expect_no_offenses(<<~'RUBY') ^^^^^^^^^ spec/rubocop/cop/rails/helper_instance_variable_spec.rb:61:20: C: [Correctable] Style/RedundantHeredocDelimiterQuotes: Remove the redundant heredoc delimiter quotes, use <<~RUBY instead. expect_offense(<<~'RUBY') ^^^^^^^^^ spec/rubocop/cop/rails/match_route_spec.rb:110:24: C: [Correctable] Style/RedundantHeredocDelimiterQuotes: Remove the redundant heredoc delimiter quotes, use <<~RUBY instead. expect_no_offenses(<<~'RUBY') ^^^^^^^^^ spec/rubocop/cop/rails/reflection_class_name_spec.rb:57:24: C: [Correctable] Style/RedundantHeredocDelimiterQuotes: Remove the redundant heredoc delimiter quotes, use <<~RUBY instead. expect_no_offenses(<<~'RUBY') ^^^^^^^^^ spec/rubocop/cop/rails/reflection_class_name_spec.rb:63:24: C: [Correctable] Style/RedundantHeredocDelimiterQuotes: Remove the redundant heredoc delimiter quotes, use <<~RUBY instead. expect_no_offenses(<<~'RUBY') ^^^^^^^^^ spec/rubocop/cop/rails/root_pathname_methods_spec.rb:123:22: C: [Correctable] Style/RedundantHeredocDelimiterQuotes: Remove the redundant heredoc delimiter quotes, use <<~RUBY instead. expect_offense(<<~'RUBY') ^^^^^^^^^ 279 files inspected, 8 offenses detected, 8 offenses autocorrectable ```
Follow up rubocop/rubocop#11528. This commit suppresses the following new `Style/RedundantHeredocDelimiterQuotes` cop's offenses: ```console % bundle exec rake (snip) Offenses: test/rubocop/cop/minitest/assert_with_expected_argument_test.rb:82:24: C: [Correctable] Style/RedundantHeredocDelimiterQuotes: Remove the redundant heredoc delimiter quotes, use <<~RUBY instead. assert_no_offenses(<<~'RUBY') ^^^^^^^^^ 121 files inspected, 1 offense detected, 1 offense autocorrectable RuboCop failed! ```
extend AutoCorrector | ||
|
||
MSG = 'Remove the redundant heredoc delimiter quotes, use `%<replacement>s` instead.' | ||
STRING_INTERPOLATION_OR_ESCAPED_CHARACTER_PATTERN = /#(\{|@|\$)|\\/.freeze |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@koic thanks! Since we picked up this release through Dependabot, I check the docs to find more info but I didn't see the rule there. I realize now that 1.45 isn't published on docs.rubocop.org where this was included. Only 1.44 is available. |
@javierjulio The 1.45 doc is published. Thank you! |
My bad. As the process is manual and I constantly switch between computers from time to time I forget to do it when I release from the "wrong" computer (the one where I haven't setup Antora locally yet). |
On the bright side - this finally motivated me to setup Node.js and Antora on my laptop as well. 😄 |
Follow up #11522 (comment).
This cop checks for redundant heredoc delimiter quotes.
Before submitting the PR make sure the following are checked:
[Fix #issue-number]
(if the related issue exists).master
(if not - rebase it).bundle exec rake default
. It executes all tests and runs RuboCop on its own code.{change_type}_{change_description}.md
if the new code introduces user-observable changes. See changelog entry format for details.