Merge pull request #12111 from Homebrew/dependabot/bundler/Library/Homebrew/rubocop-rspec-2.5.0

build(deps): bump rubocop-rspec from 2.4.0 to 2.5.0 in /Library/Homebrew
This commit is contained in:
Bo Anderson 2021-09-23 03:09:47 +01:00 committed by GitHub
commit 9fbdd6eed6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
118 changed files with 209 additions and 11 deletions

View File

@ -143,9 +143,8 @@ GEM
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.7.0, < 2.0)
rubocop-rspec (2.4.0)
rubocop (~> 1.0)
rubocop-ast (>= 1.1.0)
rubocop-rspec (2.5.0)
rubocop (~> 1.19)
rubocop-sorbet (0.6.2)
rubocop
ruby-macho (2.5.1)

View File

@ -453,6 +453,23 @@ RuboCop::Cop::RSpec::ExampleWording::MSG_IT = T.let(T.unsafe(nil), String)
RuboCop::Cop::RSpec::ExampleWording::MSG_SHOULD = T.let(T.unsafe(nil), String)
RuboCop::Cop::RSpec::ExampleWording::SHOULD_PREFIX = T.let(T.unsafe(nil), Regexp)
class RuboCop::Cop::RSpec::ExcessiveDocstringSpacing < ::RuboCop::Cop::RSpec::Base
extend ::RuboCop::Cop::AutoCorrector
def example_description(param0 = T.unsafe(nil)); end
def on_send(node); end
private
def add_whitespace_offense(node, text); end
def docstring(node); end
def excessive_whitespace?(text); end
def strip_excessive_whitespace(text); end
def text(node); end
end
RuboCop::Cop::RSpec::ExcessiveDocstringSpacing::MSG = T.let(T.unsafe(nil), String)
class RuboCop::Cop::RSpec::ExpectActual < ::RuboCop::Cop::RSpec::Base
extend ::RuboCop::Cop::AutoCorrector
@ -1423,6 +1440,18 @@ end
RuboCop::Cop::RSpec::StubbedMock::MSG = T.let(T.unsafe(nil), String)
class RuboCop::Cop::RSpec::SubjectDeclaration < ::RuboCop::Cop::RSpec::Base
def offensive_subject_declaration?(param0 = T.unsafe(nil)); end
def on_send(node); end
private
def message_for(offense); end
end
RuboCop::Cop::RSpec::SubjectDeclaration::MSG_LET = T.let(T.unsafe(nil), String)
RuboCop::Cop::RSpec::SubjectDeclaration::MSG_REDUNDANT = T.let(T.unsafe(nil), String)
class RuboCop::Cop::RSpec::SubjectStub < ::RuboCop::Cop::RSpec::Base
include ::RuboCop::Cop::RSpec::TopLevelGroup

View File

@ -287,7 +287,7 @@ describe Homebrew::Livecheck::SkipConditions do
end
context "when a formula is HEAD-only and not installed" do
it "skips " do
it "skips" do
expect(skip_conditions.skip_information(formulae[:head_only]))
.to eq(status_hashes[:formula][:head_only])
end
@ -389,7 +389,7 @@ describe Homebrew::Livecheck::SkipConditions do
end
context "when a formula is HEAD-only and not installed" do
it "skips " do
it "skips" do
expect(skip_conditions.referenced_skip_information(formulae[:head_only], original_name))
.to eq(status_hashes[:formula][:head_only].merge({ formula: original_name }))
end

View File

@ -90,7 +90,7 @@ $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/unicode-display_width
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-1.20.0/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-performance-1.11.5/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rails-2.12.2/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rspec-2.4.0/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rspec-2.5.0/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-sorbet-0.6.2/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/ruby-macho-2.5.1/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/simplecov-html-0.12.3/lib"

View File

