brew vendor-gems: commit updates.

This commit is contained in:
BrewTestBot 2021-04-29 05:56:23 +00:00
parent b61adcf6c9
commit 77c40acd26
No known key found for this signature in database
GPG Key ID: 82D7D104050B0F0F
111 changed files with 183 additions and 17 deletions

View File

@ -82,7 +82,7 @@ $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/unicode-display_width
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-1.13.0/lib" $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-1.13.0/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-performance-1.11.0/lib" $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-performance-1.11.0/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rails-2.9.1/lib" $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rails-2.9.1/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rspec-2.2.0/lib" $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rspec-2.3.0/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-sorbet-0.6.1/lib" $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-sorbet-0.6.1/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/ruby-macho-2.5.0/lib" $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/ruby-macho-2.5.0/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/simplecov-html-0.12.3/lib" $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/simplecov-html-0.12.3/lib"

View File

@ -253,7 +253,9 @@ RSpec/ExampleLength:
Description: Checks for long examples. Description: Checks for long examples.
Enabled: true Enabled: true
Max: 5 Max: 5
CountAsOne: []
VersionAdded: '1.5' VersionAdded: '1.5'
VersionChanged: '2.3'
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ExampleLength StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ExampleLength
RSpec/ExampleWithoutDescription: RSpec/ExampleWithoutDescription:

View File

@ -30,10 +30,12 @@ module RuboCop
MSG_UNUSED_ARG = 'You should call `%<arg>s.call` ' \ MSG_UNUSED_ARG = 'You should call `%<arg>s.call` ' \
'or `%<arg>s.run`.' 'or `%<arg>s.run`.'
# @!method hook(node)
def_node_matcher :hook, <<-PATTERN def_node_matcher :hook, <<-PATTERN
(block (send nil? :around sym ?) (args $...) ...) (block (send nil? :around sym ?) (args $...) ...)
PATTERN PATTERN
# @!method find_arg_usage(node)
def_node_search :find_arg_usage, <<-PATTERN def_node_search :find_arg_usage, <<-PATTERN
{(send $... {:call :run}) (send _ _ $...) (yield $...) (block-pass $...)} {(send $... {:call :run}) (send _ _ $...) (yield $...) (block-pass $...)}
PATTERN PATTERN

View File

