Skip to content

Commit

Permalink
Merge pull request #8426 from koic/fix_error_for_style_single_argumen…
Browse files Browse the repository at this point in the history
…t_dig

[Fix #8423] Fix an error for `Style/SingleArgumentDig`
  • Loading branch information
koic committed Jul 31, 2020
2 parents c343832 + cb751c0 commit cad8d8a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -30,6 +30,7 @@
* [#8406](https://github.com/rubocop-hq/rubocop/issues/8406): Improve `Style/AccessorGrouping`'s auto-correction to remove redundant blank lines. ([@koic][])
* [#8330](https://github.com/rubocop-hq/rubocop/issues/8330): Fix a false positive for `Style/MissingRespondToMissing` when defined method with inline access modifier. ([@koic][])
* [#8422](https://github.com/rubocop-hq/rubocop/issues/8422): Fix an error for `Lint/SelfAssignment` when using or-assignment for constant. ([@koic][])
* [#8423](https://github.com/rubocop-hq/rubocop/issues/8423): Fix an error for `Style/SingleArgumentDig` when without a receiver. ([@koic][])

### Changes

Expand Down
2 changes: 2 additions & 0 deletions lib/rubocop/cop/style/single_argument_dig.rb
Expand Up @@ -33,6 +33,8 @@ class SingleArgumentDig < Base
PATTERN

def on_send(node)
return unless node.receiver

expression = single_argument_dig?(node)
return unless expression

Expand Down
8 changes: 8 additions & 0 deletions spec/rubocop/cop/style/single_argument_dig_spec.rb
Expand Up @@ -66,4 +66,12 @@
end
end
end

context 'when without a receiver' do
it 'does not register an offense' do
expect_no_offenses(<<~RUBY)
dig(:key)
RUBY
end
end
end

0 comments on commit cad8d8a

Please sign in to comment.