brew vendor-gems: commit updates.
This commit is contained in:
parent
61e895d73e
commit
7058d2e1d6
@ -74,7 +74,7 @@ $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/mechanize-2.9.0/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/method_source-1.0.0/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/mustache-1.1.1/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/parallel-1.22.1/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/parallel-1.23.0/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/parallel_tests-3.13.0/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/parser-3.2.2.0/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rainbow-3.1.1/lib")
|
||||
@ -107,7 +107,7 @@ $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-capybara-2.17.1/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-performance-1.17.1/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-rails-2.19.1/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-rspec-2.19.0/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-rspec-2.20.0/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-sorbet-0.7.0/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/ruby-macho-3.0.0/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/extensions/universal-darwin-21/#{Gem.extension_api_version}/ruby-prof-1.4.3")
|
||||
|
||||
@ -144,6 +144,12 @@ RSpec/Be:
|
||||
StyleGuide: https://rspec.rubystyle.guide/#be-matcher
|
||||
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Be
|
||||
|
||||
RSpec/BeEmpty:
|
||||
Description: Prefer using `be_empty` when checking for an empty array.
|
||||
Enabled: pending
|
||||
VersionAdded: '2.20'
|
||||
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/BeEmpty
|
||||
|
||||
RSpec/BeEq:
|
||||
Description: Check for expectations where `be(...)` can replace `eq(...)`.
|
||||
Enabled: pending
|
||||
@ -202,8 +208,8 @@ RSpec/ClassCheck:
|
||||
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ClassCheck
|
||||
|
||||
RSpec/ContainExactly:
|
||||
Description: Prefer `match_array` when matching array values.
|
||||
Enabled: true
|
||||
Description: Checks where `contain_exactly` is used.
|
||||
Enabled: pending
|
||||
VersionAdded: '2.19'
|
||||
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ContainExactly
|
||||
|
||||
@ -503,6 +509,13 @@ RSpec/ImplicitSubject:
|
||||
VersionChanged: '2.13'
|
||||
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ImplicitSubject
|
||||
|
||||
RSpec/IndexedLet:
|
||||
Description: Do not set up test data using indexes (e.g., `item_1`, `item_2`).
|
||||
Enabled: pending
|
||||
VersionAdded: '2.20'
|
||||
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/IndexedLet
|
||||
Max: 1
|
||||
|
||||
RSpec/InstanceSpy:
|
||||
Description: Checks for `instance_double` used with `have_received`.
|
||||
Enabled: true
|
||||
@ -563,8 +576,8 @@ RSpec/LetSetup:
|
||||
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/LetSetup
|
||||
|
||||
RSpec/MatchArray:
|
||||
Description: Prefer `contain_exactly` when matching an array literal.
|
||||
Enabled: true
|
||||
Description: Checks where `match_array` is used.
|
||||
Enabled: pending
|
||||
VersionAdded: '2.19'
|
||||
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/MatchArray
|
||||
|
||||
@ -1048,8 +1061,9 @@ RSpec/Rails/HttpStatus:
|
||||
SupportedStyles:
|
||||
- numeric
|
||||
- symbolic
|
||||
- be_status
|
||||
VersionAdded: '1.23'
|
||||
VersionChanged: '2.0'
|
||||
VersionChanged: '2.20'
|
||||
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Rails/HttpStatus
|
||||
|
||||
RSpec/Rails/InferredSpecType:
|
||||
@ -0,0 +1,44 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module RuboCop
|
||||
module Cop
|
||||
module RSpec
|
||||
# Prefer using `be_empty` when checking for an empty array.
|
||||
#
|
||||
# @example
|
||||
# # bad
|
||||
# expect(array).to contain_exactly
|
||||
# expect(array).to match_array([])
|
||||
#
|
||||
# # good
|
||||
# expect(array).to be_empty
|
||||
#
|
||||
class BeEmpty < Base
|
||||
extend AutoCorrector
|
||||
|
||||
MSG = 'Use `be_empty` matchers for checking an empty array.'
|
||||
RESTRICT_ON_SEND = %i[contain_exactly match_array].freeze
|
||||
|
||||
# @!method expect_array_matcher?(node)
|
||||
def_node_matcher :expect_array_matcher?, <<~PATTERN
|
||||
(send
|
||||
(send nil? :expect _)
|
||||
#Runners.all
|
||||
${
|
||||
(send nil? :match_array (array))
|
||||
(send nil? :contain_exactly)
|
||||
}
|
||||
)
|
||||
PATTERN
|
||||
|
||||
def on_send(node)
|
||||
expect_array_matcher?(node.parent) do |expect|
|
||||
add_offense(expect) do |corrector|
|
||||
corrector.replace(expect, 'be_empty')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -57,7 +57,7 @@ module RuboCop
|
||||
return unless be_nil_matcher?(node)
|
||||
|
||||
add_offense(node, message: BE_MSG) do |corrector|
|
||||
corrector.replace(node.source_range, 'be(nil)')
|
||||
corrector.replace(node, 'be(nil)')
|
||||
end
|
||||
end
|
||||
|
||||
@ -65,7 +65,7 @@ module RuboCop
|
||||
return unless nil_value_expectation?(node)
|
||||
|
||||
add_offense(node, message: BE_NIL_MSG) do |corrector|
|
||||
corrector.replace(node.source_range, 'be_nil')
|
||||
corrector.replace(node, 'be_nil')
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -3,7 +3,11 @@
|
||||
module RuboCop
|
||||
module Cop
|
||||
module RSpec
|
||||
# Prefer `match_array` when matching array values.
|
||||
# Checks where `contain_exactly` is used.
|
||||
#
|
||||
# This cop checks for the following:
|
||||
# - Prefer `match_array` when matching array values.
|
||||
# - Prefer `be_empty` when using `contain_exactly` with no arguments.
|
||||
#
|
||||
# @example
|
||||
# # bad
|
||||
@ -14,6 +18,7 @@ module RuboCop
|
||||
#
|
||||
# # good
|
||||
# it { is_expected.to contain_exactly(content, *array) }
|
||||
#
|
||||
class ContainExactly < Base
|
||||
extend AutoCorrector
|
||||
|
||||
@ -21,21 +26,27 @@ module RuboCop
|
||||
RESTRICT_ON_SEND = %i[contain_exactly].freeze
|
||||
|
||||
def on_send(node)
|
||||
return unless node.each_child_node.all?(&:splat_type?)
|
||||
return if node.arguments.empty?
|
||||
|
||||
add_offense(node) do |corrector|
|
||||
autocorrect(node, corrector)
|
||||
end
|
||||
check_populated_collection(node)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def autocorrect(node, corrector)
|
||||
def check_populated_collection(node)
|
||||
return unless node.each_child_node.all?(&:splat_type?)
|
||||
|
||||
add_offense(node) do |corrector|
|
||||
autocorrect_for_populated_array(node, corrector)
|
||||
end
|
||||
end
|
||||
|
||||
def autocorrect_for_populated_array(node, corrector)
|
||||
arrays = node.arguments.map do |splat_node|
|
||||
splat_node.children.first
|
||||
end
|
||||
corrector.replace(
|
||||
node.source_range,
|
||||
node,
|
||||
"match_array(#{arrays.map(&:source).join(' + ')})"
|
||||
)
|
||||
end
|
||||
@ -22,15 +22,15 @@ module RuboCop
|
||||
class DescribedClassModuleWrapping < Base
|
||||
MSG = 'Avoid opening modules and defining specs within them.'
|
||||
|
||||
# @!method find_rspec_blocks(node)
|
||||
def_node_search :find_rspec_blocks, <<~PATTERN
|
||||
(block (send #explicit_rspec? #ExampleGroups.all ...) ...)
|
||||
# @!method include_rspec_blocks?(node)
|
||||
def_node_search :include_rspec_blocks?, <<~PATTERN
|
||||
({block numblock} (send #explicit_rspec? #ExampleGroups.all ...) ...)
|
||||
PATTERN
|
||||
|
||||
def on_module(node)
|
||||
find_rspec_blocks(node) do
|
||||
add_offense(node)
|
||||
end
|
||||
return unless include_rspec_blocks?(node)
|
||||
|
||||
add_offense(node)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -30,7 +30,7 @@ module RuboCop
|
||||
MSG = 'Add an empty line after `%<example_group>s`.'
|
||||
|
||||
def on_block(node) # rubocop:disable InternalAffairs/NumblockHandler
|
||||
return unless example_group?(node)
|
||||
return unless spec_group?(node)
|
||||
|
||||
missing_separating_line_offense(node) do |method|
|
||||
format(MSG, example_group: method)
|
||||
@ -93,8 +93,8 @@ module RuboCop
|
||||
end
|
||||
|
||||
def swap(corrector, actual, expected)
|
||||
corrector.replace(actual.source_range, expected.source)
|
||||
corrector.replace(expected.source_range, actual.source)
|
||||
corrector.replace(actual, expected.source)
|
||||
corrector.replace(expected, actual.source)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -100,10 +100,10 @@ module RuboCop
|
||||
end
|
||||
end
|
||||
|
||||
AMBIGUOUS_TYPES = %i[send pair array and or if].freeze
|
||||
|
||||
def ambiguous_without_parentheses?(node)
|
||||
node.parent&.send_type? ||
|
||||
node.parent&.pair_type? ||
|
||||
node.parent&.array_type?
|
||||
node.parent && AMBIGUOUS_TYPES.include?(node.parent.type)
|
||||
end
|
||||
|
||||
def remove_parentheses(corrector, node)
|
||||
@ -0,0 +1,76 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module RuboCop
|
||||
module Cop
|
||||
module RSpec
|
||||
# Do not set up test data using indexes (e.g., `item_1`, `item_2`).
|
||||
#
|
||||
# It makes reading the test harder because it's not clear what exactly
|
||||
# is tested by this particular example.
|
||||
#
|
||||
# @example `Max: 1 (default)`
|
||||
# # bad
|
||||
# let(:item_1) { create(:item) }
|
||||
# let(:item_2) { create(:item) }
|
||||
#
|
||||
# let(:item1) { create(:item) }
|
||||
# let(:item2) { create(:item) }
|
||||
#
|
||||
# # good
|
||||
#
|
||||
# let(:visible_item) { create(:item, visible: true) }
|
||||
# let(:invisible_item) { create(:item, visible: false) }
|
||||
#
|
||||
# @example `Max: 2`
|
||||
# # bad
|
||||
# let(:item_1) { create(:item) }
|
||||
# let(:item_2) { create(:item) }
|
||||
# let(:item_3) { create(:item) }
|
||||
#
|
||||
# # good
|
||||
# let(:item_1) { create(:item) }
|
||||
# let(:item_2) { create(:item) }
|
||||
#
|
||||
class IndexedLet < Base
|
||||
MSG = 'This `let` statement uses index in its name. Please give it ' \
|
||||
'a meaningful name.'
|
||||
|
||||
# @!method let_name(node)
|
||||
def_node_matcher :let_name, <<~PATTERN
|
||||
{
|
||||
(block (send nil? #Helpers.all ({str sym} $_) ...) ...)
|
||||
(send nil? #Helpers.all ({str sym} $_) block_pass)
|
||||
}
|
||||
PATTERN
|
||||
|
||||
def on_block(node) # rubocop:disable InternalAffairs/NumblockHandler
|
||||
return unless spec_group?(node)
|
||||
|
||||
children = node.body&.child_nodes
|
||||
return unless children
|
||||
|
||||
filter_indexed_lets(children).each do |let_node|
|
||||
add_offense(let_node)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
INDEX_REGEX = /_?\d+/.freeze
|
||||
|
||||
def filter_indexed_lets(candidates)
|
||||
candidates
|
||||
.filter { |node| indexed_let?(node) }
|
||||
.group_by { |node| let_name(node).to_s.gsub(INDEX_REGEX, '') }
|
||||
.values
|
||||
.filter { |lets| lets.length > cop_config['Max'] }
|
||||
.flatten
|
||||
end
|
||||
|
||||
def indexed_let?(node)
|
||||
let?(node) && INDEX_REGEX.match?(let_name(node))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -3,7 +3,11 @@
|
||||
module RuboCop
|
||||
module Cop
|
||||
module RSpec
|
||||
# Prefer `contain_exactly` when matching an array literal.
|
||||
# Checks where `match_array` is used.
|
||||
#
|
||||
# This cop checks for the following:
|
||||
# - Prefer `contain_exactly` when matching an array with values.
|
||||
# - Prefer `eq` when using `match_array` with an empty array literal.
|
||||
#
|
||||
# @example
|
||||
# # bad
|
||||
@ -17,20 +21,34 @@ module RuboCop
|
||||
#
|
||||
# # good
|
||||
# it { is_expected.to match_array(%w(tremble in fear foolish mortals)) }
|
||||
#
|
||||
class MatchArray < Base
|
||||
extend AutoCorrector
|
||||
|
||||
MSG = 'Prefer `contain_exactly` when matching an array literal.'
|
||||
RESTRICT_ON_SEND = %i[match_array].freeze
|
||||
|
||||
# @!method match_array_with_empty_array?(node)
|
||||
def_node_matcher :match_array_with_empty_array?, <<~PATTERN
|
||||
(send nil? :match_array (array))
|
||||
PATTERN
|
||||
|
||||
def on_send(node)
|
||||
return unless node.first_argument.array_type?
|
||||
return if match_array_with_empty_array?(node)
|
||||
|
||||
check_populated_array(node)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def check_populated_array(node)
|
||||
return if node.first_argument.percent_literal?
|
||||
|
||||
add_offense(node) do |corrector|
|
||||
array_contents = node.arguments.flat_map(&:to_a)
|
||||
corrector.replace(
|
||||
node.source_range,
|
||||
node,
|
||||
"contain_exactly(#{array_contents.map(&:source).join(', ')})"
|
||||
)
|
||||
end
|
||||
@ -70,7 +70,12 @@ module RuboCop
|
||||
|
||||
# @!method skipped_by_example_method?(node)
|
||||
def_node_matcher :skipped_by_example_method?, <<~PATTERN
|
||||
(send nil? ${#Examples.skipped #Examples.pending} ...)
|
||||
(send nil? ${#Examples.skipped #Examples.pending})
|
||||
PATTERN
|
||||
|
||||
# @!method skipped_by_example_method_with_block?(node)
|
||||
def_node_matcher :skipped_by_example_method_with_block?, <<~PATTERN
|
||||
({block numblock} (send nil? ${#Examples.skipped #Examples.pending} ...) ...)
|
||||
PATTERN
|
||||
|
||||
# @!method metadata_without_reason?(node)
|
||||
@ -102,7 +107,7 @@ module RuboCop
|
||||
on_skipped_by_example_method(node)
|
||||
on_skipped_by_example_group_method(node)
|
||||
elsif example?(parent)
|
||||
on_skipped_by_in_example_method(node, parent)
|
||||
on_skipped_by_in_example_method(node)
|
||||
end
|
||||
end
|
||||
|
||||
@ -121,7 +126,7 @@ module RuboCop
|
||||
explicit_rspec?(node.receiver)
|
||||
end
|
||||
|
||||
def on_skipped_by_in_example_method(node, _direct_parent)
|
||||
def on_skipped_by_in_example_method(node)
|
||||
skipped_in_example?(node) do |pending|
|
||||
add_offense(node, message: "Give the reason for #{pending}.")
|
||||
end
|
||||
@ -137,6 +142,10 @@ module RuboCop
|
||||
skipped_by_example_method?(node) do |pending|
|
||||
add_offense(node, message: "Give the reason for #{pending}.")
|
||||
end
|
||||
|
||||
skipped_by_example_method_with_block?(node.parent) do |pending|
|
||||
add_offense(node, message: "Give the reason for #{pending}.")
|
||||
end
|
||||
end
|
||||
|
||||
def on_skipped_by_example_group_method(node)
|
||||
@ -99,7 +99,7 @@ module RuboCop
|
||||
block = block_loc ? block_loc.source : ''
|
||||
|
||||
corrector.replace(
|
||||
matcher.source_range,
|
||||
matcher,
|
||||
to_predicate_matcher(predicate.method_name) + args + block
|
||||
)
|
||||
end
|
||||
@ -214,7 +214,7 @@ module RuboCop
|
||||
|
||||
def corrector_explicit(corrector, to_node, actual, matcher, block_child)
|
||||
replacement_matcher = replacement_matcher(to_node)
|
||||
corrector.replace(matcher.source_range, replacement_matcher)
|
||||
corrector.replace(matcher, replacement_matcher)
|
||||
move_predicate(corrector, actual, matcher, block_child)
|
||||
corrector.replace(to_node.loc.selector, 'to')
|
||||
end
|
||||
@ -226,8 +226,7 @@ module RuboCop
|
||||
block = block_loc ? block_loc.source : ''
|
||||
|
||||
corrector.remove(block_loc) if block_loc
|
||||
corrector.insert_after(actual.source_range,
|
||||
".#{predicate}" + args + block)
|
||||
corrector.insert_after(actual, ".#{predicate}" + args + block)
|
||||
end
|
||||
|
||||
# rubocop:disable Metrics/MethodLength
|
||||
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