Skip to content
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

Fix an error for Lint/ErbNewArguments cop #7806

Merged
merged 1 commit into from Mar 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -18,6 +18,7 @@
* [#7767](https://github.com/rubocop-hq/rubocop/issues/7767): Skip array literals in `Style/HashTransformValues` and `Style/HashTransformKeys`. ([@tejasbubane][])
* [#7791](https://github.com/rubocop-hq/rubocop/issues/7791): Fix an error on auto-correction for `Layout/BlockEndNewline` when `}` of multiline block without processing is not on its own line. ([@koic][])
* [#7778](https://github.com/rubocop-hq/rubocop/issues/7778): Fix a false positive for `Layout/EndAlignment` when a non-whitespace is used before the `end` keyword. ([@koic][])
* [#7806](https://github.com/rubocop-hq/rubocop/pull/7806): Fix an error for `Lint/ErbNewArguments` cop when inspecting `ActionView::Template::Handlers::ERB.new`. ([@koic][])

### Changes

Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/lint/erb_new_arguments.rb
Expand Up @@ -84,7 +84,7 @@ class ErbNewArguments < Cop

def on_send(node)
erb_new_with_non_keyword_arguments(node) do |arguments|
return if correct_arguments?(arguments)
return if arguments.empty? || correct_arguments?(arguments)

arguments[1..3].each_with_index do |argument, i|
next if !argument || argument.hash_type?
Expand Down
9 changes: 9 additions & 0 deletions spec/rubocop/cop/lint/erb_new_arguments_spec.rb
Expand Up @@ -108,5 +108,14 @@
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