forked from rubocop/rubocop
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Fix rubocop#10625] Restore the specification to `TargetRubyVersion: …
…2.5` Fixes rubocop#10625 and reverts part of rubocop#10577. Only the Ruby version (2.5) to runtime should have been dropped, not code analysis. This PR the specification to `TargetRubyVersion: 2.5` So, this keeps it compatible with `TargetRubyVersion` up to 1.28.2.
- Loading branch information
Showing
16 changed files
with
358 additions
and
288 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* [#10625](https://github.com/rubocop/rubocop/issues/10625): Restore the specification to `TargetRubyVersion: 2.5`. ([@koic][]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,101 +1,111 @@ | ||
# frozen_string_literal: true | ||
|
||
RSpec.describe RuboCop::Cop::Lint::ErbNewArguments, :config do | ||
it 'registers an offense when using `ERB.new` with non-keyword 2nd argument' do | ||
expect_offense(<<~RUBY) | ||
ERB.new(str, nil) | ||
^^^ Passing safe_level with the 2nd argument of `ERB.new` is deprecated. Do not use it, and specify other arguments as keyword arguments. | ||
RUBY | ||
|
||
expect_correction(<<~RUBY) | ||
ERB.new(str) | ||
RUBY | ||
context '<= Ruby 2.5', :ruby25 do | ||
it 'does not register an offense when using `ERB.new` with non-keyword arguments' do | ||
expect_no_offenses(<<~RUBY) | ||
ERB.new(str, nil, '-', '@output_buffer') | ||
RUBY | ||
end | ||
end | ||
|
||
it 'registers an offense when using `ERB.new` with non-keyword 2nd and 3rd arguments' do | ||
expect_offense(<<~RUBY) | ||
ERB.new(str, nil, '-') | ||
^^^ Passing trim_mode with the 3rd argument of `ERB.new` is deprecated. Use keyword argument like `ERB.new(str, trim_mode: '-')` instead. | ||
^^^ Passing safe_level with the 2nd argument of `ERB.new` is deprecated. Do not use it, and specify other arguments as keyword arguments. | ||
RUBY | ||
context '>= Ruby 2.6', :ruby26 do | ||
it 'registers an offense when using `ERB.new` with non-keyword 2nd argument' do | ||
expect_offense(<<~RUBY) | ||
ERB.new(str, nil) | ||
^^^ Passing safe_level with the 2nd argument of `ERB.new` is deprecated. Do not use it, and specify other arguments as keyword arguments. | ||
RUBY | ||
|
||
expect_correction(<<~RUBY) | ||
ERB.new(str, trim_mode: '-') | ||
RUBY | ||
end | ||
expect_correction(<<~RUBY) | ||
ERB.new(str) | ||
RUBY | ||
end | ||
|
||
it 'registers an offense when using `ERB.new` with non-keyword 2nd, 3rd and 4th arguments' do | ||
expect_offense(<<~RUBY) | ||
ERB.new(str, nil, '-', '@output_buffer') | ||
^^^^^^^^^^^^^^^^ Passing eoutvar with the 4th argument of `ERB.new` is deprecated. Use keyword argument like `ERB.new(str, eoutvar: '@output_buffer')` instead. | ||
^^^ Passing trim_mode with the 3rd argument of `ERB.new` is deprecated. Use keyword argument like `ERB.new(str, trim_mode: '-')` instead. | ||
^^^ Passing safe_level with the 2nd argument of `ERB.new` is deprecated. Do not use it, and specify other arguments as keyword arguments. | ||
RUBY | ||
|
||
expect_correction(<<~RUBY) | ||
ERB.new(str, trim_mode: '-', eoutvar: '@output_buffer') | ||
RUBY | ||
end | ||
it 'registers an offense when using `ERB.new` with non-keyword 2nd and 3rd arguments' do | ||
expect_offense(<<~RUBY) | ||
ERB.new(str, nil, '-') | ||
^^^ Passing trim_mode with the 3rd argument of `ERB.new` is deprecated. Use keyword argument like `ERB.new(str, trim_mode: '-')` instead. | ||
^^^ Passing safe_level with the 2nd argument of `ERB.new` is deprecated. Do not use it, and specify other arguments as keyword arguments. | ||
RUBY | ||
|
||
it 'registers an offense when using `ERB.new` ' \ | ||
'with non-keyword 2nd, 3rd and 4th arguments and' \ | ||
'keyword 5th argument' do | ||
expect_offense(<<~RUBY) | ||
ERB.new(str, nil, '-', '@output_buffer', trim_mode: '-', eoutvar: '@output_buffer') | ||
^^^^^^^^^^^^^^^^ Passing eoutvar with the 4th argument of `ERB.new` is deprecated. Use keyword argument like `ERB.new(str, eoutvar: '@output_buffer')` instead. | ||
^^^ Passing trim_mode with the 3rd argument of `ERB.new` is deprecated. Use keyword argument like `ERB.new(str, trim_mode: '-')` instead. | ||
^^^ Passing safe_level with the 2nd argument of `ERB.new` is deprecated. Do not use it, and specify other arguments as keyword arguments. | ||
RUBY | ||
|
||
expect_correction(<<~RUBY) | ||
ERB.new(str, trim_mode: '-', eoutvar: '@output_buffer') | ||
RUBY | ||
end | ||
expect_correction(<<~RUBY) | ||
ERB.new(str, trim_mode: '-') | ||
RUBY | ||
end | ||
|
||
it 'registers an offense when using `ERB.new` ' \ | ||
'with non-keyword 2nd and 3rd arguments and' \ | ||
'keyword 4th argument' do | ||
expect_offense(<<~RUBY) | ||
ERB.new(str, nil, '-', trim_mode: '-', eoutvar: '@output_buffer') | ||
^^^ Passing trim_mode with the 3rd argument of `ERB.new` is deprecated. Use keyword argument like `ERB.new(str, trim_mode: '-')` instead. | ||
^^^ Passing safe_level with the 2nd argument of `ERB.new` is deprecated. Do not use it, and specify other arguments as keyword arguments. | ||
RUBY | ||
|
||
expect_correction(<<~RUBY) | ||
ERB.new(str, trim_mode: '-', eoutvar: '@output_buffer') | ||
RUBY | ||
end | ||
it 'registers an offense when using `ERB.new` with non-keyword 2nd, 3rd and 4th arguments' do | ||
expect_offense(<<~RUBY) | ||
ERB.new(str, nil, '-', '@output_buffer') | ||
^^^^^^^^^^^^^^^^ Passing eoutvar with the 4th argument of `ERB.new` is deprecated. Use keyword argument like `ERB.new(str, eoutvar: '@output_buffer')` instead. | ||
^^^ Passing trim_mode with the 3rd argument of `ERB.new` is deprecated. Use keyword argument like `ERB.new(str, trim_mode: '-')` instead. | ||
^^^ Passing safe_level with the 2nd argument of `ERB.new` is deprecated. Do not use it, and specify other arguments as keyword arguments. | ||
RUBY | ||
|
||
expect_correction(<<~RUBY) | ||
ERB.new(str, trim_mode: '-', eoutvar: '@output_buffer') | ||
RUBY | ||
end | ||
|
||
it 'registers an offense when using `::ERB.new` with non-keyword 2nd, 3rd and 4th arguments' do | ||
expect_offense(<<~RUBY) | ||
::ERB.new(str, nil, '-', '@output_buffer') | ||
it 'registers an offense when using `ERB.new` ' \ | ||
'with non-keyword 2nd, 3rd and 4th arguments and' \ | ||
'keyword 5th argument' do | ||
expect_offense(<<~RUBY) | ||
ERB.new(str, nil, '-', '@output_buffer', trim_mode: '-', eoutvar: '@output_buffer') | ||
^^^^^^^^^^^^^^^^ Passing eoutvar with the 4th argument of `ERB.new` is deprecated. Use keyword argument like `ERB.new(str, eoutvar: '@output_buffer')` instead. | ||
^^^ Passing trim_mode with the 3rd argument of `ERB.new` is deprecated. Use keyword argument like `ERB.new(str, trim_mode: '-')` instead. | ||
^^^ Passing safe_level with the 2nd argument of `ERB.new` is deprecated. Do not use it, and specify other arguments as keyword arguments. | ||
RUBY | ||
RUBY | ||
|
||
expect_correction(<<~RUBY) | ||
::ERB.new(str, trim_mode: '-', eoutvar: '@output_buffer') | ||
RUBY | ||
end | ||
expect_correction(<<~RUBY) | ||
ERB.new(str, trim_mode: '-', eoutvar: '@output_buffer') | ||
RUBY | ||
end | ||
|
||
it 'does not register an offense when using `ERB.new` with keyword arguments' do | ||
expect_no_offenses(<<~RUBY) | ||
ERB.new(str, trim_mode: '-', eoutvar: '@output_buffer') | ||
RUBY | ||
end | ||
it 'registers an offense when using `ERB.new` ' \ | ||
'with non-keyword 2nd and 3rd arguments and' \ | ||
'keyword 4th argument' do | ||
expect_offense(<<~RUBY) | ||
ERB.new(str, nil, '-', trim_mode: '-', eoutvar: '@output_buffer') | ||
^^^ Passing trim_mode with the 3rd argument of `ERB.new` is deprecated. Use keyword argument like `ERB.new(str, trim_mode: '-')` instead. | ||
^^^ Passing safe_level with the 2nd argument of `ERB.new` is deprecated. Do not use it, and specify other arguments as keyword arguments. | ||
RUBY | ||
|
||
it 'does not register an offense when using `ERB.new` without optional arguments' do | ||
expect_no_offenses(<<~RUBY) | ||
ERB.new(str) | ||
RUBY | ||
end | ||
expect_correction(<<~RUBY) | ||
ERB.new(str, trim_mode: '-', eoutvar: '@output_buffer') | ||
RUBY | ||
end | ||
|
||
context 'when using `ActionView::Template::Handlers::ERB.new`' do | ||
it 'does not register an offense when using `ERB.new` without arguments' do | ||
it 'registers an offense when using `::ERB.new` with non-keyword 2nd, 3rd and 4th arguments' do | ||
expect_offense(<<~RUBY) | ||
::ERB.new(str, nil, '-', '@output_buffer') | ||
^^^^^^^^^^^^^^^^ Passing eoutvar with the 4th argument of `ERB.new` is deprecated. Use keyword argument like `ERB.new(str, eoutvar: '@output_buffer')` instead. | ||
^^^ Passing trim_mode with the 3rd argument of `ERB.new` is deprecated. Use keyword argument like `ERB.new(str, trim_mode: '-')` instead. | ||
^^^ Passing safe_level with the 2nd argument of `ERB.new` is deprecated. Do not use it, and specify other arguments as keyword arguments. | ||
RUBY | ||
|
||
expect_correction(<<~RUBY) | ||
::ERB.new(str, trim_mode: '-', eoutvar: '@output_buffer') | ||
RUBY | ||
end | ||
|
||
it 'does not register an offense when using `ERB.new` with keyword arguments' do | ||
expect_no_offenses(<<~RUBY) | ||
ERB.new | ||
ERB.new(str, trim_mode: '-', eoutvar: '@output_buffer') | ||
RUBY | ||
end | ||
|
||
it 'does not register an offense when using `ERB.new` without optional arguments' do | ||
expect_no_offenses(<<~RUBY) | ||
ERB.new(str) | ||
RUBY | ||
end | ||
|
||
context 'when using `ActionView::Template::Handlers::ERB.new`' do | ||
it 'does not register an offense when using `ERB.new` without arguments' do | ||
expect_no_offenses(<<~RUBY) | ||
ERB.new | ||
RUBY | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.