brew vendor-gems: commit updates.
This commit is contained in:
parent
c15d625d32
commit
023999a103
@ -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 ...)
|
||||
@ -6,6 +6,7 @@ module RuboCop
|
||||
# Helper methods to move a node
|
||||
class MoveNode
|
||||
include RuboCop::Cop::RangeHelp
|
||||
include RuboCop::Cop::RSpec::CommentsHelp
|
||||
include RuboCop::Cop::RSpec::FinalEndLocation
|
||||
|
||||
attr_reader :original, :corrector, :processed_source
|
||||
@ -17,20 +18,16 @@ module RuboCop
|
||||
end
|
||||
|
||||
def move_before(other)
|
||||
position = other.loc.expression
|
||||
indent = ' ' * other.loc.column
|
||||
newline_indent = "\n#{indent}"
|
||||
position = start_line_position(other)
|
||||
|
||||
corrector.insert_before(position, source(original) + newline_indent)
|
||||
corrector.insert_before(position, "#{source(original)}\n")
|
||||
corrector.remove(node_range_with_surrounding_space(original))
|
||||
end
|
||||
|
||||
def move_after(other)
|
||||
position = final_end_location(other)
|
||||
indent = ' ' * other.loc.column
|
||||
newline_indent = "\n#{indent}"
|
||||
position = end_line_position(other)
|
||||
|
||||
corrector.insert_after(position, newline_indent + source(original))
|
||||
corrector.insert_after(position, "\n#{source(original)}")
|
||||
corrector.remove(node_range_with_surrounding_space(original))
|
||||
end
|
||||
|
||||
@ -41,7 +38,7 @@ module RuboCop
|
||||
end
|
||||
|
||||
def node_range(node)
|
||||
node.loc.expression.with(end_pos: final_end_location(node).end_pos)
|
||||
source_range_with_comment(node)
|
||||
end
|
||||
|
||||
def node_range_with_surrounding_space(node)
|
||||
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