brew vendor-gems: commit updates.

This commit is contained in:
BrewTestBot 2022-07-04 18:06:06 +00:00
parent 1dae1c4875
commit 0e0f00f44c
No known key found for this signature in database
GPG Key ID: 82D7D104050B0F0F
124 changed files with 279 additions and 63 deletions

View File

@ -89,7 +89,7 @@ $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/unicode-display_width
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-1.31.1/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-performance-1.14.2/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rails-2.15.1/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rspec-2.11.1/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rspec-2.12.1/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-sorbet-0.6.11/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"

View File

@ -783,11 +783,13 @@ RSpec/VariableName:
RSpec/VerifiedDoubleReference:
Description: Checks for consistent verified double reference style.
Enabled: pending
SafeAutoCorrect: false
EnforcedStyle: constant
SupportedStyles:
- constant
- string
VersionAdded: 2.10.0
VersionChanged: '2.12'
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/VerifiedDoubleReference
RSpec/VerifiedDoubles:
@ -832,6 +834,12 @@ RSpec/Capybara/FeatureMethods:
VersionChanged: '2.0'
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Capybara/FeatureMethods
RSpec/Capybara/SpecificMatcher:
Description: Checks for there is a more specific matcher offered by Capybara.
Enabled: pending
VersionAdded: '2.12'
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Capybara/SpecificMatcher
RSpec/Capybara/VisibilityMatcher:
Description: Checks for boolean visibility in Capybara finders.
Enabled: true
@ -901,6 +909,13 @@ RSpec/Rails/AvoidSetupHook:
VersionAdded: '2.4'
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Rails/AvoidSetupHook
RSpec/Rails/HaveHttpStatus:
Description: Checks that tests use `have_http_status` instead of equality matchers.
Enabled: pending
SafeAutoCorrect: false
VersionAdded: '2.12'
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Rails/HaveHttpStatus
RSpec/Rails/HttpStatus:
Description: Enforces use of symbolic or numeric value to describe HTTP status.
Enabled: true

View File

@ -0,0 +1,77 @@
# frozen_string_literal: true
module RuboCop
module Cop
module RSpec
module Capybara
# Checks for there is a more specific matcher offered by Capybara.
#
# @example
#
# # bad
# expect(page).to have_selector('button')
# expect(page).to have_no_selector('button.cls')
# expect(page).to have_css('button')
# expect(page).to have_no_css('a.cls', exact_text: 'foo')
# expect(page).to have_css('table.cls')
# expect(page).to have_css('select')
#
# # good
# expect(page).to have_button
# expect(page).to have_no_button(class: 'cls')
# expect(page).to have_button
# expect(page).to have_no_link('foo', class: 'cls')
# expect(page).to have_table(class: 'cls')
# expect(page).to have_select
#
class SpecificMatcher < Base
MSG = 'Prefer `%<good_matcher>s` over `%<bad_matcher>s`.'
RESTRICT_ON_SEND = %i[have_selector have_no_selector have_css
have_no_css].freeze
SPECIFIC_MATCHER = {
'button' => 'button',
'a' => 'link',
'table' => 'table',
'select' => 'select'
}.freeze
# @!method first_argument(node)
def_node_matcher :first_argument, <<-PATTERN
(send nil? _ (str $_) ... )
PATTERN
def on_send(node)
return unless (arg = first_argument(node))
return unless (matcher = specific_matcher(arg))
return if acceptable_pattern?(arg)
add_offense(node, message: message(node, matcher))
end
private
def specific_matcher(arg)
splitted_arg = arg[/^\w+/, 0]
SPECIFIC_MATCHER[splitted_arg]
end
def acceptable_pattern?(arg)
arg.match?(/\[.+=\w+\]/) || arg.match?(/[ >,+]/)
end
def message(node, matcher)
format(MSG,
good_matcher: good_matcher(node, matcher),
bad_matcher: node.method_name)
end
def good_matcher(node, matcher)
node.method_name
.to_s
.gsub(/selector|css/, matcher.to_s)
end
end
end
end
end
end

