Skip to content

Commit

Permalink
Use squiggly heredoc
Browse files Browse the repository at this point in the history
  • Loading branch information
koic committed Aug 19, 2023
1 parent 23dc4de commit dd29994
Show file tree
Hide file tree
Showing 31 changed files with 394 additions and 413 deletions.
4 changes: 2 additions & 2 deletions lib/rubocop/cop/lint/non_atomic_file_operation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ class NonAtomicFileOperation < Base
REMOVE_FORCE_METHODS).freeze

# @!method send_exist_node(node)
def_node_search :send_exist_node, <<-PATTERN
def_node_search :send_exist_node, <<~PATTERN
$(send (const nil? {:FileTest :File :Dir :Shell}) {:exist? :exists?} ...)
PATTERN

# @!method receiver_and_method_name(node)
def_node_matcher :receiver_and_method_name, <<-PATTERN
def_node_matcher :receiver_and_method_name, <<~PATTERN
(send (const nil? $_) $_ ...)
PATTERN

Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/style/open_struct_use.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class OpenStructUse < Base
MSG = 'Avoid using `OpenStruct`; use `Struct`, `Hash`, a class or test doubles instead.'

# @!method uses_open_struct?(node)
def_node_matcher :uses_open_struct?, <<-PATTERN
def_node_matcher :uses_open_struct?, <<~PATTERN
(const {nil? (cbase)} :OpenStruct)
PATTERN

Expand Down
2 changes: 1 addition & 1 deletion rubocop.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY
s.required_ruby_version = '>= 2.7.0'
s.authors = ['Bozhidar Batsov', 'Jonas Arvidsson', 'Yuji Nakayama']
s.description = <<-DESCRIPTION
s.description = <<~DESCRIPTION
RuboCop is a Ruby code style checking and code formatting tool.
It aims to enforce the community-driven Ruby Style Guide.
DESCRIPTION
Expand Down
24 changes: 12 additions & 12 deletions spec/rubocop/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1639,18 +1639,18 @@ def meow_at_4am?

expect(cli.run(%w[--format simple example])).to eq(1)

expect($stderr.string).to eq(<<-RESULT.strip_margin('|'))
|Warning: Layout/LineLength does not support Min parameter.
|
|Supported parameters are:
|
| - Enabled
| - Max
| - AllowHeredoc
| - AllowURI
| - URISchemes
| - IgnoreCopDirectives
| - AllowedPatterns
expect($stderr.string).to eq(<<~RESULT)
Warning: Layout/LineLength does not support Min parameter.
Supported parameters are:
- Enabled
- Max
- AllowHeredoc
- AllowURI
- URISchemes
- IgnoreCopDirectives
- AllowedPatterns
RESULT
end

Expand Down
12 changes: 6 additions & 6 deletions spec/rubocop/cop/bundler/duplicated_gem_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

context 'and a gem is duplicated in default group' do
it 'registers an offense' do
expect_offense(<<-RUBY, 'Gemfile')
expect_offense(<<~RUBY, 'Gemfile')
source 'https://rubygems.org'
gem 'rubocop'
gem 'rubocop'
Expand All @@ -42,7 +42,7 @@

context 'and a duplicated gem is in a git/path/group/platforms block' do
it 'registers an offense' do
expect_offense(<<-RUBY, 'Gemfile')
expect_offense(<<~RUBY, 'Gemfile')
gem 'rubocop'
group :development do
gem 'rubocop', path: '/path/to/gem'
Expand All @@ -53,7 +53,7 @@
end

it 'registers an offense when gem from default group is conditionally duplicated' do
expect_offense(<<-RUBY, 'Gemfile')
expect_offense(<<~RUBY, 'Gemfile')
gem 'rubocop'
if Dir.exist? local
gem 'rubocop', path: local
Expand All @@ -66,7 +66,7 @@
end

it 'does not register an offense when gem is duplicated within `if-else` statement' do
expect_no_offenses(<<-RUBY, 'Gemfile')
expect_no_offenses(<<~RUBY, 'Gemfile')
if Dir.exist?(local)
gem 'rubocop', path: local
gem 'flog', path: local
Expand All @@ -77,7 +77,7 @@
end

it 'does not register an offense when gem is duplicated within `if-elsif` statement' do
expect_no_offenses(<<-RUBY, 'Gemfile')
expect_no_offenses(<<~RUBY, 'Gemfile')
if Dir.exist?(local)
gem 'rubocop', path: local
elsif ENV['RUBOCOP_VERSION'] == 'master'
Expand All @@ -91,7 +91,7 @@
end