@ -148,6 +148,12 @@ RSpec/ContextWording:
RSpec/DescribeClass:
Description: Check that the first argument to the top-level describe is a constant.
Enabled: true
Exclude:
- "**/spec/features/**/*"
- "**/spec/requests/**/*"
- "**/spec/routing/**/*"
- "**/spec/system/**/*"
- "**/spec/views/**/*"
IgnoredMetadata:
type:
- channel
@ -164,7 +170,7 @@ RSpec/DescribeClass:
- mailbox
- aruba
VersionAdded: '1.0'
VersionChanged: '1.44'
VersionChanged: '2.5'
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/DescribeClass
RSpec/DescribeMethod:
@ -269,6 +275,12 @@ RSpec/ExampleWithoutDescription:
VersionAdded: '1.22'
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ExampleWithoutDescription
RSpec/ExcessiveDocstringSpacing:
Description: Checks for excessive whitespace in example descriptions.
Enabled: pending
VersionAdded: '2.5'
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ExcessiveDocstringSpacing
RSpec/ExampleWording:
Description: Checks for common mistakes in example descriptions.
Enabled: true
@ -297,7 +309,9 @@ RSpec/ExpectChange:
SupportedStyles:
- method_call
- block
SafeAutoCorrect: false
VersionAdded: '1.22'
VersionChanged: '2.5'
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ExpectChange
RSpec/ExpectInHook:
@ -643,6 +657,12 @@ RSpec/StubbedMock:
VersionAdded: '1.44'
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/StubbedMock
RSpec/SubjectDeclaration:
Description: Ensure that subject is defined using subject helper.
Enabled: pending
VersionAdded: '2.5'
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/SubjectDeclaration
RSpec/SubjectStub:
Description: Checks for stubbed test subjects.
Enabled: true

View File

@ -36,7 +36,10 @@ 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)
range = range_with_surrounding_space(
range: node.loc.expression,
side: :left
)
corrector.remove(range)
end
end

View File

@ -0,0 +1,96 @@
# frozen_string_literal: true
module RuboCop
module Cop
module RSpec
# Checks for excessive whitespace in example descriptions.
#
# @example
# # bad
# it ' has excessive spacing ' do
# end
#
# # good
# it 'has excessive spacing' do
# end
#
# @example
# # bad
# context ' when a condition is met ' do
# end
#
# # good
# context 'when a condition is met' do
# end
class ExcessiveDocstringSpacing < Base
extend AutoCorrector
MSG = 'Excessive whitespace.'
# @!method example_description(node)
def_node_matcher :example_description, <<-PATTERN
(send _ {#Examples.all #ExampleGroups.all} ${
$str
$(dstr ({str dstr `sym} ...) ...)
} ...)
PATTERN
def on_send(node)
example_description(node) do |description_node, message|
text = text(message)
return unless excessive_whitespace?(text)
add_whitespace_offense(description_node, text)
end
end
private
# @param text [String]
def excessive_whitespace?(text)
text.start_with?(' ') || text.include?(' ') || text.end_with?(' ')
end
# @param text [String]
def strip_excessive_whitespace(text)
text.strip.gsub(/ +/, ' ')
end
# @param node [RuboCop::AST::Node]
# @param text [String]
def add_whitespace_offense(node, text)
docstring = docstring(node)
corrected = strip_excessive_whitespace(text)
add_offense(docstring) do |corrector|
corrector.replace(docstring, corrected)
end
end
def docstring(node)
expr = node.loc.expression
Parser::Source::Range.new(
expr.source_buffer,
expr.begin_pos + 1,
expr.end_pos - 1
)
end
# Recursive processing is required to process nested dstr nodes
# that is the case for \-separated multiline strings with interpolation.
def text(node)
case node.type
when :dstr
node.node_parts.map { |child_node| text(child_node) }.join
when :str, :sym
node.value
when :begin
node.source
end
end
end
end
end
end

View File

@ -48,6 +48,8 @@ module RuboCop
end
def only_expectations?(body, arg)
return false unless body.each_child_node.any?
body.each_child_node.all? { |child| expectation?(child, arg) }
end
end

View File

@ -6,7 +6,7 @@ module RuboCop
# Checks for nested example groups.
#
# This cop is configurable using the `Max` option
# and supports `--auto-gen-config
# and supports `--auto-gen-config`.
#
# @example
# # bad

View File

@ -0,0 +1,47 @@
# frozen_string_literal: true
module RuboCop
module Cop
module RSpec
# Ensure that subject is defined using subject helper.
#
# @example
#
# # bad
# let(:subject) { foo }
# let!(:subject) { foo }
# subject(:subject) { foo }
# subject!(:subject) { foo }
#
# # bad
# block = -> {}
# let(:subject, &block)
#
# # good
# subject(:test_subject) { foo }
#
class SubjectDeclaration < Base
MSG_LET = 'Use subject explicitly rather than using let'
MSG_REDUNDANT = 'Ambiguous declaration of subject'
# @!method offensive_subject_declaration?(node)
def_node_matcher :offensive_subject_declaration?, <<~PATTERN
(send nil? ${#Subjects.all #Helpers.all} {(sym :subject) (str "subject")} ...)
PATTERN
def on_send(node)
offense = offensive_subject_declaration?(node)
return unless offense
add_offense(node, message: message_for(offense))
end
private
def message_for(offense)
Helpers.all(offense) ? MSG_LET : MSG_REDUNDANT
end
end
end
end
end

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