View File

@ -9,6 +9,8 @@ module RuboCop
# # bad
# expect { run }.to change(Foo, :bar).by(0)
# expect { run }.to change { Foo.bar }.by(0)
#
# # bad - compound expectations
# expect { run }
# .to change(Foo, :bar).by(0)
# .and change(Foo, :baz).by(0)
@ -19,6 +21,9 @@ module RuboCop
# # good
# expect { run }.not_to change(Foo, :bar)
# expect { run }.not_to change { Foo.bar }
#
# # good - compound expectations
# define_negated_matcher :not_change, :change
# expect { run }
# .to not_change(Foo, :bar)
# .and not_change(Foo, :baz)
@ -52,17 +57,17 @@ module RuboCop
def on_send(node)
expect_change_with_arguments(node.parent) do
check_offence(node.parent)
check_offense(node.parent)
end
expect_change_with_block(node.parent.parent) do
check_offence(node.parent.parent)
check_offense(node.parent.parent)
end
end
private
def check_offence(node)
def check_offense(node)
expression = node.loc.expression
if compound_expectations?(node)
add_offense(expression, message: MSG_COMPOUND)

View File

@ -11,7 +11,7 @@ module RuboCop
# This cop can be configured using the `EnforcedStyle` and `SkipBlocks`
# options.
#
# @example `EnforcedStyle: described_class`
# @example `EnforcedStyle: described_class` (default)
# # bad
# describe MyClass do
# subject { MyClass.do_something }

View File

