bblimke/webmock

View on GitHub

Showing 70 of 70 total issues

Method fill_accumulator_for_subscript has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

      def fill_accumulator_for_subscript(accumulator, key, value)
        current_node = accumulator
        subkeys = key.split(/(?=\[[^\[\]]+)/)
        subkeys[0..-2].each do |subkey|
          node = subkey =~ /\[\]\z/ ? [] : {}
Severity: Minor
Found in lib/webmock/util/query_mapper.rb - About 4 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 parse_header_string has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

        def self.parse_header_string(header_string)
          status, headers = nil, {}

          header_string.split(/\r\n/).each do |header|
            if header =~ %r|^HTTP/1.[01] \d\d\d (.*)|
Severity: Minor
Found in lib/webmock/http_lib_adapters/curb_adapter.rb - About 4 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

File request_pattern.rb has 310 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module WebMock

  module RSpecMatcherDetector
    def rSpecHashIncludingMatcher?(matcher)
      matcher.class.name =~ /R?Spec::Mocks::ArgumentMatchers::HashIncludingMatcher/
Severity: Minor
Found in lib/webmock/request_pattern.rb - About 3 hrs to fix

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

          def invoke_curb_callbacks
            @on_progress.call(0.0,1.0,0.0,1.0) if defined?( @on_progress )
            self.header_str.lines.each { |header_line| @on_header.call header_line } if defined?( @on_header )
            if defined?( @on_body )
              if chunked_response?
    Severity: Minor
    Found in lib/webmock/http_lib_adapters/curb_adapter.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 build_curb_response has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

          def build_curb_response(webmock_response)
            raise Curl::Err::TimeoutError if webmock_response.should_timeout
            webmock_response.raise_error_if_any
    
            @body_str = webmock_response.body
    Severity: Minor
    Found in lib/webmock/http_lib_adapters/curb_adapter.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 make_raw_response has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

          def make_raw_response(response)
            response.raise_error_if_any
    
            status, headers, body = response.status, response.headers, response.body
            headers ||= {}
    Severity: Minor
    Found in lib/webmock/http_lib_adapters/em_http_request_adapter.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

    File net_http.rb has 292 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'net/http'
    require 'net/https'
    require 'stringio'
    require File.join(File.dirname(__FILE__), 'net_http_response')
    
    
    Severity: Minor
    Found in lib/webmock/http_lib_adapters/net_http.rb - About 3 hrs to fix

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

          class WebMockCurlEasy < Curl::Easy
            def curb_or_webmock
              request_signature = build_request_signature
              WebMock::RequestRegistry.instance.requested_signatures.put(request_signature)
      
      
      Severity: Minor
      Found in lib/webmock/http_lib_adapters/curb_adapter.rb - About 3 hrs to fix

        File curb_adapter.rb has 290 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        begin
          require 'curb'
        rescue LoadError
          # curb not found
        end
        Severity: Minor
        Found in lib/webmock/http_lib_adapters/curb_adapter.rb - About 2 hrs to fix

          Method request has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
          Open

                  def request(request, body = nil, &block)
                    request_signature = WebMock::NetHTTPUtility.request_signature_from_request(self, request, body)
          
                    WebMock::RequestRegistry.instance.requested_signatures.put(request_signature)
          
          
          Severity: Minor
          Found in lib/webmock/http_lib_adapters/net_http.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 values_to_query has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
          Open

                def values_to_query(new_query_values, options = {})
                  options[:notation] ||= :subscript
                  return if new_query_values.nil?
          
                  unless new_query_values.is_a?(Array)
          Severity: Minor
          Found in lib/webmock/util/query_mapper.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 matching_body_hashes? has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
          Open

              def matching_body_hashes?(query_parameters, pattern, content_type)
                return false unless query_parameters.is_a?(Hash)
                return false unless query_parameters.keys.sort == pattern.keys.sort
                query_parameters.each do |key, actual|
                  expected = pattern[key]
          Severity: Minor
          Found in lib/webmock/request_pattern.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 do_get has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
          Open

              def do_get(req, proxy, conn, stream = false, &block)
                request_signature = build_request_signature(req, :reuse_existing)
          
                WebMock::RequestRegistry.instance.requested_signatures.put(request_signature)
          
          
          Severity: Minor
          Found in lib/webmock/http_lib_adapters/httpclient_adapter.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 convert_json_to_yaml has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

                def self.convert_json_to_yaml(json) #:nodoc:
                  scanner, quoting, marks, times = StringScanner.new(json), false, [], []
                  while scanner.scan_until(/(\\['"]|['":,\\]|\\.)/)
                    case char = scanner[1]
                    when '"', "'"
          Severity: Minor
          Found in lib/webmock/util/json.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 stringify_keys! has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

                def self.stringify_keys!(arg, options = {})
                  case arg
                  when Array
                    arg.map { |elem|
                      options[:deep] ? stringify_keys!(elem, options) : elem
          Severity: Minor
          Found in lib/webmock/util/hash_keys_stringifier.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 fill_accumulator_for_subscript has 45 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def fill_accumulator_for_subscript(accumulator, key, value)
                  current_node = accumulator
                  subkeys = key.split(/(?=\[[^\[\]]+)/)
                  subkeys[0..-2].each do |subkey|
                    node = subkey =~ /\[\]\z/ ? [] : {}
          Severity: Minor
          Found in lib/webmock/util/query_mapper.rb - About 1 hr to fix

            Method build_request_signature has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

                    def self.build_request_signature(req)
                      uri = WebMock::Util::URI.heuristic_parse(req.url)
                      uri.path = uri.normalized_path.gsub("[^:]//","/")
            
                      if [:put, :post, :patch].include?(req.action)
            Severity: Minor
            Found in lib/webmock/http_lib_adapters/patron_adapter.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 13 (exceeds 5 allowed). Consider refactoring.
            Open

                    def call(request)
                      request.scheme ||= self.scheme
                      request.authority ||= self.authority
            
                      request_signature = build_request_signature(request)
            Severity: Minor
            Found in lib/webmock/http_lib_adapters/async_http_client_adapter.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 request has 39 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    def request(request, body = nil, &block)
                      request_signature = WebMock::NetHTTPUtility.request_signature_from_request(self, request, body)
            
                      WebMock::RequestRegistry.instance.requested_signatures.put(request_signature)
            
            
            Severity: Minor
            Found in lib/webmock/http_lib_adapters/net_http.rb - About 1 hr to fix

              Method build_request_signature has 39 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    def build_request_signature
                      method = @webmock_method.to_s.downcase.to_sym
              
                      uri = WebMock::Util::URI.heuristic_parse(self.url)
                      uri.path = uri.normalized_path.gsub("[^:]//","/")
              Severity: Minor
              Found in lib/webmock/http_lib_adapters/curb_adapter.rb - About 1 hr to fix
                Severity
                Category
                Status
                Source
                Language