Merge pull request #10495 from Homebrew/dependabot/bundler/Library/Homebrew/rubocop-rspec-2.2.0
build(deps): bump rubocop-rspec from 2.1.0 to 2.2.0 in /Library/Homebrew
This commit is contained in:
commit
dcf9d9368d
@ -126,7 +126,7 @@ GEM
|
||||
activesupport (>= 4.2.0)
|
||||
rack (>= 1.1)
|
||||
rubocop (>= 0.90.0, < 2.0)
|
||||
rubocop-rspec (2.1.0)
|
||||
rubocop-rspec (2.2.0)
|
||||
rubocop (~> 1.0)
|
||||
rubocop-ast (>= 1.1.0)
|
||||
rubocop-sorbet (0.5.1)
|
||||
|
||||
@ -82,12 +82,13 @@ end
|
||||
RuboCop::Cop::RSpec::AlignRightLetBrace::MSG = T.let(T.unsafe(nil), String)
|
||||
|
||||
class RuboCop::Cop::RSpec::AnyInstance < ::RuboCop::Cop::RSpec::Base
|
||||
def disallowed_stub(param0 = T.unsafe(nil)); end
|
||||
def on_send(node); end
|
||||
end
|
||||
|
||||
RuboCop::Cop::RSpec::AnyInstance::MSG = T.let(T.unsafe(nil), String)
|
||||
|
||||
RuboCop::Cop::RSpec::AnyInstance::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
|
||||
|
||||
class RuboCop::Cop::RSpec::AroundBlock < ::RuboCop::Cop::RSpec::Base
|
||||
def find_arg_usage(param0); end
|
||||
def hook(param0 = T.unsafe(nil)); end
|
||||
@ -130,6 +131,8 @@ end
|
||||
|
||||
RuboCop::Cop::RSpec::BeEql::MSG = T.let(T.unsafe(nil), String)
|
||||
|
||||
RuboCop::Cop::RSpec::BeEql::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
|
||||
|
||||
class RuboCop::Cop::RSpec::BeforeAfterAll < ::RuboCop::Cop::RSpec::Base
|
||||
def before_or_after_all(param0 = T.unsafe(nil)); end
|
||||
def on_send(node); end
|
||||
@ -137,6 +140,8 @@ end
|
||||
|
||||
RuboCop::Cop::RSpec::BeforeAfterAll::MSG = T.let(T.unsafe(nil), String)
|
||||
|
||||
RuboCop::Cop::RSpec::BeforeAfterAll::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
|
||||
|
||||
module RuboCop::Cop::RSpec::Capybara
|
||||
end
|
||||
|
||||
@ -158,6 +163,8 @@ end
|
||||
|
||||
RuboCop::Cop::RSpec::Capybara::CurrentPathExpectation::MSG = T.let(T.unsafe(nil), String)
|
||||
|
||||
RuboCop::Cop::RSpec::Capybara::CurrentPathExpectation::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
|
||||
|
||||
class RuboCop::Cop::RSpec::Capybara::FeatureMethods < ::RuboCop::Cop::RSpec::Base
|
||||
extend(::RuboCop::Cop::AutoCorrector)
|
||||
|
||||
@ -196,6 +203,18 @@ RuboCop::Cop::RSpec::Capybara::VisibilityMatcher::MSG_FALSE = T.let(T.unsafe(nil
|
||||
|
||||
RuboCop::Cop::RSpec::Capybara::VisibilityMatcher::MSG_TRUE = T.let(T.unsafe(nil), String)
|
||||
|
||||
RuboCop::Cop::RSpec::Capybara::VisibilityMatcher::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
|
||||
|
||||
module RuboCop::Cop::RSpec::CommentsHelp
|
||||
include(::RuboCop::Cop::RSpec::FinalEndLocation)
|
||||
|
||||
def begin_pos_with_comment(node); end
|
||||
def buffer; end
|
||||
def end_line_position(node); end
|
||||
def source_range_with_comment(node); end
|
||||
def start_line_position(node); end
|
||||
end
|
||||
|
||||
class RuboCop::Cop::RSpec::ContextMethod < ::RuboCop::Cop::RSpec::Base
|
||||
extend(::RuboCop::Cop::AutoCorrector)
|
||||
|
||||
@ -255,6 +274,8 @@ end
|
||||
|
||||
RuboCop::Cop::RSpec::DescribeSymbol::MSG = T.let(T.unsafe(nil), String)
|
||||
|
||||
RuboCop::Cop::RSpec::DescribeSymbol::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
|
||||
|
||||
class RuboCop::Cop::RSpec::DescribedClass < ::RuboCop::Cop::RSpec::Base
|
||||
include(::RuboCop::Cop::ConfigurableEnforcedStyle)
|
||||
extend(::RuboCop::Cop::AutoCorrector)
|
||||
@ -405,7 +426,6 @@ module RuboCop::Cop::RSpec::EmptyLineSeparation
|
||||
end
|
||||
|
||||
class RuboCop::Cop::RSpec::ExampleLength < ::RuboCop::Cop::RSpec::Base
|
||||
include(::RuboCop::Cop::ConfigurableMax)
|
||||
include(::RuboCop::Cop::CodeLength)
|
||||
|
||||
def on_block(node); end
|
||||
@ -494,6 +514,8 @@ RuboCop::Cop::RSpec::ExpectChange::MSG_BLOCK = T.let(T.unsafe(nil), String)
|
||||
|
||||
RuboCop::Cop::RSpec::ExpectChange::MSG_CALL = T.let(T.unsafe(nil), String)
|
||||
|
||||
RuboCop::Cop::RSpec::ExpectChange::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
|
||||
|
||||
class RuboCop::Cop::RSpec::ExpectInHook < ::RuboCop::Cop::RSpec::Base
|
||||
def expectation(param0); end
|
||||
def on_block(node); end
|
||||
@ -611,6 +633,8 @@ RuboCop::Cop::RSpec::FactoryBot::CreateList::MSG_CREATE_LIST = T.let(T.unsafe(ni
|
||||
|
||||
RuboCop::Cop::RSpec::FactoryBot::CreateList::MSG_N_TIMES = T.let(T.unsafe(nil), String)
|
||||
|
||||
RuboCop::Cop::RSpec::FactoryBot::CreateList::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
|
||||
|
||||
class RuboCop::Cop::RSpec::FactoryBot::CreateList::TimesCorrector
|
||||
include(::RuboCop::Cop::RSpec::FactoryBot::CreateList::Corrector)
|
||||
|
||||
@ -639,6 +663,8 @@ RuboCop::Cop::RSpec::FactoryBot::FactoryClassName::ALLOWED_CONSTANTS = T.let(T.u
|
||||
|
||||
RuboCop::Cop::RSpec::FactoryBot::FactoryClassName::MSG = T.let(T.unsafe(nil), String)
|
||||
|
||||
RuboCop::Cop::RSpec::FactoryBot::FactoryClassName::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
|
||||
|
||||
class RuboCop::Cop::RSpec::FilePath < ::RuboCop::Cop::RSpec::Base
|
||||
include(::RuboCop::Cop::RSpec::TopLevelGroup)
|
||||
|
||||
@ -738,6 +764,8 @@ end
|
||||
|
||||
RuboCop::Cop::RSpec::ImplicitBlockExpectation::MSG = T.let(T.unsafe(nil), String)
|
||||
|
||||
RuboCop::Cop::RSpec::ImplicitBlockExpectation::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
|
||||
|
||||
class RuboCop::Cop::RSpec::ImplicitExpect < ::RuboCop::Cop::RSpec::Base
|
||||
include(::RuboCop::Cop::ConfigurableEnforcedStyle)
|
||||
extend(::RuboCop::Cop::AutoCorrector)
|
||||
@ -773,6 +801,8 @@ end
|
||||
|
||||
RuboCop::Cop::RSpec::ImplicitSubject::MSG = T.let(T.unsafe(nil), String)
|
||||
|
||||
RuboCop::Cop::RSpec::ImplicitSubject::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
|
||||
|
||||
module RuboCop::Cop::RSpec::InflectedHelper
|
||||
include(::RuboCop::RSpec::Language)
|
||||
extend(::RuboCop::AST::NodePattern::Macros)
|
||||
@ -840,6 +870,8 @@ end
|
||||
|
||||
RuboCop::Cop::RSpec::ItBehavesLike::MSG = T.let(T.unsafe(nil), String)
|
||||
|
||||
RuboCop::Cop::RSpec::ItBehavesLike::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
|
||||
|
||||
class RuboCop::Cop::RSpec::IteratedExpectation < ::RuboCop::Cop::RSpec::Base
|
||||
def each?(param0 = T.unsafe(nil)); end
|
||||
def expectation?(param0 = T.unsafe(nil), param1); end
|
||||
@ -917,12 +949,13 @@ end
|
||||
RuboCop::Cop::RSpec::LetSetup::MSG = T.let(T.unsafe(nil), String)
|
||||
|
||||
class RuboCop::Cop::RSpec::MessageChain < ::RuboCop::Cop::RSpec::Base
|
||||
def message_chain(param0 = T.unsafe(nil)); end
|
||||
def on_send(node); end
|
||||
end
|
||||
|
||||
RuboCop::Cop::RSpec::MessageChain::MSG = T.let(T.unsafe(nil), String)
|
||||
|
||||
RuboCop::Cop::RSpec::MessageChain::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
|
||||
|
||||
class RuboCop::Cop::RSpec::MessageExpectation < ::RuboCop::Cop::RSpec::Base
|
||||
include(::RuboCop::Cop::ConfigurableEnforcedStyle)
|
||||
|
||||
@ -937,6 +970,8 @@ end
|
||||
|
||||
RuboCop::Cop::RSpec::MessageExpectation::MSG = T.let(T.unsafe(nil), String)
|
||||
|
||||
RuboCop::Cop::RSpec::MessageExpectation::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
|
||||
|
||||
RuboCop::Cop::RSpec::MessageExpectation::SUPPORTED_STYLES = T.let(T.unsafe(nil), Array)
|
||||
|
||||
class RuboCop::Cop::RSpec::MessageSpies < ::RuboCop::Cop::RSpec::Base
|
||||
@ -1075,6 +1110,8 @@ end
|
||||
|
||||
RuboCop::Cop::RSpec::NotToNot::MSG = T.let(T.unsafe(nil), String)
|
||||
|
||||
RuboCop::Cop::RSpec::NotToNot::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
|
||||
|
||||
class RuboCop::Cop::RSpec::OverwritingSetup < ::RuboCop::Cop::RSpec::Base
|
||||
def first_argument_name(param0 = T.unsafe(nil)); end
|
||||
def on_block(node); end
|
||||
@ -1151,6 +1188,8 @@ RuboCop::Cop::RSpec::Rails::HttpStatus::NumericStyleChecker::ALLOWED_STATUSES =
|
||||
|
||||
RuboCop::Cop::RSpec::Rails::HttpStatus::NumericStyleChecker::MSG = T.let(T.unsafe(nil), String)
|
||||
|
||||
RuboCop::Cop::RSpec::Rails::HttpStatus::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
|
||||
|
||||
class RuboCop::Cop::RSpec::Rails::HttpStatus::SymbolicStyleChecker
|
||||
def initialize(node); end
|
||||
|
||||
@ -1185,6 +1224,8 @@ end
|
||||
|
||||
RuboCop::Cop::RSpec::ReceiveCounts::MSG = T.let(T.unsafe(nil), String)
|
||||
|
||||
RuboCop::Cop::RSpec::ReceiveCounts::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
|
||||
|
||||
class RuboCop::Cop::RSpec::ReceiveNever < ::RuboCop::Cop::RSpec::Base
|
||||
extend(::RuboCop::Cop::AutoCorrector)
|
||||
|
||||
@ -1198,6 +1239,8 @@ end
|
||||
|
||||
RuboCop::Cop::RSpec::ReceiveNever::MSG = T.let(T.unsafe(nil), String)
|
||||
|
||||
RuboCop::Cop::RSpec::ReceiveNever::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
|
||||
|
||||
class RuboCop::Cop::RSpec::RepeatedDescription < ::RuboCop::Cop::RSpec::Base
|
||||
def on_block(node); end
|
||||
|
||||
@ -1323,6 +1366,8 @@ RuboCop::Cop::RSpec::ReturnFromStub::MSG_AND_RETURN = T.let(T.unsafe(nil), Strin
|
||||
|
||||
RuboCop::Cop::RSpec::ReturnFromStub::MSG_BLOCK = T.let(T.unsafe(nil), String)
|
||||
|
||||
RuboCop::Cop::RSpec::ReturnFromStub::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
|
||||
|
||||
class RuboCop::Cop::RSpec::ScatteredLet < ::RuboCop::Cop::RSpec::Base
|
||||
extend(::RuboCop::Cop::AutoCorrector)
|
||||
|
||||
@ -1405,6 +1450,8 @@ end
|
||||
|
||||
RuboCop::Cop::RSpec::SingleArgumentMessageChain::MSG = T.let(T.unsafe(nil), String)
|
||||
|
||||
RuboCop::Cop::RSpec::SingleArgumentMessageChain::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
|
||||
|
||||
class RuboCop::Cop::RSpec::StubbedMock < ::RuboCop::Cop::RSpec::Base
|
||||
def configured_response?(param0 = T.unsafe(nil)); end
|
||||
def expectation(param0 = T.unsafe(nil)); end
|
||||
@ -1464,6 +1511,8 @@ end
|
||||
|
||||
RuboCop::Cop::RSpec::UnspecifiedException::MSG = T.let(T.unsafe(nil), String)
|
||||
|
||||
RuboCop::Cop::RSpec::UnspecifiedException::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
|
||||
|
||||
module RuboCop::Cop::RSpec::Variable
|
||||
extend(::RuboCop::AST::NodePattern::Macros)
|
||||
|
||||
@ -1516,6 +1565,8 @@ end
|
||||
|
||||
RuboCop::Cop::RSpec::VerifiedDoubles::MSG = T.let(T.unsafe(nil), String)
|
||||
|
||||
RuboCop::Cop::RSpec::VerifiedDoubles::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
|
||||
|
||||
class RuboCop::Cop::RSpec::VoidExpect < ::RuboCop::Cop::RSpec::Base
|
||||
def expect?(param0 = T.unsafe(nil)); end
|
||||
def expect_block?(param0 = T.unsafe(nil)); end
|
||||
@ -1530,6 +1581,8 @@ end
|
||||
|
||||
RuboCop::Cop::RSpec::VoidExpect::MSG = T.let(T.unsafe(nil), String)
|
||||
|
||||
RuboCop::Cop::RSpec::VoidExpect::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
|
||||
|
||||
class RuboCop::Cop::RSpec::Yield < ::RuboCop::Cop::RSpec::Base
|
||||
include(::RuboCop::Cop::RangeHelp)
|
||||
extend(::RuboCop::Cop::AutoCorrector)
|
||||
@ -1599,6 +1652,7 @@ end
|
||||
class RuboCop::RSpec::Corrector::MoveNode
|
||||
include(::RuboCop::Cop::RangeHelp)
|
||||
include(::RuboCop::Cop::RSpec::FinalEndLocation)
|
||||
include(::RuboCop::Cop::RSpec::CommentsHelp)
|
||||
|
||||
def initialize(node, corrector, processed_source); end
|
||||
|
||||
@ -84,7 +84,7 @@ $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/unicode-display_width
|
||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-1.9.1/lib"
|
||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-performance-1.9.2/lib"
|
||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rails-2.9.1/lib"
|
||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rspec-2.1.0/lib"
|
||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rspec-2.2.0/lib"
|
||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-sorbet-0.5.1/lib"
|
||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/ruby-macho-2.5.0/lib"
|
||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/sorbet-runtime-stub-0.2.0/lib"
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
---
|
||||
RSpec:
|
||||
Enabled: true
|
||||
Include:
|
||||
- "**/*_spec.rb"
|
||||
- "**/spec/**/*"
|
||||
@ -15,6 +15,7 @@ require_relative 'rubocop/rspec/language'
|
||||
require_relative 'rubocop/cop/rspec/mixin/top_level_group'
|
||||
require_relative 'rubocop/cop/rspec/mixin/variable'
|
||||
require_relative 'rubocop/cop/rspec/mixin/final_end_location'
|
||||
require_relative 'rubocop/cop/rspec/mixin/comments_help'
|
||||
require_relative 'rubocop/cop/rspec/mixin/empty_line_separation'
|
||||
|
||||
require_relative 'rubocop/rspec/concept'
|
||||
@ -24,18 +24,14 @@ module RuboCop
|
||||
# end
|
||||
class AnyInstance < Base
|
||||
MSG = 'Avoid stubbing using `%<method>s`.'
|
||||
|
||||
def_node_matcher :disallowed_stub, <<-PATTERN
|
||||
(send _ ${:any_instance :allow_any_instance_of :expect_any_instance_of} ...)
|
||||
PATTERN
|
||||
RESTRICT_ON_SEND = %i[
|
||||
any_instance
|
||||
allow_any_instance_of
|
||||
expect_any_instance_of
|
||||
].freeze
|
||||
|
||||
def on_send(node)
|
||||
disallowed_stub(node) do |method|
|
||||
add_offense(
|
||||
node,
|
||||
message: format(MSG, method: method)
|
||||
)
|
||||
end
|
||||
add_offense(node, message: format(MSG, method: node.method_name))
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -39,6 +39,7 @@ module RuboCop
|
||||
extend AutoCorrector
|
||||
|
||||
MSG = 'Prefer `be` over `eql`.'
|
||||
RESTRICT_ON_SEND = %i[to].freeze
|
||||
|
||||
def_node_matcher :eql_type_with_identity, <<-PATTERN
|
||||
(send _ :to $(send nil? :eql {true false int float sym nil_type?}))
|
||||
@ -29,6 +29,8 @@ module RuboCop
|
||||
'`use_transactional_fixtures` is enabled, then records created ' \
|
||||
'in `%<hook>s` are not automatically rolled back.'
|
||||
|
||||
RESTRICT_ON_SEND = %i[before after].freeze
|
||||
|
||||
def_node_matcher :before_or_after_all, <<-PATTERN
|
||||
$(send _ {:before :after} (sym {:all :context}))
|
||||
PATTERN
|
||||
@ -30,6 +30,8 @@ module RuboCop
|
||||
'Capybara feature specs - instead, use the ' \
|
||||
'`have_current_path` matcher on `page`'
|
||||
|
||||
RESTRICT_ON_SEND = %i[expect].freeze
|
||||
|
||||
def_node_matcher :expectation_set_on_current_path, <<-PATTERN
|
||||
(send nil? :expect (send {(send nil? :page) nil?} :current_path))
|
||||
PATTERN
|
||||
@ -44,6 +44,8 @@ module RuboCop
|
||||
have_content
|
||||
].freeze
|
||||
|
||||
RESTRICT_ON_SEND = CAPYBARA_MATCHER_METHODS
|
||||
|
||||
def_node_matcher :visible_true?, <<~PATTERN
|
||||
(send nil? #capybara_matcher? ... (hash <$(pair (sym :visible) true) ...>))
|
||||
PATTERN
|
||||
@ -19,6 +19,7 @@ module RuboCop
|
||||
# @see https://github.com/rspec/rspec-core/issues/1610
|
||||
class DescribeSymbol < Base
|
||||
MSG = 'Avoid describing symbols.'
|
||||
RESTRICT_ON_SEND = %i[describe].freeze
|
||||
|
||||
def_node_matcher :describe_symbol?, <<-PATTERN
|
||||
(send #rspec? :describe $sym ...)
|
||||
@ -35,6 +35,7 @@ module RuboCop
|
||||
|
||||
MSG_BLOCK = 'Prefer `change(%<obj>s, :%<attr>s)`.'
|
||||
MSG_CALL = 'Prefer `change { %<obj>s.%<attr>s }`.'
|
||||
RESTRICT_ON_SEND = %i[change].freeze
|
||||
|
||||
def_node_matcher :expect_change_with_arguments, <<-PATTERN
|
||||
(send nil? :change ({const send} nil? $_) (sym $_))
|
||||
@ -30,6 +30,7 @@ module RuboCop
|
||||
|
||||
MSG_CREATE_LIST = 'Prefer create_list.'
|
||||
MSG_N_TIMES = 'Prefer %<number>s.times.'
|
||||
RESTRICT_ON_SEND = %i[create_list].freeze
|
||||
|
||||
def_node_matcher :n_times_block_without_arg?, <<-PATTERN
|
||||
(block
|
||||
@ -25,6 +25,7 @@ module RuboCop
|
||||
MSG = "Pass '%<class_name>s' string instead of `%<class_name>s` " \
|
||||
'constant.'
|
||||
ALLOWED_CONSTANTS = %w[Hash OpenStruct].freeze
|
||||
RESTRICT_ON_SEND = %i[factory].freeze
|
||||
|
||||
def_node_matcher :class_name, <<~PATTERN
|
||||
(send _ :factory _ (hash <(pair (sym :class) $(const ...)) ...>))
|
||||
@ -18,6 +18,7 @@ module RuboCop
|
||||
# end
|
||||
class ImplicitBlockExpectation < Base
|
||||
MSG = 'Avoid implicit block expectations.'
|
||||
RESTRICT_ON_SEND = %i[is_expected should should_not].freeze
|
||||
|
||||
def_node_matcher :lambda?, <<-PATTERN
|
||||
{
|
||||
@ -31,6 +31,7 @@ module RuboCop
|
||||
include ConfigurableEnforcedStyle
|
||||
|
||||
MSG = "Don't use implicit subject."
|
||||
RESTRICT_ON_SEND = %i[is_expected should should_not].freeze
|
||||
|
||||
def_node_matcher :implicit_subject?, <<-PATTERN
|
||||
(send nil? {:should :should_not :is_expected} ...)
|
||||
@ -24,6 +24,7 @@ module RuboCop
|
||||
|
||||
MSG = 'Prefer `%<replacement>s` over `%<original>s` when including ' \
|
||||
'examples in a nested context.'
|
||||
RESTRICT_ON_SEND = %i[it_behaves_like it_should_behave_like].freeze
|
||||
|
||||
def_node_matcher :example_inclusion_offense, '(send _ % ...)'
|
||||
|
||||
@ -15,18 +15,12 @@ module RuboCop
|
||||
#
|
||||
class MessageChain < Base
|
||||
MSG = 'Avoid stubbing using `%<method>s`.'
|
||||
|
||||
def_node_matcher :message_chain, <<-PATTERN
|
||||
(send _ {:receive_message_chain :stub_chain} ...)
|
||||
PATTERN
|
||||
RESTRICT_ON_SEND = %i[receive_message_chain stub_chain].freeze
|
||||
|
||||
def on_send(node)
|
||||
message_chain(node) do
|
||||
add_offense(
|
||||
node.loc.selector,
|
||||
message: format(MSG, method: node.method_name)
|
||||
)
|
||||
end
|
||||
add_offense(
|
||||
node.loc.selector, message: format(MSG, method: node.method_name)
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -30,6 +30,7 @@ module RuboCop
|
||||
MSG = 'Prefer `%<style>s` for setting message expectations.'
|
||||
|
||||
SUPPORTED_STYLES = %w[allow expect].freeze
|
||||
RESTRICT_ON_SEND = %i[to].freeze
|
||||
|
||||
def_node_matcher :message_expectation, <<-PATTERN
|
||||
(send $(send nil? {:expect :allow} ...) :to #receive_message?)
|
||||
@ -0,0 +1,38 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module RuboCop
|
||||
module Cop
|
||||
module RSpec
|
||||
# Help methods for working with nodes containing comments.
|
||||
module CommentsHelp
|
||||
include FinalEndLocation
|
||||
|
||||
def source_range_with_comment(node)
|
||||
begin_pos = begin_pos_with_comment(node).begin_pos
|
||||
end_pos = end_line_position(node).end_pos
|
||||
|
||||
Parser::Source::Range.new(buffer, begin_pos, end_pos)
|
||||
end
|
||||
|
||||
def begin_pos_with_comment(node)
|
||||
first_comment = processed_source.ast_with_comments[node].first
|
||||
|
||||
start_line_position(first_comment || node)
|
||||
end
|
||||
|
||||
def start_line_position(node)
|
||||
buffer.line_range(node.loc.line)
|
||||
end
|
||||
|
||||
def end_line_position(node)
|
||||
end_line = buffer.line_for_position(final_end_location(node).end_pos)
|
||||
buffer.line_range(end_line)
|
||||
end
|
||||
|
||||
def buffer
|
||||
processed_source.buffer
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -20,6 +20,7 @@ module RuboCop
|
||||
include ConfigurableEnforcedStyle
|
||||
|
||||
MSG = 'Prefer `%<replacement>s` over `%<original>s`.'
|
||||
RESTRICT_ON_SEND = %i[not_to to_not].freeze
|
||||
|
||||
def_node_matcher :not_to_not_offense, '(send _ % ...)'
|
||||
|
||||
@ -33,6 +33,7 @@ module RuboCop
|
||||
class HttpStatus < Base
|
||||
extend AutoCorrector
|
||||
include ConfigurableEnforcedStyle
|
||||
RESTRICT_ON_SEND = %i[have_http_status].freeze
|
||||
|
||||
def_node_matcher :http_status, <<-PATTERN
|
||||
(send nil? :have_http_status ${int sym})
|
||||
@ -28,6 +28,8 @@ module RuboCop
|
||||
|
||||
MSG = 'Use `%<alternative>s` instead of `%<original>s`.'
|
||||
|
||||
RESTRICT_ON_SEND = %i[times].freeze
|
||||
|
||||
def_node_matcher :receive_counts, <<-PATTERN
|
||||
(send $(send _ {:exactly :at_least :at_most} (int {1 2})) :times)
|
||||
PATTERN
|
||||
@ -16,6 +16,7 @@ module RuboCop
|
||||
class ReceiveNever < Base
|
||||
extend AutoCorrector
|
||||
MSG = 'Use `not_to receive` instead of `never`.'
|
||||
RESTRICT_ON_SEND = %i[never].freeze
|
||||
|
||||
def_node_search :method_on_stub?, '(send nil? :receive ...)'
|
||||
|
||||
@ -39,6 +39,7 @@ module RuboCop
|
||||
|
||||
MSG_AND_RETURN = 'Use `and_return` for static values.'
|
||||
MSG_BLOCK = 'Use block for static values.'
|
||||
RESTRICT_ON_SEND = %i[and_return].freeze
|
||||
|
||||
def_node_search :contains_stub?, '(send nil? :receive (...))'
|
||||
def_node_matcher :stub_with_block?, '(block #contains_stub? ...)'
|
||||
@ -21,6 +21,7 @@ module RuboCop
|
||||
|
||||
MSG = 'Use `%<recommended>s` instead of calling ' \
|
||||
'`%<called>s` with a single argument.'
|
||||
RESTRICT_ON_SEND = %i[receive_message_chain stub_chain].freeze
|
||||
|
||||
def_node_matcher :message_chain, <<-PATTERN
|
||||
(send _ {:receive_message_chain :stub_chain} $_)
|
||||
@ -32,6 +32,7 @@ module RuboCop
|
||||
# expect { do_something }.not_to raise_error
|
||||
class UnspecifiedException < Base
|
||||
MSG = 'Specify the exception being captured'
|
||||
RESTRICT_ON_SEND = %i[to].freeze
|
||||
|
||||
def_node_matcher :empty_raise_error_or_exception, <<-PATTERN
|
||||
(send
|
||||
@ -24,6 +24,7 @@ module RuboCop
|
||||
# end
|
||||
class VerifiedDoubles < Base
|
||||
MSG = 'Prefer using verifying doubles over normal doubles.'
|
||||
RESTRICT_ON_SEND = %i[double spy].freeze
|
||||
|
||||
def_node_matcher :unverified_double, <<-PATTERN
|
||||
{(send nil? {:double :spy} $...)}
|
||||
@ -14,6 +14,7 @@ module RuboCop
|
||||
class VoidExpect < Base
|
||||
MSG = 'Do not use `expect()` without `.to` or `.not_to`. ' \
|
||||
'Chain the methods or remove it.'
|
||||
RESTRICT_ON_SEND = %i[expect].freeze
|
||||
|
||||
def_node_matcher :expect?, <<-PATTERN
|
||||
(send nil? :expect ...)
|
||||
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