@ -36,11 +36,9 @@ module RuboCop
def on_block(node)
empty_hook?(node) do |hook|
add_offense(hook) do |corrector|
range = range_with_surrounding_space(
range: node.loc.expression,
side: :left
corrector.remove(
range_with_surrounding_space(node.loc.expression, side: :left)
)
corrector.remove(range)
end
end
end

View File

@ -6,7 +6,7 @@ module RuboCop
# Checks for long examples.
#
# A long example is usually more difficult to understand. Consider
# extracting out some behaviour, e.g. with a `let` block, or a helper
# extracting out some behavior, e.g. with a `let` block, or a helper
# method.
#
# @example

View File

@ -14,7 +14,7 @@ module RuboCop
#
# This cop can be configured using the `EnforcedStyle` option
#
# @example `EnforcedStyle: always_allow`
# @example `EnforcedStyle: always_allow` (default)
# # bad
# it('') { is_expected.to be_good }
# it '' do

View File

@ -5,6 +5,8 @@ module RuboCop
module RSpec
# Checks for `expect(...)` calls containing literal values.
#
# Autocorrection is performed when the expected is not a literal.
#
# @example
# # bad
# expect(5).to eq(price)

View File

@ -10,14 +10,7 @@ module RuboCop
#
# This cop can be configured using the `EnforcedStyle` option.
#
# @example `EnforcedStyle: block`
# # bad
# expect { run }.to change(Foo, :bar)
#
# # good
# expect { run }.to change { Foo.bar }
#
# @example `EnforcedStyle: method_call`
# @example `EnforcedStyle: method_call` (default)
# # bad
# expect { run }.to change { Foo.bar }
# expect { run }.to change { foo.baz }
@ -29,6 +22,13 @@ module RuboCop
# expect { run }.to change { Foo.bar(:count) }
# expect { run }.to change { user.reload.name }
#
# @example `EnforcedStyle: block`
# # bad
# expect { run }.to change(Foo, :bar)
#
# # good
# expect { run }.to change { Foo.bar }
#
class ExpectChange < Base
extend AutoCorrector
include ConfigurableEnforcedStyle

View File

@ -8,15 +8,21 @@ module RuboCop
#
# This cop can be configured using the `EnforcedStyle` option
#
# @example `EnforcedStyle: create_list`
# @example `EnforcedStyle: create_list` (default)
# # bad
# 3.times { create :user }
#
# # good
# create_list :user, 3
#
# # good
# 3.times { |n| create :user, created_at: n.months.ago }
# # bad
# 3.times { create :user, age: 18 }
#
# # good - index is used to alter the created models attributes
# 3.times { |n| create :user, age: n }
#
# # good - contains a method call, may return different values
# 3.times { create :user, age: rand }
#
# @example `EnforcedStyle: n_times`
# # bad
@ -33,15 +39,28 @@ module RuboCop
MSG_N_TIMES = 'Prefer %<number>s.times.'
RESTRICT_ON_SEND = %i[create_list].freeze
# @!method n_times_block_without_arg?(node)
def_node_matcher :n_times_block_without_arg?, <<-PATTERN
# @!method n_times_block?(node)
def_node_matcher :n_times_block?, <<-PATTERN
(block
(send (int _) :times)
(args)
...
)
PATTERN
# @!method n_times_block_with_arg_and_used?(node)
def_node_matcher :n_times_block_with_arg_and_used?, <<-PATTERN
(block
(send (int _) :times)
(args (arg _value))
`_value
)
PATTERN
# @!method arguments_include_method_call?(node)
def_node_matcher :arguments_include_method_call?, <<-PATTERN
(send ${nil? #factory_bot?} :create (sym $_) `$(send ...))
PATTERN
# @!method factory_call(node)
def_node_matcher :factory_call, <<-PATTERN
(send ${nil? #factory_bot?} :create (sym $_) $...)
@ -54,7 +73,11 @@ module RuboCop
def on_block(node)
return unless style == :create_list
return unless n_times_block_without_arg?(node)
return unless n_times_block?(node)
return if n_times_block_with_arg_and_used?(node)
return unless node.body
return if arguments_include_method_call?(node.body)
return unless contains_only_factory?(node.body)
add_offense(node.send_node, message: MSG_CREATE_LIST) do |corrector|
@ -193,7 +216,7 @@ module RuboCop
if node.body.begin_type?
format_multiline_block(node)
else
format_singeline_block(node)
format_singleline_block(node)
end
end
@ -205,7 +228,7 @@ module RuboCop
"#{indent_end}end"
end
def format_singeline_block(node)
def format_singleline_block(node)
" { #{node.arguments.source} #{node.body.source} }"
end
end

View File

@ -7,7 +7,7 @@ module RuboCop
# Use shorthands from `FactoryBot::Syntax::Methods` in your specs.
#
# @safety
# The auto-correction is marked as unsafe because the cop
# The autocorrection is marked as unsafe because the cop
# cannot verify whether you already include
# `FactoryBot::Syntax::Methods` in your test suite.
#

View File

@ -117,8 +117,9 @@ module RuboCop
def name_pattern(method_name)
return unless method_name&.str_type?
return if ignore_methods?
".*#{method_name.str_content.gsub(/\W/, '')}" unless ignore_methods?
".*#{method_name.str_content.gsub(/\s/, '_').gsub(/\W/, '')}"
end
def expected_path(constant)

View File

@ -69,10 +69,8 @@ module RuboCop
end
def with_surrounding(focus)
range_with_space = range_with_surrounding_space(
range: focus.loc.expression,
side: :left
)
range_with_space =
range_with_surrounding_space(focus.loc.expression, side: :left)
range_with_surrounding_comma(range_with_space, :left)
end

View File

@ -10,7 +10,7 @@ module RuboCop
# styles: "implicit", "each", and "example." All styles have
# the same behavior.
#
# @example when configuration is `EnforcedStyle: implicit`
# @example `EnforcedStyle: implicit` (default)
# # bad
# before(:each) do
# # ...
@ -26,7 +26,7 @@ module RuboCop
# # ...
# end
#
# @example when configuration is `EnforcedStyle: each`
# @example `EnforcedStyle: each`
# # bad
# before(:example) do
# # ...
@ -42,7 +42,7 @@ module RuboCop
# # ...
# end
#
# @example when configuration is `EnforcedStyle: example`
# @example `EnforcedStyle: example`
# # bad
# before(:each) do
# # ...

View File

@ -8,7 +8,7 @@ module RuboCop
# This cop can be configured using the `EnforcedStyle` option
# and supports the `--auto-gen-config` flag.
#
# @example `EnforcedStyle: is_expected`
# @example `EnforcedStyle: is_expected` (default)
#
# # bad
# it { should be_truthy }

View File

@ -5,14 +5,14 @@ module RuboCop
module RSpec
# Checks that only one `it_behaves_like` style is used.
#
# @example when configuration is `EnforcedStyle: it_behaves_like`
# @example `EnforcedStyle: it_behaves_like` (default)
# # bad
# it_should_behave_like 'a foo'
#
# # good
# it_behaves_like 'a foo'
#
# @example when configuration is `EnforcedStyle: it_should_behave_like`
# @example `EnforcedStyle: it_should_behave_like`
# # bad
# it_behaves_like 'a foo'
#

View File

@ -10,7 +10,7 @@ module RuboCop
#
# If several examples may define a `DummyClass`, instead of being a
# blank slate class as it will be in the first example, subsequent
# examples will be reopening it and modifying its behaviour in
# examples will be reopening it and modifying its behavior in
# unpredictable ways.
# Even worse when a class that exists in the codebase is reopened.
#

View File

@ -8,7 +8,7 @@ module RuboCop
# This cop can be configured in your configuration using the
# `EnforcedStyle` option and supports `--auto-gen-config`.
#
# @example `EnforcedStyle: allow`
# @example `EnforcedStyle: allow` (default)
#
# # bad
# expect(foo).to receive(:bar)

View File

@ -8,21 +8,27 @@ module RuboCop
# This cop can be configured in your configuration using the
# `EnforcedStyle` option and supports `--auto-gen-config`.
#
# @example `EnforcedStyle: have_received`
# @example `EnforcedStyle: have_received` (default)
#
# # bad
# expect(foo).to receive(:bar)
# do_something
#
# # good
# allow(foo).to receive(:bar) # or use instance_spy
# do_something
# expect(foo).to have_received(:bar)
#
# @example `EnforcedStyle: receive`
#
# # bad
# allow(foo).to receive(:bar)
# do_something
# expect(foo).to have_received(:bar)
#
# # good
# expect(foo).to receive(:bar)
# do_something
#
class MessageSpies < Base
include ConfigurableEnforcedStyle

View File

@ -4,7 +4,10 @@ module RuboCop
module Cop
module RSpec
# Helps determine the offending location if there is not an empty line
# following the node. Allows comments to follow directly after.
# following the node. Allows comments to follow directly after
# in the following cases.
# - `rubocop:enable` directive
# - followed by empty line(s)
module EmptyLineSeparation
include FinalEndLocation
include RangeHelp
@ -21,13 +24,19 @@ module RuboCop
end
def missing_separating_line(node)
line = final_end_location(node).line
line = final_end_line = final_end_location(node).line
line += 1 while comment_line?(processed_source[line])
while comment_line?(processed_source[line])
line += 1
comment = processed_source.comment_at_line(line)
if DirectiveComment.new(comment).enabled?
enable_directive_line = line
end
end
return if processed_source[line].blank?
yield offending_loc(line)
yield offending_loc(enable_directive_line || final_end_line)
end
def offending_loc(last_line)

View File

@ -31,6 +31,26 @@ module RuboCop
# end
# end
#
# @example `aggregate_failures: true` (default)
#
# # good - the cop ignores when RSpec aggregates failures
# describe UserCreator do
# it 'builds a user', :aggregate_failures do
# expect(user.name).to eq("John")
# expect(user.age).to eq(22)
# end
# end
#
# @example `aggregate_failures: false`
#
# # Detected as an offense
# describe UserCreator do
# it 'builds a user', aggregate_failures: false do
# expect(user.name).to eq("John")
# expect(user.age).to eq(22)
# end
# end
#
# @example configuration
#
# # .rubocop.yml

View File

@ -5,7 +5,8 @@ module RuboCop
module RSpec
# Checks for consistent method usage for negating expectations.
#
# @example
# @example `EnforcedStyle: not_to` (default)
#
# # bad
# it '...' do
# expect(false).to_not be_true
@ -15,6 +16,18 @@ module RuboCop
# it '...' do
# expect(false).not_to be_true
# end
#
# @example `EnforcedStyle: to_not`
#
# # bad
# it '...' do
# expect(false).not_to be_true
# end
#
# # good
# it '...' do
# expect(false).to_not be_true
# end
class NotToNot < Base
extend AutoCorrector
include ConfigurableEnforcedStyle

View File

@ -0,0 +1,47 @@
# frozen_string_literal: true
module RuboCop
module Cop
module RSpec
module Rails
# Checks that tests use `have_http_status` instead of equality matchers.
#
# @example
# # bad
# expect(response.status).to be(200)
#
# # good
# expect(response).to have_http_status(200)
#
class HaveHttpStatus < Base
extend AutoCorrector
MSG =
'Prefer `expect(response).%<to>s have_http_status(%<status>i)` ' \
'over `expect(response.status).%<to>s %<match>s`.'
# @!method match_status(node)
def_node_matcher :match_status, <<-PATTERN
(send
(send nil? :expect
$(send (send nil? :response) :status)
)
$#Runners.all
$(send nil? {:be :eq :eql :equal} (int $_))
)
PATTERN
def on_send(node)
match_status(node) do |response_status, to, match, status|
message = format(MSG, to: to, match: match.source, status: status)
add_offense(node, message: message) do |corrector|
corrector.replace(response_status.source_range, 'response')
corrector.replace(match.loc.selector, 'have_http_status')
end
end
end
end
end
end
end
end

View File

@ -11,6 +11,17 @@ module RuboCop
#
# This cop can be configured using the `EnforcedStyle` option
#
# @example `EnforcedStyle: and_return` (default)
# # bad
# allow(Foo).to receive(:bar) { "baz" }
# expect(Foo).to receive(:bar) { "baz" }
#
# # good
# allow(Foo).to receive(:bar).and_return("baz")
# expect(Foo).to receive(:bar).and_return("baz")
# # also good as the returned value is dynamic
# allow(Foo).to receive(:bar) { bar.baz }
#
# @example `EnforcedStyle: block`
# # bad
# allow(Foo).to receive(:bar).and_return("baz")
@ -22,17 +33,6 @@ module RuboCop
# # also good as the returned value is dynamic
# allow(Foo).to receive(:bar).and_return(bar.baz)
#
# @example `EnforcedStyle: and_return`
# # bad
# allow(Foo).to receive(:bar) { "baz" }
# expect(Foo).to receive(:bar) { "baz" }
#
# # good
# allow(Foo).to receive(:bar).and_return("baz")
# expect(Foo).to receive(:bar).and_return("baz")
# # also good as the returned value is dynamic
# allow(Foo).to receive(:bar) { bar.baz }
#
class ReturnFromStub < Base
extend AutoCorrector
include ConfigurableEnforcedStyle

View File

@ -35,7 +35,7 @@ module RuboCop
occurrences.each do |occurrence|
lines_except_current = lines - [occurrence.first_line]
message = format(MSG, hook_name: occurrences.first.method_name,
lines: lines_msg(lines_except_current))
lines: lines_msg(lines_except_current))
add_offense(occurrence, message: message)
end
end

Some files were not shown because too many files have changed in this diff Show More