Skip to content

Commit

Permalink
Increase branch coverage of RSpec/Focus
Browse files Browse the repository at this point in the history
The corrector logic for pair_type/str_type/sym_type seems like a
"generic" implementation, so I move things around to let that be a
"default" case in the if/else block.
  • Loading branch information
bquorning committed Feb 9, 2025
1 parent 837c7d7 commit 079992a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .simplecov
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

SimpleCov.start do
enable_coverage :branch
minimum_coverage line: 100, branch: 98.44
minimum_coverage line: 100, branch: 98.57
add_filter '/spec/'
add_filter '/vendor/bundle/'
end
14 changes: 8 additions & 6 deletions lib/rubocop/cop/rspec/focus.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ def on_send(node)

focus_metadata(node) do |focus|
add_offense(focus) do |corrector|
if focus.pair_type? || focus.str_type? || focus.sym_type?
corrector.remove(with_surrounding(focus))
elsif focus.send_type?
if focus.send_type?
correct_send(corrector, focus)
else
corrector.remove(with_surrounding(focus))
end
end
end
Expand All @@ -89,9 +89,11 @@ def on_send(node)
private

def focus_metadata(node, &block)
yield(node) if focused_block?(node)

metadata(node, &block)
if focused_block?(node)
yield(node)
else
metadata(node, &block)
end
end

def with_surrounding(focus)
Expand Down

0 comments on commit 079992a

Please sign in to comment.