Showing 30 of 40 total issues
Class BlockSnippetExtractor
has 38 methods (exceeds 20 allowed). Consider refactoring.
class BlockSnippetExtractor # rubocop:disable Metrics/ClassLength
# rubocop should properly handle `Struct.new {}` as an inner class definition.
attr_reader :proc, :method_name
File yield.rb
has 358 lines of code (exceeds 250 allowed). Consider refactoring.
RSpec::Support.require_rspec_support 'method_signature_verifier'
module RSpec
module Matchers
module BuiltIn
Class RaiseError
has 28 methods (exceeds 20 allowed). Consider refactoring.
class RaiseError
include Composable
# Used as a sentinel value to be able to tell when the user did not pass an
# argument. We can't use `nil` for that because we need to warn when `nil` is
File change.rb
has 289 lines of code (exceeds 250 allowed). Consider refactoring.
module RSpec
module Matchers
module BuiltIn
# @api private
# Provides the implementation for `change`.
File matchers.rb
has 271 lines of code (exceeds 250 allowed). Consider refactoring.
require 'rspec/support'
RSpec::Support.require_rspec_support 'matcher_definition'
RSpec::Support.define_optimized_require_for_rspec(:matchers) { |f| require_relative(f) }
%w[
Class YieldControl
has 23 methods (exceeds 20 allowed). Consider refactoring.
class YieldControl < BaseMatcher # rubocop:disable ClassLength
def initialize
@expectation_type = @expected_yields_count = nil
end
Class MultipleExpectationsNotMetError
has 21 methods (exceeds 20 allowed). Consider refactoring.
class MultipleExpectationsNotMetError
# @return [String] The fully formatted exception message.
def message
@message ||= (["#{summary}:"] + enumerated_failures + enumerated_errors).join("\n\n")
end
Method excluded_from_actual
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
def excluded_from_actual
return [] unless @actual.respond_to?(:include?)
expecteds.inject([]) do |memo, expected_item|
if comparing_hash_to_a_subset?(expected_item)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method matches?
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
def matches?(given_proc)
@block = given_proc
return false unless Proc === given_proc
begin
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method matches?
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
def matches?(given_proc, negative_expectation=false, &block)
@given_proc = given_proc
@block ||= block
@raised_expected_error = false
@with_expected_message = false
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method with_arity
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
def with_arity
str = ''.dup
str << " with #{with_arity_string}" if @expected_arity
str << " #{str.length == 0 ? 'with' : 'and'} #{with_keywords_string}" if @expected_keywords && @expected_keywords.count > 0
str << " #{str.length == 0 ? 'with' : 'and'} unlimited arguments" if @unlimited_arguments
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method matches?
has 39 lines of code (exceeds 25 allowed). Consider refactoring.
def matches?(given_proc)
@block = given_proc
return false unless Proc === given_proc
begin
Method set_expected_yields_count
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
def set_expected_yields_count(relativity, n)
raise_unsupported_yield_expectation if unsupported_yield_expectation?(relativity)
count = count_constraint_to_number(n)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method surface_descriptions_in
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
def surface_descriptions_in(item)
if Matchers.is_a_describable_matcher?(item)
DescribableItem.new(item)
elsif Hash === item
Hash[surface_descriptions_in(item.to_a)]
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method after_opener_state
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
def after_opener_state(token)
if handle_closer_token(token)
finish_or_find_next_block_if_incorrect!
elsif pipe_token?(token)
finalize_pending_tokens!
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method initialize
has 5 arguments (exceeds 4 allowed). Consider refactoring.
def initialize(name, declarations, matcher_execution_context, *expected, &block_arg)
Method matches?
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
def matches?(block)
@actual_formatted = []
@actual = []
args_matched_when_yielded = true
yield_count = 0
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method warn_for_negative_false_positives!
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
def warn_for_negative_false_positives!
expression = if expecting_specific_exception? && @expected_message
"`expect { }.not_to raise_error(SpecificErrorClass, message)`"
elsif expecting_specific_exception?
"`expect { }.not_to raise_error(SpecificErrorClass)`"
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method handle_matcher
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
def self.handle_matcher(actual, initial_matcher, custom_message=nil, &block)
ExpectationHelper.with_matcher(self, initial_matcher, custom_message) do |matcher|
return ::RSpec::Matchers::BuiltIn::NegativeOperatorMatcher.new(actual) unless initial_matcher
negated_match_result = does_not_match?(matcher, actual, &block)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method match
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
def match(options={}, &match_block)
define_user_override(:matches?, match_block) do |actual|
@actual = actual
RSpec::Support.with_failure_notifier(RAISE_NOTIFIER) do
begin
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method handle_matcher
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
def self.handle_matcher(actual, initial_matcher, custom_message=nil, &block)
ExpectationHelper.with_matcher(self, initial_matcher, custom_message) do |matcher|
return ::RSpec::Matchers::BuiltIn::PositiveOperatorMatcher.new(actual) unless initial_matcher
match_result = matcher.matches?(actual, &block)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method failure_message
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
def failure_message
return not_given_a_block_failure unless Proc === @event_proc
return before_value_failure unless @matches_before
return did_not_change_failure unless @change_details.changed?
after_value_failure
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method with_matchers_cloned
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
def with_matchers_cloned(object)
if Matchers.is_a_matcher?(object)
object.clone
elsif Hash === object
Hash[with_matchers_cloned(object.to_a)]
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method is_a_matcher?
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
def self.is_a_matcher?(obj)
return true if ::RSpec::Matchers::BuiltIn::BaseMatcher === obj
begin
return false if obj.respond_to?(:i_respond_to_everything_so_im_not_really_a_matcher)
rescue NoMethodError
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method perform_match
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
def perform_match(predicate, hash_subset_predicate)
return false unless actual.respond_to?(:include?)
expected.__send__(predicate) do |expected_item|
if comparing_hash_to_a_subset?(expected_item)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method diffs
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
def diffs(differ, actual)
@expected_list.map do |(expected, diff_label)|
diff = differ.diff(actual, expected)
next if diff.strip.empty?
if diff == "\e[0m\n\e[0m"
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method match_captures
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
def match_captures(expected, actual)
match = actual.match(expected)
if match
match = ReliableMatchData.new(match)
if match.names.empty?
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method for
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
def self.for(value, block)
if UndefinedValue.equal?(value)
unless block
raise ArgumentError, "You must pass either an argument or a block to `expect`."
end
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method append_features
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
def append_features(mod)
return super if mod < self # `mod < self` indicates a re-inclusion.
subclasses = ObjectSpace.each_object(Class).select { |c| c < mod && c < self }
return super unless subclasses.any?
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method throw_description
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
def throw_description(symbol, arg)
symbol_description = symbol.is_a?(String) ? symbol : description_of(symbol)
arg_description = if arg
" with #{description_of arg}"
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"