Skip to content

Commit

Permalink
Merge pull request #8171 from koic/refine_offense_range_for_safe_navi…
Browse files Browse the repository at this point in the history
…gation_with_empty

Refine offense range for `Lint/SafeNavigationWithEmpty`
  • Loading branch information
koic committed Jun 20, 2020
2 parents 17e4dcd + 50b145e commit a90ec5f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/rubocop/cop/lint/safe_navigation_with_empty.rb
Expand Up @@ -30,7 +30,7 @@ class SafeNavigationWithEmpty < Cop
def on_if(node)
return unless safe_navigation_empty_in_conditional?(node)

add_offense(node)
add_offense(node.condition)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/rubocop/cop/lint/safe_navigation_with_empty_spec.rb
Expand Up @@ -7,7 +7,7 @@
it 'registers an offense on `&.empty?`' do
expect_offense(<<~RUBY)
return unless foo&.empty?
^^^^^^^^^^^^^^^^^^^^^^^^^ Avoid calling `empty?` with the safe navigation operator in conditionals.
^^^^^^^^^^^ Avoid calling `empty?` with the safe navigation operator in conditionals.
RUBY
end

Expand Down

0 comments on commit a90ec5f

Please sign in to comment.