diff --git a/lib/rubocop/cop/rspec/change_by_zero.rb b/lib/rubocop/cop/rspec/change_by_zero.rb index d37ddd4dd..1ee9a40b7 100644 --- a/lib/rubocop/cop/rspec/change_by_zero.rb +++ b/lib/rubocop/cop/rspec/change_by_zero.rb @@ -104,12 +104,12 @@ def on_send(node) # rubocop:disable Metrics/MethodLength def register_offense(node, change_node) if compound_expectations?(node) - add_offense(node.source_range, + add_offense(node, message: message_compound(change_node)) do |corrector| autocorrect_compound(corrector, node) end else - add_offense(node.source_range, + add_offense(node, message: message(change_node)) do |corrector| autocorrect(corrector, node, change_node) end diff --git a/lib/rubocop/cop/rspec/expect_actual.rb b/lib/rubocop/cop/rspec/expect_actual.rb index 7a15aa25d..7aeb0fa81 100644 --- a/lib/rubocop/cop/rspec/expect_actual.rb +++ b/lib/rubocop/cop/rspec/expect_actual.rb @@ -69,7 +69,7 @@ def on_send(node) # rubocop:disable Metrics/MethodLength expect_literal(node) do |actual, send_node, matcher, expected| next if SKIPPED_MATCHERS.include?(matcher) - add_offense(actual.source_range) do |corrector| + add_offense(actual) do |corrector| next unless CORRECTABLE_MATCHERS.include?(matcher) next if literal?(expected)