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/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/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/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/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/parser-3.2.2.0/lib")
|
||||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rainbow-3.1.1/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-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-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-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/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}/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")
|
$:.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
|
StyleGuide: https://rspec.rubystyle.guide/#be-matcher
|
||||||
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Be
|
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:
|
RSpec/BeEq:
|
||||||
Description: Check for expectations where `be(...)` can replace `eq(...)`.
|
Description: Check for expectations where `be(...)` can replace `eq(...)`.
|
||||||
Enabled: pending
|
Enabled: pending
|
||||||
@ -202,8 +208,8 @@ RSpec/ClassCheck:
|
|||||||
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ClassCheck
|
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ClassCheck
|
||||||
|
|
||||||
RSpec/ContainExactly:
|
RSpec/ContainExactly:
|
||||||
Description: Prefer `match_array` when matching array values.
|
Description: Checks where `contain_exactly` is used.
|
||||||
Enabled: true
|
Enabled: pending
|
||||||
VersionAdded: '2.19'
|
VersionAdded: '2.19'
|
||||||
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ContainExactly
|
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ContainExactly
|
||||||
|
|
||||||
@ -503,6 +509,13 @@ RSpec/ImplicitSubject:
|
|||||||
VersionChanged: '2.13'
|
VersionChanged: '2.13'
|
||||||
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ImplicitSubject
|
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:
|
RSpec/InstanceSpy:
|
||||||
Description: Checks for `instance_double` used with `have_received`.
|
Description: Checks for `instance_double` used with `have_received`.
|
||||||
Enabled: true
|
Enabled: true
|
||||||
@ -563,8 +576,8 @@ RSpec/LetSetup:
|
|||||||
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/LetSetup
|
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/LetSetup
|
||||||
|
|
||||||
RSpec/MatchArray:
|
RSpec/MatchArray:
|
||||||
Description: Prefer `contain_exactly` when matching an array literal.
|
Description: Checks where `match_array` is used.
|
||||||
Enabled: true
|
Enabled: pending
|
||||||
VersionAdded: '2.19'
|
VersionAdded: '2.19'
|
||||||
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/MatchArray
|
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/MatchArray
|
||||||
|
|
||||||
@ -1048,8 +1061,9 @@ RSpec/Rails/HttpStatus:
|
|||||||
SupportedStyles:
|
SupportedStyles:
|
||||||
- numeric
|
- numeric
|
||||||
- symbolic
|
- symbolic
|
||||||
|
- be_status
|
||||||
VersionAdded: '1.23'
|
VersionAdded: '1.23'
|
||||||
VersionChanged: '2.0'
|
VersionChanged: '2.20'
|
||||||
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Rails/HttpStatus
|
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Rails/HttpStatus
|
||||||
|
|
||||||
RSpec/Rails/InferredSpecType:
|
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)
|
return unless be_nil_matcher?(node)
|
||||||
|
|
||||||
add_offense(node, message: BE_MSG) do |corrector|
|
add_offense(node, message: BE_MSG) do |corrector|
|
||||||
corrector.replace(node.source_range, 'be(nil)')
|
corrector.replace(node, 'be(nil)')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -65,7 +65,7 @@ module RuboCop
|
|||||||
return unless nil_value_expectation?(node)
|
return unless nil_value_expectation?(node)
|
||||||
|
|
||||||
add_offense(node, message: BE_NIL_MSG) do |corrector|
|
add_offense(node, message: BE_NIL_MSG) do |corrector|
|
||||||
corrector.replace(node.source_range, 'be_nil')
|
corrector.replace(node, 'be_nil')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -3,7 +3,11 @@
|
|||||||
module RuboCop
|
module RuboCop
|
||||||
module Cop
|
module Cop
|
||||||
module RSpec
|
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
|
# @example
|
||||||
# # bad
|
# # bad
|
||||||
@ -14,6 +18,7 @@ module RuboCop
|
|||||||
#
|
#
|
||||||
# # good
|
# # good
|
||||||
# it { is_expected.to contain_exactly(content, *array) }
|
# it { is_expected.to contain_exactly(content, *array) }
|
||||||
|
#
|
||||||
class ContainExactly < Base
|
class ContainExactly < Base
|
||||||
extend AutoCorrector
|
extend AutoCorrector
|
||||||
|
|
||||||
@ -21,21 +26,27 @@ module RuboCop
|
|||||||
RESTRICT_ON_SEND = %i[contain_exactly].freeze
|
RESTRICT_ON_SEND = %i[contain_exactly].freeze
|
||||||
|
|
||||||
def on_send(node)
|
def on_send(node)
|
||||||
return unless node.each_child_node.all?(&:splat_type?)
|
return if node.arguments.empty?
|
||||||
|
|
||||||
add_offense(node) do |corrector|
|
check_populated_collection(node)
|
||||||
autocorrect(node, corrector)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
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|
|
arrays = node.arguments.map do |splat_node|
|
||||||
splat_node.children.first
|
splat_node.children.first
|
||||||
end
|
end
|
||||||
corrector.replace(
|
corrector.replace(
|
||||||
node.source_range,
|
node,
|
||||||
"match_array(#{arrays.map(&:source).join(' + ')})"
|
"match_array(#{arrays.map(&:source).join(' + ')})"
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
@ -22,15 +22,15 @@ module RuboCop
|
|||||||
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)
|
# @!method include_rspec_blocks?(node)
|
||||||
def_node_search :find_rspec_blocks, <<~PATTERN
|
def_node_search :include_rspec_blocks?, <<~PATTERN
|
||||||
(block (send #explicit_rspec? #ExampleGroups.all ...) ...)
|
({block numblock} (send #explicit_rspec? #ExampleGroups.all ...) ...)
|
||||||
PATTERN
|
PATTERN
|
||||||
|
|
||||||
def on_module(node)
|
def on_module(node)
|
||||||
find_rspec_blocks(node) do
|
return unless include_rspec_blocks?(node)
|
||||||
add_offense(node)
|
|
||||||
end
|
add_offense(node)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -30,7 +30,7 @@ module RuboCop
|
|||||||
MSG = 'Add an empty line after `%<example_group>s`.'
|
MSG = 'Add an empty line after `%<example_group>s`.'
|
||||||
|
|
||||||
def on_block(node) # rubocop:disable InternalAffairs/NumblockHandler
|
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|
|
missing_separating_line_offense(node) do |method|
|
||||||
format(MSG, example_group: method)
|
format(MSG, example_group: method)
|
||||||
@ -93,8 +93,8 @@ module RuboCop
|
|||||||
end
|
end
|
||||||
|
|
||||||
def swap(corrector, actual, expected)
|
def swap(corrector, actual, expected)
|
||||||
corrector.replace(actual.source_range, expected.source)
|
corrector.replace(actual, expected.source)
|
||||||
corrector.replace(expected.source_range, actual.source)
|
corrector.replace(expected, actual.source)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -100,10 +100,10 @@ module RuboCop
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
AMBIGUOUS_TYPES = %i[send pair array and or if].freeze
|
||||||
|
|
||||||
def ambiguous_without_parentheses?(node)
|
def ambiguous_without_parentheses?(node)
|
||||||
node.parent&.send_type? ||
|
node.parent && AMBIGUOUS_TYPES.include?(node.parent.type)
|
||||||
node.parent&.pair_type? ||
|
|
||||||
node.parent&.array_type?
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def remove_parentheses(corrector, node)
|
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 RuboCop
|
||||||
module Cop
|
module Cop
|
||||||
module RSpec
|
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
|
# @example
|
||||||
# # bad
|
# # bad
|
||||||
@ -17,20 +21,34 @@ module RuboCop
|
|||||||
#
|
#
|
||||||
# # good
|
# # good
|
||||||
# it { is_expected.to match_array(%w(tremble in fear foolish mortals)) }
|
# it { is_expected.to match_array(%w(tremble in fear foolish mortals)) }
|
||||||
|
#
|
||||||
class MatchArray < Base
|
class MatchArray < Base
|
||||||
extend AutoCorrector
|
extend AutoCorrector
|
||||||
|
|
||||||
MSG = 'Prefer `contain_exactly` when matching an array literal.'
|
MSG = 'Prefer `contain_exactly` when matching an array literal.'
|
||||||
RESTRICT_ON_SEND = %i[match_array].freeze
|
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)
|
def on_send(node)
|
||||||
return unless node.first_argument.array_type?
|
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?
|
return if node.first_argument.percent_literal?
|
||||||
|
|
||||||
add_offense(node) do |corrector|
|
add_offense(node) do |corrector|
|
||||||
array_contents = node.arguments.flat_map(&:to_a)
|
array_contents = node.arguments.flat_map(&:to_a)
|
||||||
corrector.replace(
|
corrector.replace(
|
||||||
node.source_range,
|
node,
|
||||||
"contain_exactly(#{array_contents.map(&:source).join(', ')})"
|
"contain_exactly(#{array_contents.map(&:source).join(', ')})"
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
@ -70,7 +70,12 @@ module RuboCop
|
|||||||
|
|
||||||
# @!method skipped_by_example_method?(node)
|
# @!method skipped_by_example_method?(node)
|
||||||
def_node_matcher :skipped_by_example_method?, <<~PATTERN
|
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
|
PATTERN
|
||||||
|
|
||||||
# @!method metadata_without_reason?(node)
|
# @!method metadata_without_reason?(node)
|
||||||
@ -102,7 +107,7 @@ module RuboCop
|
|||||||
on_skipped_by_example_method(node)
|
on_skipped_by_example_method(node)
|
||||||
on_skipped_by_example_group_method(node)
|
on_skipped_by_example_group_method(node)
|
||||||
elsif example?(parent)
|
elsif example?(parent)
|
||||||
on_skipped_by_in_example_method(node, parent)
|
on_skipped_by_in_example_method(node)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -121,7 +126,7 @@ module RuboCop
|
|||||||
explicit_rspec?(node.receiver)
|
explicit_rspec?(node.receiver)
|
||||||
end
|
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|
|
skipped_in_example?(node) do |pending|
|
||||||
add_offense(node, message: "Give the reason for #{pending}.")
|
add_offense(node, message: "Give the reason for #{pending}.")
|
||||||
end
|
end
|
||||||
@ -137,6 +142,10 @@ module RuboCop
|
|||||||
skipped_by_example_method?(node) do |pending|
|
skipped_by_example_method?(node) do |pending|
|
||||||
add_offense(node, message: "Give the reason for #{pending}.")
|
add_offense(node, message: "Give the reason for #{pending}.")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
skipped_by_example_method_with_block?(node.parent) do |pending|
|
||||||
|
add_offense(node, message: "Give the reason for #{pending}.")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def on_skipped_by_example_group_method(node)
|
def on_skipped_by_example_group_method(node)
|
||||||
@ -99,7 +99,7 @@ module RuboCop
|
|||||||
block = block_loc ? block_loc.source : ''
|
block = block_loc ? block_loc.source : ''
|
||||||
|
|
||||||
corrector.replace(
|
corrector.replace(
|
||||||
matcher.source_range,
|
matcher,
|
||||||
to_predicate_matcher(predicate.method_name) + args + block
|
to_predicate_matcher(predicate.method_name) + args + block
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
@ -214,7 +214,7 @@ module RuboCop
|
|||||||
|
|
||||||
def corrector_explicit(corrector, to_node, actual, matcher, block_child)
|
def corrector_explicit(corrector, to_node, actual, matcher, block_child)
|
||||||
replacement_matcher = replacement_matcher(to_node)
|
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)
|
move_predicate(corrector, actual, matcher, block_child)
|
||||||
corrector.replace(to_node.loc.selector, 'to')
|
corrector.replace(to_node.loc.selector, 'to')
|
||||||
end
|
end
|
||||||
@ -226,8 +226,7 @@ module RuboCop
|
|||||||
block = block_loc ? block_loc.source : ''
|
block = block_loc ? block_loc.source : ''
|
||||||
|
|
||||||
corrector.remove(block_loc) if block_loc
|
corrector.remove(block_loc) if block_loc
|
||||||
corrector.insert_after(actual.source_range,
|
corrector.insert_after(actual, ".#{predicate}" + args + block)
|
||||||
".#{predicate}" + args + block)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# rubocop:disable Metrics/MethodLength
|
# 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