diff --git a/lib/rubocop/cop/rspec/expect_actual.rb b/lib/rubocop/cop/rspec/expect_actual.rb index 43bf1e7a6..7a15aa25d 100644 --- a/lib/rubocop/cop/rspec/expect_actual.rb +++ b/lib/rubocop/cop/rspec/expect_actual.rb @@ -97,7 +97,7 @@ def simple_literal?(node) def complex_literal?(node) COMPLEX_LITERALS.include?(node.type) && - node.each_child_node.all? { literal?(_1) } + node.each_child_node.all? { |child_node| literal?(child_node) } end end end diff --git a/lib/rubocop/cop/rspec/file_path.rb b/lib/rubocop/cop/rspec/file_path.rb index 09ca463fe..d0cbdf095 100644 --- a/lib/rubocop/cop/rspec/file_path.rb +++ b/lib/rubocop/cop/rspec/file_path.rb @@ -101,7 +101,7 @@ def ensure_correct_file_path(send_node, example_group, arguments) end def routing_spec?(args) - args.any? { routing_metadata?(_1) } || routing_spec_path? + args.any? { |arg| routing_metadata?(arg) } || routing_spec_path? end def pattern_for(example_group, arguments) diff --git a/lib/rubocop/cop/rspec/leaky_constant_declaration.rb b/lib/rubocop/cop/rspec/leaky_constant_declaration.rb index 0591930aa..907b97dea 100644 --- a/lib/rubocop/cop/rspec/leaky_constant_declaration.rb +++ b/lib/rubocop/cop/rspec/leaky_constant_declaration.rb @@ -119,7 +119,7 @@ def on_module(node) private def inside_describe_block?(node) - node.each_ancestor(:block).any? { spec_group?(_1) } + node.each_ancestor(:block).any? { |ancestor| spec_group?(ancestor) } end end end diff --git a/lib/rubocop/cop/rspec/multiple_describes.rb b/lib/rubocop/cop/rspec/multiple_describes.rb index 43ff656a8..69199a592 100644 --- a/lib/rubocop/cop/rspec/multiple_describes.rb +++ b/lib/rubocop/cop/rspec/multiple_describes.rb @@ -30,7 +30,7 @@ class MultipleDescribes < Base def on_top_level_group(node) top_level_example_groups = - top_level_groups.select { example_group?(_1) } + top_level_groups.select { |group| example_group?(group) } return if top_level_example_groups.one? return unless top_level_example_groups.first.equal?(node) diff --git a/lib/rubocop/cop/rspec/multiple_memoized_helpers.rb b/lib/rubocop/cop/rspec/multiple_memoized_helpers.rb index b30beeec7..e386c5c68 100644 --- a/lib/rubocop/cop/rspec/multiple_memoized_helpers.rb +++ b/lib/rubocop/cop/rspec/multiple_memoized_helpers.rb @@ -108,10 +108,8 @@ def on_new_investigation attr_reader :example_group_memoized_helpers def all_helpers(node) - [ - *helpers(node), - *node.each_ancestor(:block).flat_map { helpers(_1) } - ] + helpers(node) + + node.each_ancestor(:block).flat_map { |ancestor| helpers(ancestor) } end def helpers(node) diff --git a/lib/rubocop/cop/rspec/named_subject.rb b/lib/rubocop/cop/rspec/named_subject.rb index 6bab5683b..f69480051 100644 --- a/lib/rubocop/cop/rspec/named_subject.rb +++ b/lib/rubocop/cop/rspec/named_subject.rb @@ -107,8 +107,11 @@ def on_block(node) # rubocop:disable InternalAffairs/NumblockHandler private def ignored_shared_example?(node) - cop_config['IgnoreSharedExamples'] && - node.each_ancestor(:block).any? { shared_example?(_1) } + return false unless cop_config['IgnoreSharedExamples'] + + node.each_ancestor(:block).any? do |ancestor| + shared_example?(ancestor) + end end def check_explicit_subject(node) diff --git a/lib/rubocop/cop/rspec/subject_stub.rb b/lib/rubocop/cop/rspec/subject_stub.rb index 415f031a3..273e4fea9 100644 --- a/lib/rubocop/cop/rspec/subject_stub.rb +++ b/lib/rubocop/cop/rspec/subject_stub.rb @@ -113,8 +113,8 @@ class SubjectStub < Base PATTERN def on_top_level_group(node) - @explicit_subjects = find_all_explicit(node) { subject?(_1) } - @subject_overrides = find_all_explicit(node) { let?(_1) } + @explicit_subjects = find_all_explicit(node) { |n| subject?(n) } + @subject_overrides = find_all_explicit(node) { |n| let?(n) } find_subject_expectations(node) do |stub| add_offense(stub) diff --git a/lib/rubocop/rspec/shared_contexts/default_rspec_language_config_context.rb b/lib/rubocop/rspec/shared_contexts/default_rspec_language_config_context.rb index 9efbc24b5..f130fdb4d 100644 --- a/lib/rubocop/rspec/shared_contexts/default_rspec_language_config_context.rb +++ b/lib/rubocop/rspec/shared_contexts/default_rspec_language_config_context.rb @@ -21,7 +21,7 @@ def deep_dup(object) when Array object.map { |item| deep_dup(item) } when Hash - object.transform_values { deep_dup(_1) } + object.transform_values { |value| deep_dup(value) } else object # only collections undergo modifications and need duping end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index bca7a9197..b39d1e6fe 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -13,7 +13,7 @@ module SpecHelper Dir .glob(File.expand_path(spec_helper_glob, __dir__)) .sort - .each { require(_1) } + .each { |path| require path } RSpec.configure do |config| # Set metadata so smoke tests are run on all cop specs