brew vendor-gems: commit updates.
This commit is contained in:
parent
704162afcf
commit
951a8f9377
@ -87,7 +87,7 @@ $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/unicode-display_width
|
|||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-1.27.0/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-1.27.0/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-performance-1.13.3/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-performance-1.13.3/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rails-2.14.2/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rails-2.14.2/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rspec-2.10.0/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rspec-2.11.0/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-sorbet-0.6.8/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-sorbet-0.6.8/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/ruby-macho-3.0.0/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/ruby-macho-3.0.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"
|
||||||
|
@ -110,6 +110,14 @@ RSpec:
|
|||||||
- subject
|
- subject
|
||||||
- subject!
|
- subject!
|
||||||
|
|
||||||
|
Metrics/BlockLength:
|
||||||
|
inherit_mode:
|
||||||
|
merge:
|
||||||
|
- Exclude
|
||||||
|
Exclude:
|
||||||
|
- "**/*_spec.rb"
|
||||||
|
- "**/spec/**/*"
|
||||||
|
|
||||||
RSpec/AlignLeftLetBrace:
|
RSpec/AlignLeftLetBrace:
|
||||||
Description: Checks that left braces for adjacent single line lets are aligned.
|
Description: Checks that left braces for adjacent single line lets are aligned.
|
||||||
Enabled: false
|
Enabled: false
|
||||||
@ -176,6 +184,12 @@ RSpec/BeforeAfterAll:
|
|||||||
StyleGuide: https://rspec.rubystyle.guide/#avoid-hooks-with-context-scope
|
StyleGuide: https://rspec.rubystyle.guide/#avoid-hooks-with-context-scope
|
||||||
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/BeforeAfterAll
|
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/BeforeAfterAll
|
||||||
|
|
||||||
|
RSpec/ChangeByZero:
|
||||||
|
Description: Prefer negated matchers over `to change.by(0)`.
|
||||||
|
Enabled: pending
|
||||||
|
VersionAdded: 2.11.0
|
||||||
|
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ChangeByZero
|
||||||
|
|
||||||
RSpec/ContextMethod:
|
RSpec/ContextMethod:
|
||||||
Description: "`context` should not be used for specifying methods."
|
Description: "`context` should not be used for specifying methods."
|
||||||
Enabled: true
|
Enabled: true
|
||||||
@ -256,7 +270,7 @@ RSpec/DescribedClassModuleWrapping:
|
|||||||
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/DescribedClassModuleWrapping
|
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/DescribedClassModuleWrapping
|
||||||
|
|
||||||
RSpec/Dialect:
|
RSpec/Dialect:
|
||||||
Description: This cop enforces custom RSpec dialects.
|
Description: Enforces custom RSpec dialects.
|
||||||
Enabled: false
|
Enabled: false
|
||||||
PreferredMethods: {}
|
PreferredMethods: {}
|
||||||
VersionAdded: '1.33'
|
VersionAdded: '1.33'
|
||||||
@ -787,13 +801,13 @@ RSpec/VerifiedDoubles:
|
|||||||
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/VerifiedDoubles
|
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/VerifiedDoubles
|
||||||
|
|
||||||
RSpec/VoidExpect:
|
RSpec/VoidExpect:
|
||||||
Description: This cop checks void `expect()`.
|
Description: Checks void `expect()`.
|
||||||
Enabled: true
|
Enabled: true
|
||||||
VersionAdded: '1.16'
|
VersionAdded: '1.16'
|
||||||
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/VoidExpect
|
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/VoidExpect
|
||||||
|
|
||||||
RSpec/Yield:
|
RSpec/Yield:
|
||||||
Description: This cop checks for calling a block within a stub.
|
Description: Checks for calling a block within a stub.
|
||||||
Enabled: true
|
Enabled: true
|
||||||
VersionAdded: '1.32'
|
VersionAdded: '1.32'
|
||||||
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Yield
|
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Yield
|
@ -46,7 +46,7 @@ module RuboCop
|
|||||||
|
|
||||||
MSG = 'Use `%<replacement>s` instead of `%<method>s`.'
|
MSG = 'Use `%<replacement>s` instead of `%<method>s`.'
|
||||||
|
|
||||||
# https://git.io/v7Kwr
|
# https://github.com/teamcapybara/capybara/blob/e283c1aeaa72441f5403963577e16333bf111a81/lib/capybara/rspec/features.rb#L31-L36
|
||||||
MAP = {
|
MAP = {
|
||||||
background: :before,
|
background: :before,
|
||||||
scenario: :it,
|
scenario: :it,
|
@ -0,0 +1,88 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
module RuboCop
|
||||||
|
module Cop
|
||||||
|
module RSpec
|
||||||
|
# Prefer negated matchers over `to change.by(0)`.
|
||||||
|
#
|
||||||
|
# @example
|
||||||
|
# # bad
|
||||||
|
# expect { run }.to change(Foo, :bar).by(0)
|
||||||
|
# expect { run }.to change { Foo.bar }.by(0)
|
||||||
|
# expect { run }
|
||||||
|
# .to change(Foo, :bar).by(0)
|
||||||
|
# .and change(Foo, :baz).by(0)
|
||||||
|
# expect { run }
|
||||||
|
# .to change { Foo.bar }.by(0)
|
||||||
|
# .and change { Foo.baz }.by(0)
|
||||||
|
#
|
||||||
|
# # good
|
||||||
|
# expect { run }.not_to change(Foo, :bar)
|
||||||
|
# expect { run }.not_to change { Foo.bar }
|
||||||
|
# expect { run }
|
||||||
|
# .to not_change(Foo, :bar)
|
||||||
|
# .and not_change(Foo, :baz)
|
||||||
|
# expect { run }
|
||||||
|
# .to not_change { Foo.bar }
|
||||||
|
# .and not_change { Foo.baz }
|
||||||
|
#
|
||||||
|
class ChangeByZero < Base
|
||||||
|
extend AutoCorrector
|
||||||
|
MSG = 'Prefer `not_to change` over `to change.by(0)`.'
|
||||||
|
MSG_COMPOUND = 'Prefer negated matchers with compound expectations ' \
|
||||||
|
'over `change.by(0)`.'
|
||||||
|
RESTRICT_ON_SEND = %i[change].freeze
|
||||||
|
|
||||||
|
# @!method expect_change_with_arguments(node)
|
||||||
|
def_node_matcher :expect_change_with_arguments, <<-PATTERN
|
||||||
|
(send
|
||||||
|
(send nil? :change ...) :by
|
||||||
|
(int 0))
|
||||||
|
PATTERN
|
||||||
|
|
||||||
|
# @!method expect_change_with_block(node)
|
||||||
|
def_node_matcher :expect_change_with_block, <<-PATTERN
|
||||||
|
(send
|
||||||
|
(block
|
||||||
|
(send nil? :change)
|
||||||
|
(args)
|
||||||
|
(send (...) $_)) :by
|
||||||
|
(int 0))
|
||||||
|
PATTERN
|
||||||
|
|
||||||
|
def on_send(node)
|
||||||
|
expect_change_with_arguments(node.parent) do
|
||||||
|
check_offence(node.parent)
|
||||||
|
end
|
||||||
|
|
||||||
|
expect_change_with_block(node.parent.parent) do
|
||||||
|
check_offence(node.parent.parent)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def check_offence(node)
|
||||||
|
expression = node.loc.expression
|
||||||
|
if compound_expectations?(node)
|
||||||
|
add_offense(expression, message: MSG_COMPOUND)
|
||||||
|
else
|
||||||
|
add_offense(expression) do |corrector|
|
||||||
|
autocorrect(corrector, node)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def compound_expectations?(node)
|
||||||
|
%i[and or].include?(node.parent.method_name)
|
||||||
|
end
|
||||||
|
|
||||||
|
def autocorrect(corrector, node)
|
||||||
|
corrector.replace(node.parent.loc.selector, 'not_to')
|
||||||
|
range = node.loc.dot.with(end_pos: node.loc.expression.end_pos)
|
||||||
|
corrector.remove(range)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -78,9 +78,8 @@ module RuboCop
|
|||||||
PATTERN
|
PATTERN
|
||||||
|
|
||||||
# @!method contains_described_class?(node)
|
# @!method contains_described_class?(node)
|
||||||
def_node_search :contains_described_class?, <<-PATTERN
|
def_node_search :contains_described_class?,
|
||||||
(send nil? :described_class)
|
'(send nil? :described_class)'
|
||||||
PATTERN
|
|
||||||
|
|
||||||
def on_block(node)
|
def on_block(node)
|
||||||
# In case the explicit style is used, we need to remember what's
|
# In case the explicit style is used, we need to remember what's
|
||||||
@ -129,17 +128,13 @@ module RuboCop
|
|||||||
end
|
end
|
||||||
|
|
||||||
def scope_change?(node)
|
def scope_change?(node)
|
||||||
scope_changing_syntax?(node) ||
|
scope_changing_syntax?(node) ||
|
||||||
common_instance_exec_closure?(node) ||
|
common_instance_exec_closure?(node) ||
|
||||||
skippable_block?(node)
|
skippable_block?(node)
|
||||||
end
|
end
|
||||||
|
|
||||||
def skippable_block?(node)
|
def skippable_block?(node)
|
||||||
node.block_type? && !rspec_block?(node) && skip_blocks?
|
node.block_type? && !rspec_block?(node) && cop_config['SkipBlocks']
|
||||||
end
|
|
||||||
|
|
||||||
def skip_blocks?
|
|
||||||
cop_config['SkipBlocks']
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def offensive?(node)
|
def offensive?(node)
|
||||||
@ -152,6 +147,7 @@ module RuboCop
|
|||||||
|
|
||||||
def offensive_described_class?(node)
|
def offensive_described_class?(node)
|
||||||
return unless node.const_type?
|
return unless node.const_type?
|
||||||
|
|
||||||
# E.g. `described_class::CONSTANT`
|
# E.g. `described_class::CONSTANT`
|
||||||
return if contains_described_class?(node)
|
return if contains_described_class?(node)
|
||||||
|
|
||||||
@ -172,14 +168,13 @@ module RuboCop
|
|||||||
# @return [Array<Symbol>]
|
# @return [Array<Symbol>]
|
||||||
# @example
|
# @example
|
||||||
# # nil represents base constant
|
# # nil represents base constant
|
||||||
# collapse_namespace([], :C) # => [:C]
|
# collapse_namespace([], [:C]) # => [:C]
|
||||||
# collapse_namespace([:A, :B], [:C) # => [:A, :B, :C]
|
# collapse_namespace([:A, :B], [:C]) # => [:A, :B, :C]
|
||||||
# collapse_namespace([:A, :B], [:B, :C) # => [:A, :B, :C]
|
# collapse_namespace([:A, :B], [:B, :C]) # => [:A, :B, :C]
|
||||||
# collapse_namespace([:A, :B], [nil, :C) # => [nil, :C]
|
# collapse_namespace([:A, :B], [nil, :C]) # => [nil, :C]
|
||||||
# collapse_namespace([:A, :B], [nil, :B, :C) # => [nil, :B, :C]
|
# collapse_namespace([:A, :B], [nil, :B, :C]) # => [nil, :B, :C]
|
||||||
def collapse_namespace(namespace, const)
|
def collapse_namespace(namespace, const)
|
||||||
return const if namespace.empty?
|
return const if namespace.empty? || const.first.nil?
|
||||||
return const if const.first.nil?
|
|
||||||
|
|
||||||
start = [0, (namespace.length - const.length)].max
|
start = [0, (namespace.length - const.length)].max
|
||||||
max = namespace.length
|
max = namespace.length
|
||||||
@ -196,9 +191,7 @@ module RuboCop
|
|||||||
# const_name(s(:const, s(:const, nil, :M), :C)) # => [:M, :C]
|
# const_name(s(:const, s(:const, nil, :M), :C)) # => [:M, :C]
|
||||||
# const_name(s(:const, s(:cbase), :C)) # => [nil, :C]
|
# const_name(s(:const, s(:cbase), :C)) # => [nil, :C]
|
||||||
def const_name(node)
|
def const_name(node)
|
||||||
# rubocop:disable InternalAffairs/NodeDestructuring
|
namespace, name = *node # rubocop:disable InternalAffairs/NodeDestructuring
|
||||||
namespace, name = *node
|
|
||||||
# rubocop:enable InternalAffairs/NodeDestructuring
|
|
||||||
if !namespace
|
if !namespace
|
||||||
[name]
|
[name]
|
||||||
elsif namespace.const_type?
|
elsif namespace.const_type?
|
@ -3,7 +3,7 @@
|
|||||||
module RuboCop
|
module RuboCop
|
||||||
module Cop
|
module Cop
|
||||||
module RSpec
|
module RSpec
|
||||||
# This cop enforces custom RSpec dialects.
|
# Enforces custom RSpec dialects.
|
||||||
#
|
#
|
||||||
# A dialect can be based on the following RSpec methods:
|
# A dialect can be based on the following RSpec methods:
|
||||||
#
|
#
|
@ -39,7 +39,7 @@ module RuboCop
|
|||||||
|
|
||||||
# @!method expect_change_with_arguments(node)
|
# @!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 $_ (sym $_))
|
(send nil? :change $_ ({sym str} $_))
|
||||||
PATTERN
|
PATTERN
|
||||||
|
|
||||||
# @!method expect_change_with_block(node)
|
# @!method expect_change_with_block(node)
|
||||||
@ -47,7 +47,7 @@ module RuboCop
|
|||||||
(block
|
(block
|
||||||
(send nil? :change)
|
(send nil? :change)
|
||||||
(args)
|
(args)
|
||||||
(send ({const send} nil? $_) $_)
|
(send $_ $_)
|
||||||
)
|
)
|
||||||
PATTERN
|
PATTERN
|
||||||
|
|
||||||
@ -67,9 +67,9 @@ module RuboCop
|
|||||||
return unless style == :method_call
|
return unless style == :method_call
|
||||||
|
|
||||||
expect_change_with_block(node) do |receiver, message|
|
expect_change_with_block(node) do |receiver, message|
|
||||||
msg = format(MSG_BLOCK, obj: receiver, attr: message)
|
msg = format(MSG_BLOCK, obj: receiver.source, attr: message)
|
||||||
add_offense(node, message: msg) do |corrector|
|
add_offense(node, message: msg) do |corrector|
|
||||||
replacement = "change(#{receiver}, :#{message})"
|
replacement = "change(#{receiver.source}, :#{message})"
|
||||||
corrector.replace(node, replacement)
|
corrector.replace(node, replacement)
|
||||||
end
|
end
|
||||||
end
|
end
|
@ -24,7 +24,7 @@ module RuboCop
|
|||||||
# rubocop:disable InternalAffairs/NodeDestructuring
|
# rubocop:disable InternalAffairs/NodeDestructuring
|
||||||
variable_name, _rhs = *node
|
variable_name, _rhs = *node
|
||||||
# rubocop:enable InternalAffairs/NodeDestructuring
|
# rubocop:enable InternalAffairs/NodeDestructuring
|
||||||
name = variable_name[1..-1]
|
name = variable_name[1..]
|
||||||
return unless name.eql?('stdout') || name.eql?('stderr')
|
return unless name.eql?('stdout') || name.eql?('stderr')
|
||||||
|
|
||||||
add_offense(node.loc.name, message: format(MSG, name: name))
|
add_offense(node.loc.name, message: format(MSG, name: name))
|
@ -47,7 +47,7 @@ module RuboCop
|
|||||||
def correct_variable(variable)
|
def correct_variable(variable)
|
||||||
case variable.type
|
case variable.type
|
||||||
when :dsym
|
when :dsym
|
||||||
variable.source[1..-1]
|
variable.source[1..]
|
||||||
when :sym
|
when :sym
|
||||||
variable.value.to_s.inspect
|
variable.value.to_s.inspect
|
||||||
else
|
else
|
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