rspec/rspec-expectations

View on GitHub

Showing 40 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

Severity: Minor
Found in lib/rspec/expectations/block_snippet_extractor.rb - About 5 hrs to fix

    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
    Severity: Minor
    Found in lib/rspec/matchers/built_in/yield.rb - About 4 hrs to fix

      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
      Severity: Minor
      Found in lib/rspec/matchers/built_in/raise_error.rb - About 3 hrs to fix

        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`.
        Severity: Minor
        Found in lib/rspec/matchers/built_in/change.rb - About 2 hrs to fix

          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[
          Severity: Minor
          Found in lib/rspec/matchers.rb - About 2 hrs to fix

            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
            
            
            Severity: Minor
            Found in lib/rspec/matchers/built_in/yield.rb - About 2 hrs to fix

              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
              Severity: Minor
              Found in lib/rspec/expectations/failure_aggregator.rb - About 2 hrs to fix

                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
                Severity: Minor
                Found in lib/rspec/matchers/built_in/throw_symbol.rb - About 2 hrs to fix

                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 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)
                Severity: Minor
                Found in lib/rspec/matchers/built_in/include.rb - About 2 hrs to fix

                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
                Severity: Minor
                Found in lib/rspec/matchers/built_in/raise_error.rb - About 1 hr to fix

                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
                Severity: Minor
                Found in lib/rspec/matchers/built_in/respond_to.rb - About 1 hr to fix

                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
                Severity: Minor
                Found in lib/rspec/matchers/built_in/throw_symbol.rb - About 1 hr to fix

                  Similar blocks of code found in 2 locations. 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)
                  Severity: Minor
                  Found in lib/rspec/expectations/handler.rb and 1 other location - About 1 hr to fix
                  lib/rspec/expectations/handler.rb on lines 47..57

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 47.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Similar blocks of code found in 2 locations. 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)
                  Severity: Minor
                  Found in lib/rspec/expectations/handler.rb and 1 other location - About 1 hr to fix
                  lib/rspec/expectations/handler.rb on lines 75..85

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 47.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  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)
                  
                  
                  Severity: Minor
                  Found in lib/rspec/matchers/built_in/yield.rb - About 55 mins to fix

                  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!
                  Severity: Minor
                  Found in lib/rspec/expectations/block_snippet_extractor.rb - About 45 mins to fix

                  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)]
                  Severity: Minor
                  Found in lib/rspec/matchers/composable.rb - About 45 mins to fix

                  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)
                  Severity: Minor
                  Found in lib/rspec/matchers/dsl.rb - About 35 mins to fix

                    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)
                    Severity: Minor
                    Found in lib/rspec/expectations/handler.rb - About 35 mins to fix

                    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
                    Severity: Minor
                    Found in lib/rspec/matchers/dsl.rb - About 35 mins to fix

                    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 7 (exceeds 5 allowed). Consider refactoring.

                            def matches?(block)
                              @actual_formatted = []
                              @actual = []
                              args_matched_when_yielded = true
                              yield_count = 0
                    Severity: Minor
                    Found in lib/rspec/matchers/built_in/yield.rb - About 35 mins to fix

                    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)`"
                    Severity: Minor
                    Found in lib/rspec/matchers/built_in/raise_error.rb - About 35 mins to fix

                    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)
                    Severity: Minor
                    Found in lib/rspec/expectations/handler.rb - About 35 mins to fix

                    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

                    Identical blocks of code found in 2 locations. Consider refactoring.

                            def diff_would_wrongly_highlight_matched_item?
                              return false unless actual.is_a?(String) && expected.is_a?(Array)
                    
                              lines = actual.split("\n")
                              expected.any? do |str|
                    Severity: Minor
                    Found in benchmarks/include_matcher.rb and 1 other location - About 25 mins to fix
                    lib/rspec/matchers/built_in/include.rb on lines 137..143

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 31.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Identical blocks of code found in 2 locations. Consider refactoring.

                            def diff_would_wrongly_highlight_matched_item?
                              return false unless actual.is_a?(String) && expected.is_a?(Array)
                    
                              lines = actual.split("\n")
                              expected.any? do |str|
                    Severity: Minor
                    Found in lib/rspec/matchers/built_in/include.rb and 1 other location - About 25 mins to fix
                    benchmarks/include_matcher.rb on lines 91..97

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 31.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    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}"
                    Severity: Minor
                    Found in lib/rspec/matchers/built_in/throw_symbol.rb - About 25 mins to fix

                    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?
                    Severity: Minor
                    Found in lib/rspec/matchers/built_in/match.rb - About 25 mins to fix

                    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

                    Similar blocks of code found in 2 locations. Consider refactoring.

                      x.report("Old `to include` failures") do
                        array_sizes.each do |n|
                          begin
                            expect([*1..n]).to old_include(*n+1..n*1.5)
                          rescue RSpec::Expectations::ExpectationNotMetError
                    Severity: Minor
                    Found in benchmarks/include_matcher.rb and 1 other location - About 25 mins to fix
                    benchmarks/include_matcher.rb on lines 139..144

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 30.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    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)
                    Severity: Minor
                    Found in benchmarks/include_matcher.rb - About 25 mins to fix

                    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)]
                    Severity: Minor
                    Found in lib/rspec/matchers/composable.rb - About 25 mins to fix

                    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
                    Severity: Minor
                    Found in lib/rspec/matchers/built_in/change.rb - About 25 mins to fix

                    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?
                    Severity: Minor
                    Found in lib/rspec/matchers.rb - About 25 mins to fix

                    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"
                    Severity: Minor
                    Found in lib/rspec/matchers/expecteds_for_multiple_diffs.rb - About 25 mins to fix

                    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
                    Severity: Minor
                    Found in lib/rspec/expectations/expectation_target.rb - About 25 mins to fix

                    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
                    Severity: Minor
                    Found in lib/rspec/matchers.rb - About 25 mins to fix

                    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

                    Similar blocks of code found in 2 locations. Consider refactoring.

                      x.report("New `to include` failures") do
                        array_sizes.each do |n|
                          begin
                            expect([*1..n]).to include(*n+1..n*1.5)
                          rescue RSpec::Expectations::ExpectationNotMetError
                    Severity: Minor
                    Found in benchmarks/include_matcher.rb and 1 other location - About 25 mins to fix
                    benchmarks/include_matcher.rb on lines 130..135

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 30.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Similar blocks of code found in 2 locations. Consider refactoring.

                      x.report("Old `to not include` failures") do
                        array_sizes.each do |n|
                          begin
                            expect([*1..n]).to_not old_include(*n/2..n)
                          rescue RSpec::Expectations::ExpectationNotMetError
                    Severity: Minor
                    Found in benchmarks/include_matcher.rb and 1 other location - About 20 mins to fix
                    benchmarks/include_matcher.rb on lines 177..182

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 28.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Similar blocks of code found in 2 locations. Consider refactoring.

                      x.report("New `to not include` failures") do
                        array_sizes.each do |n|
                          begin
                            expect([*1..n]).to_not include(*n/2..n)
                          rescue RSpec::Expectations::ExpectationNotMetError
                    Severity: Minor
                    Found in benchmarks/include_matcher.rb and 1 other location - About 20 mins to fix
                    benchmarks/include_matcher.rb on lines 168..173

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 28.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Identical blocks of code found in 2 locations. Consider refactoring.

                        expecteds.each do |expected|
                          bm.report("#{size.to_s.rjust(5)} items") do
                            begin
                              expect(actual).to match_array(expected)
                            rescue RSpec::Expectations::ExpectationNotMetError
                    Severity: Minor
                    Found in benchmarks/match_array/failing_with_duplicate_items.rb and 1 other location - About 20 mins to fix
                    benchmarks/match_array/failing_with_distinct_items.rb on lines 27..33

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 27.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Identical blocks of code found in 2 locations. Consider refactoring.

                        expecteds.each do |expected|
                          bm.report("#{size.to_s.rjust(5)} items") do
                            begin
                              expect(actual).to match_array(expected)
                            rescue RSpec::Expectations::ExpectationNotMetError
                    Severity: Minor
                    Found in benchmarks/match_array/failing_with_distinct_items.rb and 1 other location - About 20 mins to fix
                    benchmarks/match_array/failing_with_duplicate_items.rb on lines 24..30

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 27.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Severity
                    Category