rspec/rspec-mocks

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

Summary

Maintainability
C
1 day
Test Coverage

Class ErrorGenerator has 48 methods (exceeds 20 allowed). Consider refactoring.

    class ErrorGenerator
      attr_writer :opts

      def initialize(target=nil)
        @target = target
Severity: Minor
Found in lib/rspec/mocks/error_generator.rb - About 6 hrs to fix

    File error_generator.rb has 262 lines of code (exceeds 250 allowed). Consider refactoring.

    RSpec::Support.require_rspec_support "object_formatter"
    
    module RSpec
      module Mocks
        # Raised when a message expectation is not satisfied.
    Severity: Minor
    Found in lib/rspec/mocks/error_generator.rb - About 2 hrs to fix

      Method raise_expectation_error has 8 arguments (exceeds 4 allowed). Consider refactoring.

            def raise_expectation_error(message, expected_received_count, argument_list_matcher,
                                        actual_received_count, expectation_count_type, args,
                                        backtrace_line=nil, source_id=nil)
      Severity: Major
      Found in lib/rspec/mocks/error_generator.rb - About 1 hr to fix

        Method describe_expectation has 5 arguments (exceeds 4 allowed). Consider refactoring.

              def describe_expectation(verb, message, expected_received_count, _actual_received_count, args)
        Severity: Minor
        Found in lib/rspec/mocks/error_generator.rb - About 35 mins to fix

          Method raise_unimplemented_error has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.

                def raise_unimplemented_error(doubled_module, method_name, object)
                  message = case object
                            when InstanceVerifyingDouble
                              "the %s class does not implement the instance method: %s".dup <<
                                if ObjectMethodReference.for(doubled_module, method_name).implemented?
          Severity: Minor
          Found in lib/rspec/mocks/error_generator.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