it 'does not register an offense when gem is duplicated within `case` statement' do
expect_no_offenses(<<-RUBY, 'Gemfile')
expect_no_offenses(<<~RUBY, 'Gemfile')
case
when Dir.exist?(local)
gem 'rubocop', path: local
Expand Down
24 changes: 12 additions & 12 deletions spec/rubocop/cop/bundler/duplicated_group_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

context 'and a group is duplicated' do
it 'registers an offense' do
expect_offense(<<-RUBY, 'Gemfile')
expect_offense(<<~RUBY, 'Gemfile')
group :development do
gem 'rubocop'
end
Expand All @@ -49,7 +49,7 @@

context 'and a group is duplicated using different argument types' do
it 'registers an offense' do
expect_offense(<<-RUBY, 'Gemfile')
expect_offense(<<~RUBY, 'Gemfile')
group :development do
gem 'rubocop'
end
Expand Down Expand Up @@ -137,7 +137,7 @@

context 'and a set of groups is duplicated' do
it 'registers an offense' do
expect_offense(<<-RUBY, 'Gemfile')
expect_offense(<<~RUBY, 'Gemfile')
group :test, :development do
gem 'rubocop'
end
Expand All @@ -151,7 +151,7 @@

context 'and a set of groups is duplicated but `source` URLs are different' do
it 'does not register an offense' do
expect_no_offenses(<<-RUBY, 'Gemfile')
expect_no_offenses(<<~RUBY, 'Gemfile')
source 'https://rubygems.pkg.github.com/private-org' do
group :development do
gem 'rubocop'
Expand All @@ -167,7 +167,7 @@

context 'and a set of groups is duplicated and `source` URLs are the same' do
it 'registers an offense' do
expect_offense(<<-RUBY, 'Gemfile')
expect_offense(<<~RUBY, 'Gemfile')
source 'https://rubygems.pkg.github.com/private-org' do
group :development do
gem 'rubocop'
Expand All @@ -190,7 +190,7 @@

context 'and a set of groups is duplicated but `git` URLs are different' do
it 'does not register an offense' do
expect_no_offenses(<<-RUBY, 'Gemfile')
expect_no_offenses(<<~RUBY, 'Gemfile')
git 'https://github.com/rubocop/rubocop.git' do
group :default do
gem 'rubocop'
Expand All @@ -209,7 +209,7 @@

context 'and a set of groups is duplicated and `git` URLs are the same' do
it 'registers an offense' do
expect_offense(<<-RUBY, 'Gemfile')
expect_offense(<<~RUBY, 'Gemfile')
git 'https://github.com/rails/rails.git' do
group :default do
gem 'activesupport'
Expand All @@ -228,7 +228,7 @@

context 'and a set of groups is duplicated but `platforms` values are different' do
it 'does not register an offense' do
expect_no_offenses(<<-RUBY, 'Gemfile')
expect_no_offenses(<<~RUBY, 'Gemfile')
platforms :ruby do
group :default do
gem 'openssl'
Expand All @@ -246,7 +246,7 @@

context 'and a set of groups is duplicated and `platforms` values are the same' do
it 'registers an offense' do
expect_offense(<<-RUBY, 'Gemfile')
expect_offense(<<~RUBY, 'Gemfile')
platforms :ruby do
group :default do
gem 'ruby-debug'
Expand All @@ -265,7 +265,7 @@

context 'and a set of groups is duplicated but `path` values are different' do
it 'does not register an offense' do
expect_no_offenses(<<-RUBY, 'Gemfile')
expect_no_offenses(<<~RUBY, 'Gemfile')
path 'components_admin' do
group :default do
gem 'admin_ui'
Expand All @@ -283,7 +283,7 @@

context 'and a set of groups is duplicated and `path` values are the same' do
it 'registers an offense' do
expect_offense(<<-RUBY, 'Gemfile')
expect_offense(<<~RUBY, 'Gemfile')
path 'components' do
group :default do
gem 'admin_ui'
Expand All @@ -302,7 +302,7 @@

context 'when `source` URL argument is not given' do
it 'does not crash' do
expect_no_offenses(<<-RUBY, 'Gemfile')
expect_no_offenses(<<~RUBY, 'Gemfile')
source do
group :development do
gem 'rubocop'
Expand Down

0 comments on commit dd29994

Please sign in to comment.