From 4a9cbfe4a1d5b1d4b1d2d6f6875151ba4692cef8 Mon Sep 17 00:00:00 2001 From: Benjamin Quorning Date: Sun, 9 Feb 2025 13:12:52 +0100 Subject: [PATCH] Increase branch coverage of RSpec/Focus 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. --- lib/rubocop/cop/rspec/focus.rb | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/rubocop/cop/rspec/focus.rb b/lib/rubocop/cop/rspec/focus.rb index 246352ad5..7fdfe20ba 100644 --- a/lib/rubocop/cop/rspec/focus.rb +++ b/lib/rubocop/cop/rspec/focus.rb @@ -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 @@ -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)