@ -22,6 +22,7 @@ module RuboCop
class Be < Base class Be < Base
MSG = "Don't use `be` without an argument." MSG = "Don't use `be` without an argument."
# @!method be_without_args(node)
def_node_matcher :be_without_args, <<-PATTERN def_node_matcher :be_without_args, <<-PATTERN
(send _ #Runners.all $(send nil? :be)) (send _ #Runners.all $(send nil? :be))
PATTERN PATTERN

View File

@ -41,6 +41,7 @@ module RuboCop
MSG = 'Prefer `be` over `eql`.' MSG = 'Prefer `be` over `eql`.'
RESTRICT_ON_SEND = %i[to].freeze RESTRICT_ON_SEND = %i[to].freeze
# @!method eql_type_with_identity(node)
def_node_matcher :eql_type_with_identity, <<-PATTERN def_node_matcher :eql_type_with_identity, <<-PATTERN
(send _ :to $(send nil? :eql {true false int float sym nil_type?})) (send _ :to $(send nil? :eql {true false int float sym nil_type?}))
PATTERN PATTERN

View File

@ -31,6 +31,7 @@ module RuboCop
RESTRICT_ON_SEND = %i[before after].freeze RESTRICT_ON_SEND = %i[before after].freeze
# @!method before_or_after_all(node)
def_node_matcher :before_or_after_all, <<-PATTERN def_node_matcher :before_or_after_all, <<-PATTERN
$(send _ {:before :after} (sym {:all :context})) $(send _ {:before :after} (sym {:all :context}))
PATTERN PATTERN

View File

@ -32,17 +32,20 @@ module RuboCop
RESTRICT_ON_SEND = %i[expect].freeze RESTRICT_ON_SEND = %i[expect].freeze
# @!method expectation_set_on_current_path(node)
def_node_matcher :expectation_set_on_current_path, <<-PATTERN def_node_matcher :expectation_set_on_current_path, <<-PATTERN
(send nil? :expect (send {(send nil? :page) nil?} :current_path)) (send nil? :expect (send {(send nil? :page) nil?} :current_path))
PATTERN PATTERN
# Supported matchers: eq(...) / match(/regexp/) / match('regexp') # Supported matchers: eq(...) / match(/regexp/) / match('regexp')
# @!method as_is_matcher(node)
def_node_matcher :as_is_matcher, <<-PATTERN def_node_matcher :as_is_matcher, <<-PATTERN
(send (send
#expectation_set_on_current_path $#Runners.all #expectation_set_on_current_path $#Runners.all
${(send nil? :eq ...) (send nil? :match (regexp ...))}) ${(send nil? :eq ...) (send nil? :match (regexp ...))})
PATTERN PATTERN
# @!method regexp_str_matcher(node)
def_node_matcher :regexp_str_matcher, <<-PATTERN def_node_matcher :regexp_str_matcher, <<-PATTERN
(send (send
#expectation_set_on_current_path $#Runners.all #expectation_set_on_current_path $#Runners.all

View File

@ -55,16 +55,19 @@ module RuboCop
feature: :describe feature: :describe
}.freeze }.freeze
# @!method capybara_speak(node)
def_node_matcher :capybara_speak, <<-PATTERN def_node_matcher :capybara_speak, <<-PATTERN
{#{MAP.keys.map(&:inspect).join(' ')}} {#{MAP.keys.map(&:inspect).join(' ')}}
PATTERN PATTERN
# @!method spec?(node)
def_node_matcher :spec?, <<-PATTERN def_node_matcher :spec?, <<-PATTERN
(block (block
(send #rspec? {:describe :feature} ...) (send #rspec? {:describe :feature} ...)
...) ...)
PATTERN PATTERN
# @!method feature_method(node)
def_node_matcher :feature_method, <<-PATTERN def_node_matcher :feature_method, <<-PATTERN
(block (block
$(send #rspec? $#capybara_speak ...) $(send #rspec? $#capybara_speak ...)

View File

@ -46,10 +46,12 @@ module RuboCop
RESTRICT_ON_SEND = CAPYBARA_MATCHER_METHODS RESTRICT_ON_SEND = CAPYBARA_MATCHER_METHODS
# @!method visible_true?(node)
def_node_matcher :visible_true?, <<~PATTERN def_node_matcher :visible_true?, <<~PATTERN
(send nil? #capybara_matcher? ... (hash <$(pair (sym :visible) true) ...>)) (send nil? #capybara_matcher? ... (hash <$(pair (sym :visible) true) ...>))
PATTERN PATTERN
# @!method visible_false?(node)
def_node_matcher :visible_false?, <<~PATTERN def_node_matcher :visible_false?, <<~PATTERN
(send nil? #capybara_matcher? ... (hash <$(pair (sym :visible) false) ...>)) (send nil? #capybara_matcher? ... (hash <$(pair (sym :visible) false) ...>))
PATTERN PATTERN

View File

@ -28,6 +28,7 @@ module RuboCop
MSG = 'Use `describe` for testing methods.' MSG = 'Use `describe` for testing methods.'
# @!method context_method(node)
def_node_matcher :context_method, <<-PATTERN def_node_matcher :context_method, <<-PATTERN
(block (send #rspec? :context $(str #method_name?) ...) ...) (block (send #rspec? :context $(str #method_name?) ...) ...)
PATTERN PATTERN

View File

@ -8,6 +8,7 @@ module RuboCop
# The default list of prefixes is minimal. Users are encouraged to tailor # The default list of prefixes is minimal. Users are encouraged to tailor
# the configuration to meet project needs. Other acceptable prefixes may # the configuration to meet project needs. Other acceptable prefixes may
# include `if`, `unless`, `for`, `before`, `after`, or `during`. # include `if`, `unless`, `for`, `before`, `after`, or `during`.
# They may consist of multiple words if desired.
# #
# @see https://rspec.rubystyle.guide/#context-descriptions # @see https://rspec.rubystyle.guide/#context-descriptions
# @see http://www.betterspecs.org/#contexts # @see http://www.betterspecs.org/#contexts
@ -37,6 +38,7 @@ module RuboCop
class ContextWording < Base class ContextWording < Base
MSG = 'Start context description with %<prefixes>s.' MSG = 'Start context description with %<prefixes>s.'
# @!method context_wording(node)
def_node_matcher :context_wording, <<-PATTERN def_node_matcher :context_wording, <<-PATTERN
(block (send #rspec? { :context :shared_context } $(str #bad_prefix?) ...) ...) (block (send #rspec? { :context :shared_context } $(str #bad_prefix?) ...) ...)
PATTERN PATTERN
@ -51,7 +53,7 @@ module RuboCop
private private
def bad_prefix?(description) def bad_prefix?(description)
!prefixes.include?(description.split(/\b/).first) !prefix_regex.match?(description)
end end
def joined_prefixes def joined_prefixes
@ -65,6 +67,10 @@ module RuboCop
def prefixes def prefixes
cop_config['Prefixes'] || [] cop_config['Prefixes'] || []
end end
def prefix_regex
/^#{Regexp.union(prefixes)}\b/
end
end end
end end
end end

View File

@ -40,14 +40,17 @@ module RuboCop
MSG = 'The first argument to describe should be ' \ MSG = 'The first argument to describe should be ' \
'the class or module being tested.' 'the class or module being tested.'
# @!method example_group_with_ignored_metadata?(node)
def_node_matcher :example_group_with_ignored_metadata?, <<~PATTERN def_node_matcher :example_group_with_ignored_metadata?, <<~PATTERN
(send #rspec? :describe ... (hash <#ignored_metadata? ...>)) (send #rspec? :describe ... (hash <#ignored_metadata? ...>))
PATTERN PATTERN
# @!method not_a_const_described(node)
def_node_matcher :not_a_const_described, <<~PATTERN def_node_matcher :not_a_const_described, <<~PATTERN
(send #rspec? :describe $[!const !#string_constant?] ...) (send #rspec? :describe $[!const !#string_constant?] ...)
PATTERN PATTERN
# @!method sym_pair(node)
def_node_matcher :sym_pair, <<~PATTERN def_node_matcher :sym_pair, <<~PATTERN
(pair $sym $sym) (pair $sym $sym)
PATTERN PATTERN

View File

@ -22,6 +22,7 @@ module RuboCop
MSG = 'The second argument to describe should be the method ' \ MSG = 'The second argument to describe should be the method ' \
"being tested. '#instance' or '.class'." "being tested. '#instance' or '.class'."
# @!method second_argument(node)
def_node_matcher :second_argument, <<~PATTERN def_node_matcher :second_argument, <<~PATTERN
(block (block
(send #rspec? :describe _first_argument $(str _) ...) ... (send #rspec? :describe _first_argument $(str _) ...) ...

View File

@ -21,6 +21,7 @@ module RuboCop
MSG = 'Avoid describing symbols.' MSG = 'Avoid describing symbols.'
RESTRICT_ON_SEND = %i[describe].freeze RESTRICT_ON_SEND = %i[describe].freeze
# @!method describe_symbol?(node)
def_node_matcher :describe_symbol?, <<-PATTERN def_node_matcher :describe_symbol?, <<-PATTERN
(send #rspec? :describe $sym ...) (send #rspec? :describe $sym ...)
PATTERN PATTERN

View File

@ -61,18 +61,23 @@ module RuboCop
DESCRIBED_CLASS = 'described_class' DESCRIBED_CLASS = 'described_class'
MSG = 'Use `%<replacement>s` instead of `%<src>s`.' MSG = 'Use `%<replacement>s` instead of `%<src>s`.'
# @!method common_instance_exec_closure?(node)
def_node_matcher :common_instance_exec_closure?, <<-PATTERN def_node_matcher :common_instance_exec_closure?, <<-PATTERN
(block (send (const nil? {:Class :Module :Struct}) :new ...) ...) (block (send (const nil? {:Class :Module :Struct}) :new ...) ...)
PATTERN PATTERN
# @!method rspec_block?(node)
def_node_matcher :rspec_block?, block_pattern('#ALL.all') def_node_matcher :rspec_block?, block_pattern('#ALL.all')
# @!method scope_changing_syntax?(node)
def_node_matcher :scope_changing_syntax?, '{def class module}' def_node_matcher :scope_changing_syntax?, '{def class module}'
# @!method described_constant(node)
def_node_matcher :described_constant, <<-PATTERN def_node_matcher :described_constant, <<-PATTERN
(block (send _ :describe $(const ...) ...) (args) $_) (block (send _ :describe $(const ...) ...) (args) $_)
PATTERN PATTERN
# @!method contains_described_class?(node)
def_node_search :contains_described_class?, <<-PATTERN def_node_search :contains_described_class?, <<-PATTERN
(send nil? :described_class) (send nil? :described_class)
PATTERN PATTERN

View File

@ -18,10 +18,11 @@ module RuboCop
# # ... # # ...
# end # end
# #
# @see https://github.com/rubocop-hq/rubocop-rspec/issues/735 # @see https://github.com/rubocop/rubocop-rspec/issues/735
class DescribedClassModuleWrapping < Base class DescribedClassModuleWrapping < Base
MSG = 'Avoid opening modules and defining specs within them.' MSG = 'Avoid opening modules and defining specs within them.'
# @!method find_rspec_blocks(node)
def_node_search :find_rspec_blocks, block_pattern('#ExampleGroups.all') def_node_search :find_rspec_blocks, block_pattern('#ExampleGroups.all')
def on_module(node) def on_module(node)

View File

@ -47,6 +47,7 @@ module RuboCop
MSG = 'Prefer `%<prefer>s` over `%<current>s`.' MSG = 'Prefer `%<prefer>s` over `%<current>s`.'
# @!method rspec_method?(node)
def_node_matcher :rspec_method?, send_pattern('#ALL.all') def_node_matcher :rspec_method?, send_pattern('#ALL.all')
def on_send(node) def on_send(node)

View File

@ -28,6 +28,7 @@ module RuboCop
MSG = 'Empty hook detected.' MSG = 'Empty hook detected.'
# @!method empty_hook?(node)
def_node_matcher :empty_hook?, <<~PATTERN def_node_matcher :empty_hook?, <<~PATTERN
(block $#{send_pattern('#Hooks.all')} _ nil?) (block $#{send_pattern('#Hooks.all')} _ nil?)
PATTERN PATTERN

View File

@ -25,29 +25,43 @@ module RuboCop
# result = service.call # result = service.call
# expect(result).to be(true) # expect(result).to be(true)
# end # end
#
# You can set literals you want to fold with `CountAsOne`.
# Available are: 'array', 'hash', and 'heredoc'. Each literal
# will be counted as one line regardless of its actual size.
#
# @example CountAsOne: ['array', 'heredoc']
#
# it do
# array = [ # +1
# 1,
# 2
# ]
#
# hash = { # +3
# key: 'value'
# }
#
# msg = <<~HEREDOC # +1
# Heredoc
# content.
# HEREDOC
# end # 5 points
class ExampleLength < Base class ExampleLength < Base
include CodeLength include CodeLength
MSG = 'Example has too many lines [%<total>d/%<max>d].' LABEL = 'Example'
def on_block(node) def on_block(node)
return unless example?(node) return unless example?(node)
length = code_length(node) check_code_length(node)
return unless length > max_length
add_offense(node, message: message(length))
end end
private private
def code_length(node) def cop_label
node.source.lines[1..-2].count { |line| !irrelevant_line(line) } LABEL
end
def message(length)
format(MSG, total: length, max: max_length)
end end
end end
end end

View File

@ -54,6 +54,7 @@ module RuboCop
'have auto-generated description.' 'have auto-generated description.'
MSG_ADD_DESCRIPTION = 'Add a description.' MSG_ADD_DESCRIPTION = 'Add a description.'
# @!method example_description(node)
def_node_matcher :example_description, '(send nil? _ $(str $_))' def_node_matcher :example_description, '(send nil? _ $(str $_))'
def on_block(node) def on_block(node)

View File

@ -38,6 +38,7 @@ module RuboCop
SHOULD_PREFIX = /\Ashould(?:n't)?\b/i.freeze SHOULD_PREFIX = /\Ashould(?:n't)?\b/i.freeze
IT_PREFIX = /\Ait /i.freeze IT_PREFIX = /\Ait /i.freeze
# @!method it_description(node)
def_node_matcher :it_description, <<-PATTERN def_node_matcher :it_description, <<-PATTERN
(block (send _ :it ${ (block (send _ :it ${
(str $_) (str $_)

View File

@ -45,6 +45,7 @@ module RuboCop
SUPPORTED_MATCHERS = %i[eq eql equal be].freeze SUPPORTED_MATCHERS = %i[eq eql equal be].freeze
# @!method expect_literal(node)
def_node_matcher :expect_literal, <<~PATTERN def_node_matcher :expect_literal, <<~PATTERN
(send (send
(send nil? :expect $#literal?) (send nil? :expect $#literal?)

View File

@ -37,10 +37,12 @@ module RuboCop
MSG_CALL = 'Prefer `change { %<obj>s.%<attr>s }`.' MSG_CALL = 'Prefer `change { %<obj>s.%<attr>s }`.'
RESTRICT_ON_SEND = %i[change].freeze RESTRICT_ON_SEND = %i[change].freeze
# @!method expect_change_with_arguments(node)
def_node_matcher :expect_change_with_arguments, <<-PATTERN def_node_matcher :expect_change_with_arguments, <<-PATTERN
(send nil? :change ({const send} nil? $_) (sym $_)) (send nil? :change ({const send} nil? $_) (sym $_))
PATTERN PATTERN
# @!method expect_change_with_block(node)
def_node_matcher :expect_change_with_block, <<-PATTERN def_node_matcher :expect_change_with_block, <<-PATTERN
(block (block
(send nil? :change) (send nil? :change)

View File

@ -23,6 +23,7 @@ module RuboCop
class ExpectInHook < Base class ExpectInHook < Base
MSG = 'Do not use `%<expect>s` in `%<hook>s` hook' MSG = 'Do not use `%<expect>s` in `%<hook>s` hook'
# @!method expectation(node)
def_node_search :expectation, send_pattern('#Expectations.all') def_node_search :expectation, send_pattern('#Expectations.all')
def on_block(node) def on_block(node)

View File

@ -29,10 +29,12 @@ module RuboCop
MSG = 'Use a block to declare attribute values.' MSG = 'Use a block to declare attribute values.'
# @!method value_matcher(node)
def_node_matcher :value_matcher, <<-PATTERN def_node_matcher :value_matcher, <<-PATTERN
(send _ !#reserved_method? $...) (send _ !#reserved_method? $...)
PATTERN PATTERN
# @!method factory_attributes(node)
def_node_matcher :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
@ -79,6 +81,7 @@ module RuboCop
value_matcher(attribute).to_a.all?(&:block_pass_type?) value_matcher(attribute).to_a.all?(&:block_pass_type?)
end end
# @!method association?(node)
def_node_matcher :association?, '(hash <(pair (sym :factory) _) ...>)' def_node_matcher :association?, '(hash <(pair (sym :factory) _) ...>)'
def autocorrect_replacing_parens(corrector, node) def autocorrect_replacing_parens(corrector, node)

View File

@ -32,6 +32,7 @@ module RuboCop
MSG_N_TIMES = 'Prefer %<number>s.times.' MSG_N_TIMES = 'Prefer %<number>s.times.'
RESTRICT_ON_SEND = %i[create_list].freeze RESTRICT_ON_SEND = %i[create_list].freeze
# @!method n_times_block_without_arg?(node)
def_node_matcher :n_times_block_without_arg?, <<-PATTERN def_node_matcher :n_times_block_without_arg?, <<-PATTERN
(block (block
(send (int _) :times) (send (int _) :times)
@ -40,10 +41,12 @@ module RuboCop
) )
PATTERN PATTERN
# @!method factory_call(node)
def_node_matcher :factory_call, <<-PATTERN def_node_matcher :factory_call, <<-PATTERN
(send ${(const nil? {:FactoryGirl :FactoryBot}) nil?} :create (sym $_) $...) (send ${(const nil? {:FactoryGirl :FactoryBot}) nil?} :create (sym $_) $...)
PATTERN PATTERN
# @!method factory_list_call(node)
def_node_matcher :factory_list_call, <<-PATTERN def_node_matcher :factory_list_call, <<-PATTERN
(send {(const nil? {:FactoryGirl :FactoryBot}) nil?} :create_list (sym _) (int $_) ...) (send {(const nil? {:FactoryGirl :FactoryBot}) nil?} :create_list (sym _) (int $_) ...)
PATTERN PATTERN

View File

@ -27,6 +27,7 @@ module RuboCop
ALLOWED_CONSTANTS = %w[Hash OpenStruct].freeze ALLOWED_CONSTANTS = %w[Hash OpenStruct].freeze
RESTRICT_ON_SEND = %i[factory].freeze RESTRICT_ON_SEND = %i[factory].freeze
# @!method class_name(node)
def_node_matcher :class_name, <<~PATTERN def_node_matcher :class_name, <<~PATTERN
(send _ :factory _ (hash <(pair (sym :class) $(const ...)) ...>)) (send _ :factory _ (hash <(pair (sym :class) $(const ...)) ...>))
PATTERN PATTERN

View File

@ -61,12 +61,14 @@ module RuboCop
MSG = 'Spec path should end with `%<suffix>s`.' MSG = 'Spec path should end with `%<suffix>s`.'
# @!method const_described(node)
def_node_matcher :const_described, <<~PATTERN def_node_matcher :const_described, <<~PATTERN
(block (block
$(send #rspec? _example_group $(const ...) $...) ... $(send #rspec? _example_group $(const ...) $...) ...
) )
PATTERN PATTERN
# @!method routing_metadata?(node)
def_node_search :routing_metadata?, '(pair (sym :type) (sym :routing))' def_node_search :routing_metadata?, '(pair (sym :type) (sym :routing))'
def on_top_level_example_group(node) def on_top_level_example_group(node)

View File

@ -25,6 +25,7 @@ module RuboCop
MSG = 'Focused spec found.' MSG = 'Focused spec found.'
# @!method focusable_selector?(node)
def_node_matcher :focusable_selector?, <<-PATTERN def_node_matcher :focusable_selector?, <<-PATTERN
{ {
#ExampleGroups.regular #ExampleGroups.regular
@ -35,11 +36,13 @@ module RuboCop
} }
PATTERN PATTERN
# @!method metadata(node)
def_node_matcher :metadata, <<-PATTERN def_node_matcher :metadata, <<-PATTERN
{(send #rspec? #focusable_selector? <$(sym :focus) ...>) {(send #rspec? #focusable_selector? <$(sym :focus) ...>)
(send #rspec? #focusable_selector? ... (hash <$(pair (sym :focus) true) ...>))} (send #rspec? #focusable_selector? ... (hash <$(pair (sym :focus) true) ...>))}
PATTERN PATTERN
# @!method focused_block?(node)
def_node_matcher :focused_block?, def_node_matcher :focused_block?,
send_pattern(<<~PATTERN) send_pattern(<<~PATTERN)
{#ExampleGroups.focused #Examples.focused} {#ExampleGroups.focused #Examples.focused}

View File

@ -64,10 +64,12 @@ module RuboCop
IMPLICIT_MSG = 'Omit the default `%<scope>p` argument for RSpec hooks.' IMPLICIT_MSG = 'Omit the default `%<scope>p` argument for RSpec hooks.'
EXPLICIT_MSG = 'Use `%<scope>p` for RSpec hooks.' EXPLICIT_MSG = 'Use `%<scope>p` for RSpec hooks.'
# @!method scoped_hook(node)
def_node_matcher :scoped_hook, <<-PATTERN def_node_matcher :scoped_hook, <<-PATTERN
(block $(send _ #Hooks.all (sym ${:each :example})) ...) (block $(send _ #Hooks.all (sym ${:each :example})) ...)
PATTERN PATTERN
# @!method unscoped_hook(node)
def_node_matcher :unscoped_hook, '(block $(send _ #Hooks.all) ...)' def_node_matcher :unscoped_hook, '(block $(send _ #Hooks.all) ...)'
def on_block(node) def on_block(node)

View File

@ -28,6 +28,7 @@ module RuboCop
MSG = 'Move `%<hook>s` above the examples in the group.' MSG = 'Move `%<hook>s` above the examples in the group.'
# @!method example_or_group?(node)
def_node_matcher :example_or_group?, <<-PATTERN def_node_matcher :example_or_group?, <<-PATTERN
{ {
#{block_pattern('{#ExampleGroups.all #Examples.all}')} #{block_pattern('{#ExampleGroups.all #Examples.all}')}

View File

@ -20,6 +20,7 @@ module RuboCop
MSG = 'Avoid implicit block expectations.' MSG = 'Avoid implicit block expectations.'
RESTRICT_ON_SEND = %i[is_expected should should_not].freeze RESTRICT_ON_SEND = %i[is_expected should should_not].freeze
# @!method lambda?(node)
def_node_matcher :lambda?, <<-PATTERN def_node_matcher :lambda?, <<-PATTERN
{ {
(send (const nil? :Proc) :new) (send (const nil? :Proc) :new)
@ -27,8 +28,10 @@ module RuboCop
} }
PATTERN PATTERN
# @!method lambda_subject?(node)
def_node_matcher :lambda_subject?, '(block #lambda? ...)' def_node_matcher :lambda_subject?, '(block #lambda? ...)'
# @!method implicit_expect(node)
def_node_matcher :implicit_expect, <<-PATTERN def_node_matcher :implicit_expect, <<-PATTERN
$(send nil? {:is_expected :should :should_not} ...) $(send nil? {:is_expected :should :should_not} ...)
PATTERN PATTERN

View File

@ -30,6 +30,7 @@ module RuboCop
MSG = 'Prefer `%<good>s` over `%<bad>s`.' MSG = 'Prefer `%<good>s` over `%<bad>s`.'
# @!method implicit_expect(node)
def_node_matcher :implicit_expect, <<-PATTERN def_node_matcher :implicit_expect, <<-PATTERN
{ {
(send nil? ${:should :should_not} ...) (send nil? ${:should :should_not} ...)

View File

@ -33,6 +33,7 @@ module RuboCop
MSG = "Don't use implicit subject." MSG = "Don't use implicit subject."
RESTRICT_ON_SEND = %i[is_expected should should_not].freeze RESTRICT_ON_SEND = %i[is_expected should should_not].freeze
# @!method implicit_subject?(node)
def_node_matcher :implicit_subject?, <<-PATTERN def_node_matcher :implicit_subject?, <<-PATTERN
(send nil? {:should :should_not :is_expected} ...) (send nil? {:should :should_not :is_expected} ...)
PATTERN PATTERN

View File

@ -24,6 +24,7 @@ module RuboCop
MSG = 'Use `instance_spy` when you check your double ' \ MSG = 'Use `instance_spy` when you check your double ' \
'with `have_received`.' 'with `have_received`.'
# @!method null_double(node)
def_node_search :null_double, <<-PATTERN def_node_search :null_double, <<-PATTERN
(lvasgn $_ (lvasgn $_
(send (send
@ -31,6 +32,7 @@ module RuboCop
...) :as_null_object)) ...) :as_null_object))
PATTERN PATTERN
# @!method have_received_usage(node)
def_node_search :have_received_usage, <<-PATTERN def_node_search :have_received_usage, <<-PATTERN
(send (send
(send nil? :expect (send nil? :expect

View File

@ -52,10 +52,12 @@ module RuboCop
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).'
# @!method dynamic_class?(node)
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
# @!method custom_matcher?(node)
def_node_matcher :custom_matcher?, <<-PATTERN def_node_matcher :custom_matcher?, <<-PATTERN
(block { (block {
(send nil? :matcher sym) (send nil? :matcher sym)
@ -63,8 +65,10 @@ module RuboCop
} ...) } ...)
PATTERN PATTERN
# @!method ivar_usage(node)
def_node_search :ivar_usage, '$(ivar $_)' def_node_search :ivar_usage, '$(ivar $_)'
# @!method ivar_assigned?(node)
def_node_search :ivar_assigned?, '(ivasgn % ...)' def_node_search :ivar_assigned?, '(ivasgn % ...)'
def on_top_level_group(node) def on_top_level_group(node)

View File

@ -26,6 +26,7 @@ module RuboCop
'examples in a nested context.' 'examples in a nested context.'
RESTRICT_ON_SEND = %i[it_behaves_like it_should_behave_like].freeze RESTRICT_ON_SEND = %i[it_behaves_like it_should_behave_like].freeze
# @!method example_inclusion_offense(node)
def_node_matcher :example_inclusion_offense, '(send _ % ...)' def_node_matcher :example_inclusion_offense, '(send _ % ...)'
def on_send(node) def on_send(node)

View File

@ -19,6 +19,7 @@ module RuboCop
MSG = 'Prefer using the `all` matcher instead ' \ MSG = 'Prefer using the `all` matcher instead ' \
'of iterating over an array.' 'of iterating over an array.'
# @!method each?(node)
def_node_matcher :each?, <<-PATTERN def_node_matcher :each?, <<-PATTERN
(block (block
(send ... :each) (send ... :each)
@ -27,6 +28,7 @@ module RuboCop
) )
PATTERN PATTERN
# @!method expectation?(node)
def_node_matcher :expectation?, <<-PATTERN def_node_matcher :expectation?, <<-PATTERN
(send (send nil? :expect (lvar %)) :to ...) (send (send nil? :expect (lvar %)) :to ...)
PATTERN PATTERN

View File

@ -35,6 +35,7 @@ module RuboCop
MSG = 'Move `let` before the examples in the group.' MSG = 'Move `let` before the examples in the group.'
# @!method example_or_group?(node)
def_node_matcher :example_or_group?, <<-PATTERN def_node_matcher :example_or_group?, <<-PATTERN
{ {
#{block_pattern('{#ExampleGroups.all #Examples.all}')} #{block_pattern('{#ExampleGroups.all #Examples.all}')}

View File

@ -28,6 +28,7 @@ module RuboCop
class LetSetup < Base class LetSetup < Base
MSG = 'Do not use `let!` to setup objects not referenced in tests.' MSG = 'Do not use `let!` to setup objects not referenced in tests.'
# @!method example_or_shared_group_or_including?(node)
def_node_matcher :example_or_shared_group_or_including?, def_node_matcher :example_or_shared_group_or_including?,
block_pattern(<<~PATTERN) block_pattern(<<~PATTERN)
{ {
@ -37,6 +38,7 @@ module RuboCop
} }
PATTERN PATTERN
# @!method let_bang(node)
def_node_matcher :let_bang, <<-PATTERN def_node_matcher :let_bang, <<-PATTERN
{ {
(block $(send nil? :let! {(sym $_) (str $_)}) ...) (block $(send nil? :let! {(sym $_) (str $_)}) ...)
@ -44,6 +46,7 @@ module RuboCop
} }
PATTERN PATTERN
# @!method method_called?(node)
def_node_search :method_called?, '(send nil? %)' def_node_search :method_called?, '(send nil? %)'
def on_block(node) def on_block(node)

View File

@ -32,10 +32,12 @@ module RuboCop
SUPPORTED_STYLES = %w[allow expect].freeze SUPPORTED_STYLES = %w[allow expect].freeze
RESTRICT_ON_SEND = %i[to].freeze RESTRICT_ON_SEND = %i[to].freeze
# @!method message_expectation(node)
def_node_matcher :message_expectation, <<-PATTERN def_node_matcher :message_expectation, <<-PATTERN
(send $(send nil? {:expect :allow} ...) :to #receive_message?) (send $(send nil? {:expect :allow} ...) :to #receive_message?)
PATTERN PATTERN
# @!method receive_message?(node)
def_node_search :receive_message?, '(send nil? :receive ...)' def_node_search :receive_message?, '(send nil? :receive ...)'
def on_send(node) def on_send(node)

View File

@ -35,10 +35,12 @@ module RuboCop
SUPPORTED_STYLES = %w[have_received receive].freeze SUPPORTED_STYLES = %w[have_received receive].freeze
# @!method message_expectation(node)
def_node_matcher :message_expectation, %( def_node_matcher :message_expectation, %(
(send (send nil? :expect $_) #Runners.all ...) (send (send nil? :expect $_) #Runners.all ...)
) )
# @!method receive_message(node)
def_node_search :receive_message, %( def_node_search :receive_message, %(
$(send nil? {:receive :have_received} ...) $(send nil? {:receive :have_received} ...)
) )

View File

@ -10,6 +10,7 @@ module RuboCop
Subjects = RuboCop::RSpec::Language::Subjects Subjects = RuboCop::RSpec::Language::Subjects
Helpers = RuboCop::RSpec::Language::Helpers Helpers = RuboCop::RSpec::Language::Helpers
# @!method variable_definition?(node)
def_node_matcher :variable_definition?, <<~PATTERN def_node_matcher :variable_definition?, <<~PATTERN
(send nil? {#Subjects.all #Helpers.all} (send nil? {#Subjects.all #Helpers.all}
$({sym str dsym dstr} ...) ...) $({sym str dsym dstr} ...) ...)

View File

@ -53,6 +53,7 @@ module RuboCop
ANYTHING = ->(_node) { true } ANYTHING = ->(_node) { true }
TRUE = ->(node) { node.true_type? } TRUE = ->(node) { node.true_type? }
# @!method aggregate_failures?(node)
def_node_matcher :aggregate_failures?, <<-PATTERN def_node_matcher :aggregate_failures?, <<-PATTERN
(block { (block {
(send _ _ <(sym :aggregate_failures) ...>) (send _ _ <(sym :aggregate_failures) ...>)
@ -60,7 +61,9 @@ module RuboCop
} ...) } ...)
PATTERN PATTERN
# @!method expect?(node)
def_node_matcher :expect?, send_pattern('#Expectations.all') def_node_matcher :expect?, send_pattern('#Expectations.all')
# @!method aggregate_failures_block?(node)
def_node_matcher :aggregate_failures_block?, <<-PATTERN def_node_matcher :aggregate_failures_block?, <<-PATTERN
(block (send nil? :aggregate_failures ...) ...) (block (send nil? :aggregate_failures ...) ...)
PATTERN PATTERN

View File

@ -44,12 +44,15 @@ module RuboCop
class NamedSubject < Base class NamedSubject < Base
MSG = 'Name your test subject if you need to reference it explicitly.' MSG = 'Name your test subject if you need to reference it explicitly.'
# @!method example_or_hook_block?(node)
def_node_matcher :example_or_hook_block?, def_node_matcher :example_or_hook_block?,
block_pattern('{#Examples.all #Hooks.all}') block_pattern('{#Examples.all #Hooks.all}')
# @!method shared_example?(node)
def_node_matcher :shared_example?, def_node_matcher :shared_example?,
block_pattern('#SharedGroups.examples') block_pattern('#SharedGroups.examples')
# @!method subject_usage(node)
def_node_search :subject_usage, '$(send nil? :subject)' def_node_search :subject_usage, '$(send nil? :subject)'
def on_block(node) def on_block(node)

View File

@ -22,6 +22,7 @@ module RuboCop
MSG = 'Prefer `%<replacement>s` over `%<original>s`.' MSG = 'Prefer `%<replacement>s` over `%<original>s`.'
RESTRICT_ON_SEND = %i[not_to to_not].freeze RESTRICT_ON_SEND = %i[not_to to_not].freeze
# @!method not_to_not_offense(node)
def_node_matcher :not_to_not_offense, '(send _ % ...)' def_node_matcher :not_to_not_offense, '(send _ % ...)'
def on_send(node) def on_send(node)

View File

@ -24,8 +24,10 @@ module RuboCop
class OverwritingSetup < Base class OverwritingSetup < Base
MSG = '`%<name>s` is already defined.' MSG = '`%<name>s` is already defined.'
# @!method setup?(node)
def_node_matcher :setup?, block_pattern('{#Helpers.all #Subjects.all}') def_node_matcher :setup?, block_pattern('{#Helpers.all #Subjects.all}')
# @!method first_argument_name(node)
def_node_matcher :first_argument_name, '(send _ _ ({str sym} $_))' def_node_matcher :first_argument_name, '(send _ _ ({str sym} $_))'
def on_block(node) def on_block(node)

View File

@ -34,11 +34,13 @@ module RuboCop
class Pending < Base class Pending < Base
MSG = 'Pending spec found.' MSG = 'Pending spec found.'
# @!method skippable?(node)
def_node_matcher :skippable?, def_node_matcher :skippable?,
send_pattern(<<~PATTERN) send_pattern(<<~PATTERN)
{#ExampleGroups.regular #Examples.regular} {#ExampleGroups.regular #Examples.regular}
PATTERN PATTERN
# @!method skipped_in_metadata?(node)
def_node_matcher :skipped_in_metadata?, <<-PATTERN def_node_matcher :skipped_in_metadata?, <<-PATTERN
{ {
(send _ _ <#skip_or_pending? ...>) (send _ _ <#skip_or_pending? ...>)
@ -46,8 +48,10 @@ module RuboCop
} }
PATTERN PATTERN
# @!method skip_or_pending?(node)
def_node_matcher :skip_or_pending?, '{(sym :skip) (sym :pending)}' def_node_matcher :skip_or_pending?, '{(sym :skip) (sym :pending)}'
# @!method pending_block?(node)
def_node_matcher :pending_block?, def_node_matcher :pending_block?,
send_pattern(<<~PATTERN) send_pattern(<<~PATTERN)
{ {

View File

@ -25,6 +25,7 @@ module RuboCop
end end
end end
# @!method predicate_in_actual?(node)
def_node_matcher :predicate_in_actual?, <<-PATTERN def_node_matcher :predicate_in_actual?, <<-PATTERN
(send (send
(send nil? :expect { (send nil? :expect {
@ -34,10 +35,12 @@ module RuboCop
$#boolean_matcher?) $#boolean_matcher?)
PATTERN PATTERN
# @!method be_bool?(node)
def_node_matcher :be_bool?, <<-PATTERN def_node_matcher :be_bool?, <<-PATTERN
(send nil? {:be :eq :eql :equal} {true false}) (send nil? {:be :eq :eql :equal} {true false})
PATTERN PATTERN
# @!method be_boolthy?(node)
def_node_matcher :be_boolthy?, <<-PATTERN def_node_matcher :be_boolthy?, <<-PATTERN
(send nil? {:be_truthy :be_falsey :be_falsy :a_truthy_value :a_falsey_value :a_falsy_value}) (send nil? {:be_truthy :be_falsey :be_falsy :a_truthy_value :a_falsey_value :a_falsy_value})
PATTERN PATTERN
@ -152,6 +155,7 @@ module RuboCop
end end
end end
# @!method predicate_matcher?(node)
def_node_matcher :predicate_matcher?, <<-PATTERN def_node_matcher :predicate_matcher?, <<-PATTERN
(send (send
(send nil? :expect $!nil?) (send nil? :expect $!nil?)
@ -160,6 +164,7 @@ module RuboCop
(block $(send nil? #predicate_matcher_name? ...) ...)}) (block $(send nil? #predicate_matcher_name? ...) ...)})
PATTERN PATTERN
# @!method predicate_matcher_block?(node)
def_node_matcher :predicate_matcher_block?, <<-PATTERN def_node_matcher :predicate_matcher_block?, <<-PATTERN
(block (block
(send (send

View File

@ -35,6 +35,7 @@ module RuboCop
include ConfigurableEnforcedStyle include ConfigurableEnforcedStyle
RESTRICT_ON_SEND = %i[have_http_status].freeze RESTRICT_ON_SEND = %i[have_http_status].freeze
# @!method http_status(node)
def_node_matcher :http_status, <<-PATTERN def_node_matcher :http_status, <<-PATTERN
(send nil? :have_http_status ${int sym}) (send nil? :have_http_status ${int sym})
PATTERN PATTERN

View File

@ -30,10 +30,12 @@ module RuboCop
RESTRICT_ON_SEND = %i[times].freeze RESTRICT_ON_SEND = %i[times].freeze
# @!method receive_counts(node)
def_node_matcher :receive_counts, <<-PATTERN def_node_matcher :receive_counts, <<-PATTERN
(send $(send _ {:exactly :at_least :at_most} (int {1 2})) :times) (send $(send _ {:exactly :at_least :at_most} (int {1 2})) :times)
PATTERN PATTERN
# @!method stub?(node)
def_node_search :stub?, '(send nil? :receive ...)' def_node_search :stub?, '(send nil? :receive ...)'
def on_send(node) def on_send(node)

View File

@ -18,6 +18,7 @@ module RuboCop
MSG = 'Use `not_to receive` instead of `never`.' MSG = 'Use `not_to receive` instead of `never`.'
RESTRICT_ON_SEND = %i[never].freeze RESTRICT_ON_SEND = %i[never].freeze
# @!method method_on_stub?(node)
def_node_search :method_on_stub?, '(send nil? :receive ...)' def_node_search :method_on_stub?, '(send nil? :receive ...)'
def on_send(node) def on_send(node)

View File

@ -46,16 +46,23 @@ module RuboCop
class RepeatedExampleGroupBody < Base class RepeatedExampleGroupBody < Base
MSG = 'Repeated %<group>s block body on line(s) %<loc>s' MSG = 'Repeated %<group>s block body on line(s) %<loc>s'
# @!method several_example_groups?(node)
def_node_matcher :several_example_groups?, <<-PATTERN def_node_matcher :several_example_groups?, <<-PATTERN
(begin <#example_group_with_body? #example_group_with_body? ...>) (begin <#example_group_with_body? #example_group_with_body? ...>)
PATTERN PATTERN
# @!method metadata(node)
def_node_matcher :metadata, '(block (send _ _ _ $...) ...)' def_node_matcher :metadata, '(block (send _ _ _ $...) ...)'
# @!method body(node)
def_node_matcher :body, '(block _ args $...)' def_node_matcher :body, '(block _ args $...)'
# @!method const_arg(node)
def_node_matcher :const_arg, '(block (send _ _ $const ...) ...)' def_node_matcher :const_arg, '(block (send _ _ $const ...) ...)'
# @!method skip_or_pending?(node)
def_node_matcher :skip_or_pending?, <<-PATTERN def_node_matcher :skip_or_pending?, <<-PATTERN
(block <(send nil? {:skip :pending}) ...>) (block <(send nil? {:skip :pending} ...) ...>)
PATTERN PATTERN
def on_begin(node) def on_begin(node)

View File

@ -46,18 +46,22 @@ module RuboCop
class RepeatedExampleGroupDescription < Base class RepeatedExampleGroupDescription < Base
MSG = 'Repeated %<group>s block description on line(s) %<loc>s' MSG = 'Repeated %<group>s block description on line(s) %<loc>s'
# @!method several_example_groups?(node)
def_node_matcher :several_example_groups?, <<-PATTERN def_node_matcher :several_example_groups?, <<-PATTERN
(begin <#example_group? #example_group? ...>) (begin <#example_group? #example_group? ...>)
PATTERN PATTERN
# @!method doc_string_and_metadata(node)
def_node_matcher :doc_string_and_metadata, <<-PATTERN def_node_matcher :doc_string_and_metadata, <<-PATTERN
(block (send _ _ $_ $...) ...) (block (send _ _ $_ $...) ...)
PATTERN PATTERN
# @!method skip_or_pending?(node)
def_node_matcher :skip_or_pending?, <<-PATTERN def_node_matcher :skip_or_pending?, <<-PATTERN
(block <(send nil? {:skip :pending}) ...>) (block <(send nil? {:skip :pending}) ...>)
PATTERN PATTERN
# @!method empty_description?(node)
def_node_matcher :empty_description?, '(block (send _ _) ...)' def_node_matcher :empty_description?, '(block (send _ _) ...)'
def on_begin(node) def on_begin(node)

View File

@ -50,13 +50,16 @@ module RuboCop
MSG = 'Repeated include of shared_examples %<name>s ' \ MSG = 'Repeated include of shared_examples %<name>s ' \
'on line(s) %<repeat>s' 'on line(s) %<repeat>s'
# @!method several_include_examples?(node)
def_node_matcher :several_include_examples?, <<-PATTERN def_node_matcher :several_include_examples?, <<-PATTERN
(begin <#include_examples? #include_examples? ...>) (begin <#include_examples? #include_examples? ...>)
PATTERN PATTERN
# @!method include_examples?(node)
def_node_matcher :include_examples?, def_node_matcher :include_examples?,
send_pattern('#Includes.examples') send_pattern('#Includes.examples')
# @!method shared_examples_name(node)
def_node_matcher :shared_examples_name, <<-PATTERN def_node_matcher :shared_examples_name, <<-PATTERN
(send _ #Includes.examples $_ ...) (send _ #Includes.examples $_ ...)
PATTERN PATTERN

View File

@ -41,8 +41,13 @@ module RuboCop
MSG_BLOCK = 'Use block for static values.' MSG_BLOCK = 'Use block for static values.'
RESTRICT_ON_SEND = %i[and_return].freeze RESTRICT_ON_SEND = %i[and_return].freeze
# @!method contains_stub?(node)
def_node_search :contains_stub?, '(send nil? :receive (...))' def_node_search :contains_stub?, '(send nil? :receive (...))'
# @!method stub_with_block?(node)
def_node_matcher :stub_with_block?, '(block #contains_stub? ...)' def_node_matcher :stub_with_block?, '(block #contains_stub? ...)'
# @!method and_return_value(node)
def_node_search :and_return_value, <<-PATTERN def_node_search :and_return_value, <<-PATTERN
$(send _ :and_return $(...)) $(send _ :and_return $(...))
PATTERN PATTERN

View File

@ -56,9 +56,11 @@ module RuboCop
MSG_EXAMPLES = "Use `shared_examples` when you don't define context." MSG_EXAMPLES = "Use `shared_examples` when you don't define context."
MSG_CONTEXT = "Use `shared_context` when you don't define examples." MSG_CONTEXT = "Use `shared_context` when you don't define examples."
# @!method examples?(node)
def_node_search :examples?, def_node_search :examples?,
send_pattern('{#Includes.examples #Examples.all}') send_pattern('{#Includes.examples #Examples.all}')
# @!method context?(node)
def_node_search :context?, <<-PATTERN def_node_search :context?, <<-PATTERN
( (
send #rspec? { send #rspec? {
@ -70,8 +72,10 @@ module RuboCop
) )
PATTERN PATTERN
# @!method shared_context(node)
def_node_matcher :shared_context, def_node_matcher :shared_context,
block_pattern('#SharedGroups.context') block_pattern('#SharedGroups.context')
# @!method shared_example(node)
def_node_matcher :shared_example, def_node_matcher :shared_example,
block_pattern('#SharedGroups.examples') block_pattern('#SharedGroups.examples')

View File

@ -23,6 +23,7 @@ module RuboCop
class SharedExamples < Base class SharedExamples < Base
extend AutoCorrector extend AutoCorrector
# @!method shared_examples(node)
def_node_matcher :shared_examples, def_node_matcher :shared_examples,
send_pattern( send_pattern(
'{#SharedGroups.all #Includes.all}' '{#SharedGroups.all #Includes.all}'

View File

@ -23,10 +23,12 @@ module RuboCop
'`%<called>s` with a single argument.' '`%<called>s` with a single argument.'
RESTRICT_ON_SEND = %i[receive_message_chain stub_chain].freeze RESTRICT_ON_SEND = %i[receive_message_chain stub_chain].freeze
# @!method message_chain(node)
def_node_matcher :message_chain, <<-PATTERN def_node_matcher :message_chain, <<-PATTERN
(send _ {:receive_message_chain :stub_chain} $_) (send _ {:receive_message_chain :stub_chain} $_)
PATTERN PATTERN
# @!method single_key_hash?(node)
def_node_matcher :single_key_hash?, '(hash pair)' def_node_matcher :single_key_hash?, '(hash pair)'
def on_send(node) def on_send(node)

View File

@ -39,6 +39,7 @@ module RuboCop
} }
PATTERN PATTERN
# @!method configured_response?(node)
def_node_matcher :configured_response?, <<~PATTERN def_node_matcher :configured_response?, <<~PATTERN
{ :and_return :and_raise :and_throw :and_yield { :and_return :and_raise :and_throw :and_yield
:and_call_original :and_wrap_original } :and_call_original :and_wrap_original }

View File

@ -81,6 +81,7 @@ module RuboCop
) )
PATTERN PATTERN
# @!method message_expectation_matcher?(node)
def_node_search :message_expectation_matcher?, <<-PATTERN def_node_search :message_expectation_matcher?, <<-PATTERN
(send nil? { (send nil? {
:receive :receive_messages :receive_message_chain :have_received :receive :receive_messages :receive_message_chain :have_received

View File

@ -34,6 +34,7 @@ module RuboCop
MSG = 'Specify the exception being captured' MSG = 'Specify the exception being captured'
RESTRICT_ON_SEND = %i[to].freeze RESTRICT_ON_SEND = %i[to].freeze
# @!method empty_raise_error_or_exception(node)
def_node_matcher :empty_raise_error_or_exception, <<-PATTERN def_node_matcher :empty_raise_error_or_exception, <<-PATTERN
(send (send
(block (block

View File

@ -26,6 +26,7 @@ module RuboCop
MSG = 'Prefer using verifying doubles over normal doubles.' MSG = 'Prefer using verifying doubles over normal doubles.'
RESTRICT_ON_SEND = %i[double spy].freeze RESTRICT_ON_SEND = %i[double spy].freeze
# @!method unverified_double(node)
def_node_matcher :unverified_double, <<-PATTERN def_node_matcher :unverified_double, <<-PATTERN
{(send nil? {:double :spy} $...)} {(send nil? {:double :spy} $...)}
PATTERN PATTERN

View File

@ -16,10 +16,12 @@ module RuboCop
'Chain the methods or remove it.' 'Chain the methods or remove it.'
RESTRICT_ON_SEND = %i[expect].freeze RESTRICT_ON_SEND = %i[expect].freeze
# @!method expect?(node)
def_node_matcher :expect?, <<-PATTERN def_node_matcher :expect?, <<-PATTERN
(send nil? :expect ...) (send nil? :expect ...)
PATTERN PATTERN
# @!method expect_block?(node)
def_node_matcher :expect_block?, <<-PATTERN def_node_matcher :expect_block?, <<-PATTERN
(block #expect? (args) _body) (block #expect? (args) _body)
PATTERN PATTERN

View File

@ -17,10 +17,13 @@ module RuboCop
MSG = 'Use `.and_yield`.' MSG = 'Use `.and_yield`.'
# @!method method_on_stub?(node)
def_node_search :method_on_stub?, '(send nil? :receive ...)' def_node_search :method_on_stub?, '(send nil? :receive ...)'
# @!method block_arg(node)
def_node_matcher :block_arg, '(args (blockarg $_))' def_node_matcher :block_arg, '(args (blockarg $_))'
# @!method block_call?(node)
def_node_matcher :block_call?, '(send (lvar %) :call ...)' def_node_matcher :block_call?, '(send (lvar %) :call ...)'
def on_block(node) def on_block(node)

Some files were not shown because too many files have changed in this diff Show More