rspec/rspec-mocks

View on GitHub
lib/rspec/mocks/message_expectation.rb

Summary

Maintainability
D
2 days
Test Coverage

Class MessageExpectation has 58 methods (exceeds 20 allowed). Consider refactoring.

    class MessageExpectation
      # @!group Configuring Responses

      # @overload and_return(value)
      # @overload and_return(first_value, second_value)
Severity: Major
Found in lib/rspec/mocks/message_expectation.rb - About 1 day to fix

    File message_expectation.rb has 441 lines of code (exceeds 250 allowed). Consider refactoring.

    RSpec::Support.require_rspec_support 'mutex'
    
    module RSpec
      module Mocks
        # A message expectation that only allows concrete return values to be set
    Severity: Minor
    Found in lib/rspec/mocks/message_expectation.rb - About 6 hrs to fix

      Method call has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.

            def call(*_args_to_ignore, &block)
              return if @args_to_yield.empty? && @eval_context.nil?
      
              @error_generator.raise_missing_block_error @args_to_yield unless block
              value = nil
      Severity: Minor
      Found in lib/rspec/mocks/message_expectation.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 initialize has 7 arguments (exceeds 4 allowed). Consider refactoring.

              def initialize(error_generator, expectation_ordering, expected_from, method_double,
                             type=:expectation, opts={}, &implementation_block)
      Severity: Major
      Found in lib/rspec/mocks/message_expectation.rb - About 50 mins to fix

        Method invoke_incrementing_actual_calls_by has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.

                def invoke_incrementing_actual_calls_by(increment, allowed_to_fail, parent_stub, *args, &block)
                  args.unshift(orig_object) if yield_receiver_to_implementation_block?
        
                  if negative? || (allowed_to_fail && (@exactly || @at_most) && (@actual_received_count == @expected_received_count))
                    # args are the args we actually received, @argument_list_matcher is the
        Severity: Minor
        Found in lib/rspec/mocks/message_expectation.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 invoke_incrementing_actual_calls_by has 5 arguments (exceeds 4 allowed). Consider refactoring.

                def invoke_incrementing_actual_calls_by(increment, allowed_to_fail, parent_stub, *args, &block)
        Severity: Minor
        Found in lib/rspec/mocks/message_expectation.rb - About 35 mins to fix

          Method and_return has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.

                def and_return(first_value, *values)
                  raise_already_invoked_error_if_necessary(__method__)
                  if negative?
                    raise "`and_return` is not supported with negative message expectations"
                  end
          Severity: Minor
          Found in lib/rspec/mocks/message_expectation.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

          There are no issues that match your filters.

          Category