Showing 41 of 41 total issues

Class DoubleDefinition has 40 methods (exceeds 20 allowed). Consider refactoring.
Open

    class DoubleDefinition #:nodoc:
      ORIGINAL_METHOD = Object.new

      attr_accessor(
        :argument_expectation,
Severity: Minor
Found in lib/rr/double_definitions/double_definition.rb - About 5 hrs to fix

    Method wildcard_match? has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
    Open

      def wildcard_match?(other)
        return false unless other.is_a?(Hash)
    
        return false if size != other.size
    
    
    Severity: Minor
    Found in lib/rr/core_ext/hash.rb - About 5 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

    Class Double has 27 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class Double
        extend(Module.new do
          def formatted_name(method_name, args, kwargs)
            formatted_arguments =
              args.collect {|arg| arg.inspect} +
    Severity: Minor
    Found in lib/rr/double.rb - About 3 hrs to fix

      Class DoubleInjection has 26 methods (exceeds 20 allowed). Consider refactoring.
      Open

          class DoubleInjection < Injection
            extend(Module.new do
              def find_or_create(subject_class, method_name)
                instances[subject_class][method_name.to_sym] ||= begin
                  new(subject_class, method_name.to_sym).bind
      Severity: Minor
      Found in lib/rr/injections/double_injection.rb - About 3 hrs to fix

        Method find_all_matches has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
        Open

            def find_all_matches(args, kwargs)
              kwargs ||= {}
              @doubles.each do |double|
                if double.exact_match?(args, kwargs)
                  matching_doubles << double
        Severity: Minor
        Found in lib/rr/double_matches.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 wildcard_match? has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
        Open

              def wildcard_match?(arguments, keyword_arguments)
                return false unless arguments.length == expected_arguments.length
                arguments.each_with_index do |arg, index|
                  expected_argument = expected_arguments[index]
                  if expected_argument.respond_to?(:wildcard_match?)
        Severity: Minor
        Found in lib/rr/expectations/argument_equality_expectation.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 hook has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

              def hook
                assertion_error_class = self.assertion_error_class
                test_case_class.class_eval do
                  include RR::DSL
                  include Mixin
        Severity: Minor
        Found in lib/rr/integrations/minitest_4.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 bind_method has 40 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def bind_method
                id = BoundObjects.size
                BoundObjects[id] = subject_class
        
                if KeywordArguments.fully_supported?
        Severity: Minor
        Found in lib/rr/injections/method_missing_injection.rb - About 1 hr to fix

          Method wildcard_match? has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

            def wildcard_match?(other)
              return false unless other.is_a?(Array)
              return false unless size == other.size
          
              each_with_index do |value, i|
          Severity: Minor
          Found in lib/rr/core_ext/array.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 bind_method has 35 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def bind_method
                  id = BoundObjects.size
                  BoundObjects[id] = subject_class
          
                  if KeywordArguments.fully_supported?
          Severity: Minor
          Found in lib/rr/injections/double_injection.rb - About 1 hr to fix

            Method hook has 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def hook
                    assertion_error_class = self.assertion_error_class
                    test_case_class.class_eval do
                      include RR::DSL
                      include Mixin
            Severity: Minor
            Found in lib/rr/integrations/minitest_4.rb - About 1 hr to fix

              Method wildcard_match? has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                def wildcard_match?(other)
                  if is_a?(String)
                    return RR::Expectations::ArgumentEqualityExpectation.recursive_safe_eq(self, other)
                  end
                  return false unless other.is_a?(Enumerable)
              Severity: Minor
              Found in lib/rr/core_ext/enumerable.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 call has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                        def call(subject_class, stubbed_methods=nil, &block)
                          strategy_lambda = lambda do |double_definition_create|
                            ::RR::DoubleDefinitions::Strategies::DoubleInjection::AnyInstanceOf.new(double_definition_create)
                          end
                          ::RR::DoubleDefinitions::DoubleDefinitionCreate.set_default_double_injection_strategy(strategy_lambda) do
              Severity: Minor
              Found in lib/rr/double_definitions/double_injections/any_instance_of.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 wildcard_match? has 29 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    def wildcard_match?(arguments, keyword_arguments)
                      return false unless arguments.length == expected_arguments.length
                      arguments.each_with_index do |arg, index|
                        expected_argument = expected_arguments[index]
                        if expected_argument.respond_to?(:wildcard_match?)
              Severity: Minor
              Found in lib/rr/expectations/argument_equality_expectation.rb - About 1 hr to fix

                Method wildcard_match? has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def wildcard_match?(other)
                    return false unless other.is_a?(Hash)
                
                    return false if size != other.size
                
                
                Severity: Minor
                Found in lib/rr/core_ext/hash.rb - About 1 hr to fix

                  Method exact_match? has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def exact_match?(arguments, keyword_arguments)
                          return false unless arguments.length == expected_arguments.length
                          arguments.each_with_index do |arg, index|
                            expected_arg = expected_arguments[index]
                            return false unless self.class.recursive_safe_eq(expected_arg, arg)
                  Severity: Minor
                  Found in lib/rr/expectations/argument_equality_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 find_double_to_attempt has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def find_double_to_attempt
                          matches = DoubleMatches.new(doubles).find_all_matches(args, kwargs)
                  
                          unless matches.exact_terminal_doubles_to_attempt.empty?
                            return matches.exact_terminal_doubles_to_attempt.first
                  Severity: Minor
                  Found in lib/rr/method_dispatches/base_method_dispatch.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 call has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def call
                          if Injections::DoubleInjection.exists?(subject_class, method_name)
                            @double = find_double_to_attempt
                            if double
                              return_value = extract_subject_from_return_value(call_implementation)
                  Severity: Minor
                  Found in lib/rr/method_dispatches/method_missing_dispatch.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 dispatch_method has 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                          def dispatch_method(subject,
                                              subject_class,
                                              method_name,
                                              arguments,
                                              keyword_arguments,
                  Severity: Minor
                  Found in lib/rr/injections/double_injection.rb - About 45 mins to fix

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

                          def bind
                            unless class_instance_method_defined(subject_class, original_method_alias_name)
                              unless class_instance_method_defined(subject_class, :method_missing)
                                @placeholder_method_defined = true
                                subject_class.class_eval do
                    Severity: Minor
                    Found in lib/rr/injections/method_missing_injection.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

                    Severity
                    Category
                    Status
                    Source
                    Language