brew vendor-gems: commit updates.
This commit is contained in:
parent
f7c3f66eb1
commit
30121165d9
21
Library/Homebrew/vendor/bundle/bundler/setup.rb
vendored
21
Library/Homebrew/vendor/bundle/bundler/setup.rb
vendored
@ -14,18 +14,15 @@ $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/ast-2.4.1/lib"
|
|||||||
$:.unshift "#{path}/"
|
$:.unshift "#{path}/"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/extensions/universal-darwin-19/2.6.0/byebug-11.1.3"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/extensions/universal-darwin-19/2.6.0/byebug-11.1.3"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/byebug-11.1.3/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/byebug-11.1.3/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/connection_pool-2.2.3/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/extensions/universal-darwin-19/2.6.0/json-2.3.1"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/extensions/universal-darwin-19/2.6.0/json-2.3.0"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/json-2.3.1/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/json-2.3.0/lib"
|
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/docile-1.3.2/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/docile-1.3.2/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/simplecov-html-0.10.2/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/simplecov-html-0.12.2/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/simplecov-0.16.1/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/simplecov-0.18.5/lib"
|
||||||
$:.unshift "#{path}/../../../../../../../../Library/Ruby/Gems/2.6.0/gems/sync-0.5.0/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/url-0.3.2/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/tins-1.25.0/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/codecov-0.1.17/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/term-ansicolor-1.7.1/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/connection_pool-2.2.3/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/thor-1.0.1/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/diff-lcs-1.4.4/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/coveralls-0.8.23/lib"
|
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/diff-lcs-1.4.2/lib"
|
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/extensions/universal-darwin-19/2.6.0/unf_ext-0.0.7.7"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/extensions/universal-darwin-19/2.6.0/unf_ext-0.0.7.7"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/unf_ext-0.0.7.7/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/unf_ext-0.0.7.7/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/unf-0.1.4/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/unf-0.1.4/lib"
|
||||||
@ -67,5 +64,5 @@ $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/ruby-progressbar-1.10
|
|||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/unicode-display_width-1.7.0/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/unicode-display_width-1.7.0/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-0.86.0/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-0.86.0/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-performance-1.6.1/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-performance-1.6.1/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rspec-1.40.0/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rspec-1.41.0/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/ruby-macho-2.2.0/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/ruby-macho-2.2.0/lib"
|
||||||
|
|||||||
@ -1,87 +0,0 @@
|
|||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
module RuboCop
|
|
||||||
module RSpec
|
|
||||||
# Wrapper for RSpec example groups
|
|
||||||
class ExampleGroup < Concept
|
|
||||||
# @!method scope_change?(node)
|
|
||||||
#
|
|
||||||
# Detect if the node is an example group or shared example
|
|
||||||
#
|
|
||||||
# Selectors which indicate that we should stop searching
|
|
||||||
#
|
|
||||||
def_node_matcher :scope_change?, (
|
|
||||||
ExampleGroups::ALL + SharedGroups::ALL + Includes::ALL
|
|
||||||
).block_pattern
|
|
||||||
|
|
||||||
def subjects
|
|
||||||
subjects_in_scope(node)
|
|
||||||
end
|
|
||||||
|
|
||||||
def examples
|
|
||||||
examples_in_scope(node).map(&Example.public_method(:new))
|
|
||||||
end
|
|
||||||
|
|
||||||
def hooks
|
|
||||||
hooks_in_scope(node).map(&Hook.public_method(:new))
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def subjects_in_scope(node)
|
|
||||||
node.each_child_node.flat_map do |child|
|
|
||||||
find_subjects(child)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def find_subjects(node)
|
|
||||||
return [] if scope_change?(node)
|
|
||||||
|
|
||||||
if subject?(node)
|
|
||||||
[node]
|
|
||||||
else
|
|
||||||
subjects_in_scope(node)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def hooks_in_scope(node)
|
|
||||||
node.each_child_node.flat_map do |child|
|
|
||||||
find_hooks(child)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def find_hooks(node)
|
|
||||||
return [] if scope_change?(node) || example?(node)
|
|
||||||
|
|
||||||
if hook?(node)
|
|
||||||
[node]
|
|
||||||
else
|
|
||||||
hooks_in_scope(node)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def examples_in_scope(node, &blk)
|
|
||||||
node.each_child_node.flat_map do |child|
|
|
||||||
find_examples(child, &blk)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Recursively search for examples within the current scope
|
|
||||||
#
|
|
||||||
# Searches node for examples and halts when a scope change is detected
|
|
||||||
#
|
|
||||||
# @param node [RuboCop::Node] node to recursively search for examples
|
|
||||||
#
|
|
||||||
# @return [Array<RuboCop::Node>] discovered example nodes
|
|
||||||
def find_examples(node)
|
|
||||||
return [] if scope_change?(node)
|
|
||||||
|
|
||||||
if example?(node)
|
|
||||||
[node]
|
|
||||||
else
|
|
||||||
examples_in_scope(node)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@ -13,6 +13,7 @@ require_relative 'rubocop/rspec/top_level_describe'
|
|||||||
require_relative 'rubocop/rspec/wording'
|
require_relative 'rubocop/rspec/wording'
|
||||||
require_relative 'rubocop/rspec/language'
|
require_relative 'rubocop/rspec/language'
|
||||||
require_relative 'rubocop/rspec/language/node_pattern'
|
require_relative 'rubocop/rspec/language/node_pattern'
|
||||||
|
require_relative 'rubocop/rspec/top_level_group'
|
||||||
require_relative 'rubocop/rspec/concept'
|
require_relative 'rubocop/rspec/concept'
|
||||||
require_relative 'rubocop/rspec/example_group'
|
require_relative 'rubocop/rspec/example_group'
|
||||||
require_relative 'rubocop/rspec/example'
|
require_relative 'rubocop/rspec/example'
|
||||||
@ -43,12 +43,14 @@ module RuboCop
|
|||||||
def_node_matcher :rails_metadata?, <<-PATTERN
|
def_node_matcher :rails_metadata?, <<-PATTERN
|
||||||
(pair
|
(pair
|
||||||
(sym :type)
|
(sym :type)
|
||||||
(sym {:request :feature :system :routing :view})
|
(sym {
|
||||||
|
:channel :controller :helper :job :mailer :model :request
|
||||||
|
:routing :view :feature :system :mailbox
|
||||||
|
}
|
||||||
|
)
|
||||||
)
|
)
|
||||||
PATTERN
|
PATTERN
|
||||||
|
|
||||||
def_node_matcher :shared_group?, SharedGroups::ALL.block_pattern
|
|
||||||
|
|
||||||
def on_top_level_describe(node, (described_value, _))
|
def on_top_level_describe(node, (described_value, _))
|
||||||
return if shared_group?(root_node)
|
return if shared_group?(root_node)
|
||||||
return if valid_describe?(node)
|
return if valid_describe?(node)
|
||||||
@ -31,12 +31,15 @@ module RuboCop
|
|||||||
(send _ !#reserved_method? $...)
|
(send _ !#reserved_method? $...)
|
||||||
PATTERN
|
PATTERN
|
||||||
|
|
||||||
def_node_search :factory_attributes, <<-PATTERN
|
def_node_matcher :factory_attributes, <<-PATTERN
|
||||||
(block (send _ #attribute_defining_method? ...) _ { (begin $...) $(send ...) } )
|
(block (send _ #attribute_defining_method? ...) _ { (begin $...) $(send ...) } )
|
||||||
PATTERN
|
PATTERN
|
||||||
|
|
||||||
def on_block(node)
|
def on_block(node)
|
||||||
factory_attributes(node).to_a.flatten.each do |attribute|
|
attributes = factory_attributes(node) || []
|
||||||
|
attributes = [attributes] unless attributes.is_a?(Array)
|
||||||
|
|
||||||
|
attributes.each do |attribute|
|
||||||
next unless offensive_receiver?(attribute.receiver, node)
|
next unless offensive_receiver?(attribute.receiver, node)
|
||||||
next if proc?(attribute) || association?(attribute.first_argument)
|
next if proc?(attribute) || association?(attribute.first_argument)
|
||||||
|
|
||||||
@ -47,13 +47,11 @@ module RuboCop
|
|||||||
# end
|
# end
|
||||||
#
|
#
|
||||||
class InstanceVariable < Cop
|
class InstanceVariable < Cop
|
||||||
|
include RuboCop::RSpec::TopLevelGroup
|
||||||
|
|
||||||
MSG = 'Avoid instance variables – use let, ' \
|
MSG = 'Avoid instance variables – use let, ' \
|
||||||
'a method call, or a local variable (if possible).'
|
'a method call, or a local variable (if possible).'
|
||||||
|
|
||||||
EXAMPLE_GROUP_METHODS = ExampleGroups::ALL + SharedGroups::ALL
|
|
||||||
|
|
||||||
def_node_matcher :spec_group?, EXAMPLE_GROUP_METHODS.block_pattern
|
|
||||||
|
|
||||||
def_node_matcher :dynamic_class?, <<-PATTERN
|
def_node_matcher :dynamic_class?, <<-PATTERN
|
||||||
(block (send (const nil? :Class) :new ...) ...)
|
(block (send (const nil? :Class) :new ...) ...)
|
||||||
PATTERN
|
PATTERN
|
||||||
@ -69,9 +67,7 @@ module RuboCop
|
|||||||
|
|
||||||
def_node_search :ivar_assigned?, '(ivasgn % ...)'
|
def_node_search :ivar_assigned?, '(ivasgn % ...)'
|
||||||
|
|
||||||
def on_block(node)
|
def on_top_level_group(node)
|
||||||
return unless spec_group?(node)
|
|
||||||
|
|
||||||
ivar_usage(node) do |ivar, name|
|
ivar_usage(node) do |ivar, name|
|
||||||
next if valid_usage?(ivar)
|
next if valid_usage?(ivar)
|
||||||
next if assignment_only? && !ivar_assigned?(node, name)
|
next if assignment_only? && !ivar_assigned?(node, name)
|
||||||
@ -119,11 +119,8 @@ module RuboCop
|
|||||||
private
|
private
|
||||||
|
|
||||||
def inside_describe_block?(node)
|
def inside_describe_block?(node)
|
||||||
node.each_ancestor(:block).any?(&method(:in_example_or_shared_group?))
|
node.each_ancestor(:block).any?(&method(:spec_group?))
|
||||||
end
|
end
|
||||||
|
|
||||||
def_node_matcher :in_example_or_shared_group?,
|
|
||||||
(ExampleGroups::ALL + SharedGroups::ALL).block_pattern
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -28,14 +28,20 @@ module RuboCop
|
|||||||
class LetSetup < Cop
|
class LetSetup < Cop
|
||||||
MSG = 'Do not use `let!` to setup objects not referenced in tests.'
|
MSG = 'Do not use `let!` to setup objects not referenced in tests.'
|
||||||
|
|
||||||
def_node_search :let_bang, <<-PATTERN
|
def_node_matcher :example_or_shared_group_or_including?,
|
||||||
|
(
|
||||||
|
ExampleGroups::ALL + SharedGroups::ALL +
|
||||||
|
Includes::ALL
|
||||||
|
).block_pattern
|
||||||
|
|
||||||
|
def_node_matcher :let_bang, <<-PATTERN
|
||||||
(block $(send nil? :let! (sym $_)) args ...)
|
(block $(send nil? :let! (sym $_)) args ...)
|
||||||
PATTERN
|
PATTERN
|
||||||
|
|
||||||
def_node_search :method_called?, '(send nil? %)'
|
def_node_search :method_called?, '(send nil? %)'
|
||||||
|
|
||||||
def on_block(node)
|
def on_block(node)
|
||||||
return unless example_group?(node)
|
return unless example_or_shared_group_or_including?(node)
|
||||||
|
|
||||||
unused_let_bang(node) do |let|
|
unused_let_bang(node) do |let|
|
||||||
add_offense(let)
|
add_offense(let)
|
||||||
@ -45,10 +51,16 @@ module RuboCop
|
|||||||
private
|
private
|
||||||
|
|
||||||
def unused_let_bang(node)
|
def unused_let_bang(node)
|
||||||
let_bang(node) do |method_send, method_name|
|
child_let_bang(node) do |method_send, method_name|
|
||||||
yield(method_send) unless method_called?(node, method_name)
|
yield(method_send) unless method_called?(node, method_name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def child_let_bang(node, &block)
|
||||||
|
RuboCop::RSpec::ExampleGroup.new(node).lets.each do |let|
|
||||||
|
let_bang(let, &block)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -97,13 +97,11 @@ module RuboCop
|
|||||||
"Configuration key `#{DEPRECATED_MAX_KEY}` for #{cop_name} is " \
|
"Configuration key `#{DEPRECATED_MAX_KEY}` for #{cop_name} is " \
|
||||||
'deprecated in favor of `Max`. Please use that instead.'
|
'deprecated in favor of `Max`. Please use that instead.'
|
||||||
|
|
||||||
def_node_search :find_contexts, ExampleGroups::ALL.block_pattern
|
|
||||||
|
|
||||||
def on_top_level_describe(node, _args)
|
def on_top_level_describe(node, _args)
|
||||||
find_nested_contexts(node.parent) do |context, nesting|
|
find_nested_example_groups(node.parent) do |example_group, nesting|
|
||||||
self.max = nesting
|
self.max = nesting
|
||||||
add_offense(
|
add_offense(
|
||||||
context.send_node,
|
example_group.send_node,
|
||||||
message: message(nesting)
|
message: message(nesting)
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
@ -111,13 +109,14 @@ module RuboCop
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def find_nested_contexts(node, nesting: 1, &block)
|
def find_nested_example_groups(node, nesting: 1, &block)
|
||||||
find_contexts(node) do |nested_context|
|
example_group = example_group?(node)
|
||||||
yield(nested_context, nesting) if nesting > max_nesting
|
yield node, nesting if example_group && nesting > max_nesting
|
||||||
|
|
||||||
nested_context.each_child_node do |child|
|
next_nesting = example_group ? nesting + 1 : nesting
|
||||||
find_nested_contexts(child, nesting: nesting + 1, &block)
|
|
||||||
end
|
node.each_child_node(:block, :begin) do |child|
|
||||||
|
find_nested_example_groups(child, nesting: next_nesting, &block)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -277,12 +277,12 @@ module RuboCop
|
|||||||
# expect(foo).to be_something
|
# expect(foo).to be_something
|
||||||
#
|
#
|
||||||
# # also good - It checks "true" strictly.
|
# # also good - It checks "true" strictly.
|
||||||
# expect(foo).to be(true)
|
# expect(foo.something?).to be(true)
|
||||||
#
|
#
|
||||||
# @example Strict: false, EnforcedStyle: inflected
|
# @example Strict: false, EnforcedStyle: inflected
|
||||||
# # bad
|
# # bad
|
||||||
# expect(foo.something?).to be_truthy
|
# expect(foo.something?).to be_truthy
|
||||||
# expect(foo).to be(true)
|
# expect(foo.something?).to be(true)
|
||||||
#
|
#
|
||||||
# # good
|
# # good
|
||||||
# expect(foo).to be_something
|
# expect(foo).to be_something
|
||||||
@ -40,20 +40,21 @@ module RuboCop
|
|||||||
MSG_BLOCK = 'Use block for static values.'
|
MSG_BLOCK = 'Use block for static values.'
|
||||||
|
|
||||||
def_node_search :contains_stub?, '(send nil? :receive (...))'
|
def_node_search :contains_stub?, '(send nil? :receive (...))'
|
||||||
|
def_node_matcher :stub_with_block?, '(block #contains_stub? ...)'
|
||||||
def_node_search :and_return_value, <<-PATTERN
|
def_node_search :and_return_value, <<-PATTERN
|
||||||
$(send _ :and_return $(...))
|
$(send _ :and_return $(...))
|
||||||
PATTERN
|
PATTERN
|
||||||
|
|
||||||
def on_send(node)
|
def on_send(node)
|
||||||
return unless contains_stub?(node)
|
|
||||||
return unless style == :block
|
return unless style == :block
|
||||||
|
return unless contains_stub?(node)
|
||||||
|
|
||||||
check_and_return_call(node)
|
check_and_return_call(node)
|
||||||
end
|
end
|
||||||
|
|
||||||
def on_block(node)
|
def on_block(node)
|
||||||
return unless contains_stub?(node)
|
|
||||||
return unless style == :and_return
|
return unless style == :and_return
|
||||||
|
return unless stub_with_block?(node)
|
||||||
|
|
||||||
check_block_body(node)
|
check_block_body(node)
|
||||||
end
|
end
|
||||||
@ -22,6 +22,8 @@ module RuboCop
|
|||||||
# end
|
# end
|
||||||
#
|
#
|
||||||
class SubjectStub < Cop
|
class SubjectStub < Cop
|
||||||
|
include RuboCop::RSpec::TopLevelGroup
|
||||||
|
|
||||||
MSG = 'Do not stub methods of the object under test.'
|
MSG = 'Do not stub methods of the object under test.'
|
||||||
|
|
||||||
# @!method subject(node)
|
# @!method subject(node)
|
||||||
@ -75,11 +77,7 @@ module RuboCop
|
|||||||
} ...)
|
} ...)
|
||||||
PATTERN
|
PATTERN
|
||||||
|
|
||||||
def on_block(node)
|
def on_top_level_group(node)
|
||||||
return unless example_group?(node)
|
|
||||||
return if (processed_example_groups & node.ancestors).any?
|
|
||||||
|
|
||||||
processed_example_groups << node
|
|
||||||
@explicit_subjects = find_all_explicit_subjects(node)
|
@explicit_subjects = find_all_explicit_subjects(node)
|
||||||
|
|
||||||
find_subject_expectations(node) do |stub|
|
find_subject_expectations(node) do |stub|
|
||||||
@ -89,10 +87,6 @@ module RuboCop
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def processed_example_groups
|
|
||||||
@processed_example_groups ||= Set.new
|
|
||||||
end
|
|
||||||
|
|
||||||
def find_all_explicit_subjects(node)
|
def find_all_explicit_subjects(node)
|
||||||
node.each_descendant(:block).with_object({}) do |child, h|
|
node.each_descendant(:block).with_object({}) do |child, h|
|
||||||
name = subject(child)
|
name = subject(child)
|
||||||
@ -0,0 +1,59 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
module RuboCop
|
||||||
|
module RSpec
|
||||||
|
# Wrapper for RSpec example groups
|
||||||
|
class ExampleGroup < Concept
|
||||||
|
# @!method scope_change?(node)
|
||||||
|
#
|
||||||
|
# Detect if the node is an example group or shared example
|
||||||
|
#
|
||||||
|
# Selectors which indicate that we should stop searching
|
||||||
|
#
|
||||||
|
def_node_matcher :scope_change?, (
|
||||||
|
ExampleGroups::ALL + SharedGroups::ALL + Includes::ALL
|
||||||
|
).block_pattern
|
||||||
|
|
||||||
|
def lets
|
||||||
|
find_all_in_scope(node, :let?)
|
||||||
|
end
|
||||||
|
|
||||||
|
def subjects
|
||||||
|
find_all_in_scope(node, :subject?)
|
||||||
|
end
|
||||||
|
|
||||||
|
def examples
|
||||||
|
find_all_in_scope(node, :example?).map(&Example.public_method(:new))
|
||||||
|
end
|
||||||
|
|
||||||
|
def hooks
|
||||||
|
find_all_in_scope(node, :hook?).map(&Hook.public_method(:new))
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
# Recursively search for predicate within the current scope
|
||||||
|
#
|
||||||
|
# Searches node and halts when a scope change is detected
|
||||||
|
#
|
||||||
|
# @param node [RuboCop::Node] node to recursively search
|
||||||
|
#
|
||||||
|
# @return [Array<RuboCop::Node>] discovered nodes
|
||||||
|
def find_all_in_scope(node, predicate)
|
||||||
|
node.each_child_node.flat_map do |child|
|
||||||
|
find_all(child, predicate)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def find_all(node, predicate)
|
||||||
|
if public_send(predicate, node)
|
||||||
|
[node]
|
||||||
|
elsif scope_change?(node) || example?(node)
|
||||||
|
[]
|
||||||
|
else
|
||||||
|
find_all_in_scope(node, predicate)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@ -4,7 +4,13 @@ module RuboCop
|
|||||||
module RSpec
|
module RSpec
|
||||||
# RuboCop FactoryBot project namespace
|
# RuboCop FactoryBot project namespace
|
||||||
module FactoryBot
|
module FactoryBot
|
||||||
ATTRIBUTE_DEFINING_METHODS = %i[factory trait transient ignore].freeze
|
ATTRIBUTE_DEFINING_METHODS = %i[
|
||||||
|
factory
|
||||||
|
ignore
|
||||||
|
trait
|
||||||
|
traits_for_enum
|
||||||
|
transient
|
||||||
|
].freeze
|
||||||
|
|
||||||
UNPROXIED_METHODS = %i[
|
UNPROXIED_METHODS = %i[
|
||||||
__send__
|
__send__
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user