rspec/rspec-mocks

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

Summary

Maintainability
D
1 day
Test Coverage

Class Proxy has 34 methods (exceeds 20 allowed). Consider refactoring.

    class Proxy
      # @private
      SpecificMessage = Struct.new(:object, :message, :args) do
        def ==(expectation)
          expectation.orig_object == object && expectation.matches?(message, *args)
Severity: Minor
Found in lib/rspec/mocks/proxy.rb - About 4 hrs to fix

    File proxy.rb has 340 lines of code (exceeds 250 allowed). Consider refactoring.

    module RSpec
      module Mocks
        # @private
        class Proxy
          # @private
    Severity: Minor
    Found in lib/rspec/mocks/proxy.rb - About 4 hrs to fix

      Method message_received has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.

            def message_received(message, *args, &block)
              record_message_received message, *args, &block
      
              expectation = find_matching_expectation(message, *args)
              stub = find_matching_method_stub(message, *args)
      Severity: Minor
      Found in lib/rspec/mocks/proxy.rb - About 3 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 replay_received_message_on has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.

            def replay_received_message_on(expectation, &block)
              expected_method_name = expectation.message
              meth_double = method_double_for(expected_method_name)
      
              if meth_double.expectations.any?
      Severity: Minor
      Found in lib/rspec/mocks/proxy.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 original_method_handle_for has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.

            def original_method_handle_for(message)
              unbound_method = superclass_proxy &&
                superclass_proxy.original_unbound_method_handle_from_ancestor_for(message.to_sym)
      
              return super unless unbound_method
      Severity: Minor
      Found in lib/rspec/mocks/proxy.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 find_best_matching_expectation_for has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.

            def find_best_matching_expectation_for(method_name)
              first_match = nil
      
              method_double_for(method_name).expectations.each do |expectation|
                next unless yield expectation
      Severity: Minor
      Found in lib/rspec/mocks/proxy.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 check_for_unexpected_arguments has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.

            def check_for_unexpected_arguments(expectation)
              @messages_received_mutex.synchronize do
                return if @messages_received.empty?
      
                return if @messages_received.any? { |method_name, args, _| expectation.matches?(method_name, *args) }
      Severity: Minor
      Found in lib/rspec/mocks/proxy.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

      There are no issues that match your filters.

      Category