bblimke/webmock

View on GitHub

Showing 61 of 71 total issues

Avoid deeply nested control flow statements.
Open

                  headers[parts[0]] = [headers[parts[0]]] unless headers[parts[0]].kind_of? Array
Severity: Major
Found in lib/webmock/http_lib_adapters/curb_adapter.rb - About 45 mins to fix

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

        def do_get(req, proxy, conn, stream = false, &block)
    Severity: Minor
    Found in lib/webmock/http_lib_adapters/httpclient_adapter.rb - About 35 mins to fix

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

                endpoint,
                protocol = endpoint.protocol,
                scheme = endpoint.scheme,
                authority = endpoint.authority,
                **options
      Severity: Minor
      Found in lib/webmock/http_lib_adapters/async_http_client_adapter.rb - About 35 mins to fix

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

            def do_request_async(method, uri, query, body, extheader)
        Severity: Minor
        Found in lib/webmock/http_lib_adapters/httpclient_adapter.rb - About 35 mins to fix

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

              def initialize(library_name, library_version, min_patch_level, max_minor_version = nil, unsupported_versions = [])
          Severity: Minor
          Found in lib/webmock/util/version_checker.rb - About 35 mins to fix

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

                  def build_request_signature
                    headers, body = build_request, @req.body
            
                    @conn.middleware.select {|m| m.respond_to?(:request) }.each do |m|
                      headers, body = m.request(self, headers, body)
            Severity: Minor
            Found in lib/webmock/http_lib_adapters/em_http_request_adapter.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

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

                def read_body(dest = nil, &block)
                  if !(defined?(@__read_body_previously_called).nil?) && @__read_body_previously_called
                    return super
                  end
                  return @body if dest.nil? && block.nil?
            Severity: Minor
            Found in lib/webmock/http_lib_adapters/net_http_response.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

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

                  def curb_or_webmock
                    request_signature = build_request_signature
                    WebMock::RequestRegistry.instance.requested_signatures.put(request_signature)
            
                    if webmock_response = WebMock::StubRegistry.instance.response_for_request(request_signature)
            Severity: Minor
            Found in lib/webmock/http_lib_adapters/curb_adapter.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

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

                  def normalize_query_hash(query_hash, empty_accumulator, options)
                    query_hash.inject(empty_accumulator.dup) do |accumulator, (key, value)|
                      if options[:notation] == :flat_array
                        accumulator << [key, value]
                      else
            Severity: Minor
            Found in lib/webmock/util/query_mapper.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

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

                      def handle_request(req)
                        request_signature =
                          WebMock::HttpLibAdapters::PatronAdapter.build_request_signature(req)
            
                        WebMock::RequestRegistry.instance.requested_signatures.put(request_signature)
            Severity: Minor
            Found in lib/webmock/http_lib_adapters/patron_adapter.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

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

                def matches?(body, content_type = "")
                  assert_non_multipart_body(content_type)
            
                  if (@pattern).is_a?(Hash)
                    return true if @pattern.empty?
            Severity: Minor
            Found in lib/webmock/request_pattern.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

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

                  def from_webmock(request, webmock_response, request_signature = nil)
                    status  = Status.new(webmock_response.status.first)
                    headers = webmock_response.headers || {}
                    uri     = normalize_uri(request_signature && request_signature.uri)
            
            
            Severity: Minor
            Found in lib/webmock/http_lib_adapters/http_rb/response.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

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

                def self.invoke_callbacks(options, request_signature, response)
                  return if @@callbacks.empty?
                  CallbackRegistry.callbacks.each do |callback|
                    except = callback[:options][:except]
                    real_only = callback[:options][:real_requests_only]
            Severity: Minor
            Found in lib/webmock/callback_registry.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

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

                  def query_to_values(query, options={})
                    return nil if query.nil?
                    query = query.dup.force_encoding('utf-8') if query.respond_to?(:force_encoding)
            
                    options[:notation] ||= :subscript
            Severity: Minor
            Found in lib/webmock/util/query_mapper.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

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

              def self.net_connect_allowed?(uri = nil)
                return !!Config.instance.allow_net_connect if uri.nil?
            
                if uri.is_a?(String)
                  uri = WebMock::Util::URI.normalize_uri(uri)
            Severity: Minor
            Found in lib/webmock/webmock.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

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

                def self.from_request_signature(signature)
                  stub = self.new(signature.method.to_sym, signature.uri.to_s)
            
                  if signature.body.to_s != ''
                    body = if signature.url_encoded?
            Severity: Minor
            Found in lib/webmock/request_stub.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

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

                def to_s
                  if requested_signatures.hash.empty?
                    "No requests were made."
                  else
                    text = "".dup
            Severity: Minor
            Found in lib/webmock/request_registry.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

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

                def add_query_params(query_params)
                  @query_params = if query_params.is_a?(Hash)
                    query_params
                  elsif query_params.is_a?(WebMock::Matchers::HashIncludingMatcher) \
                          || query_params.is_a?(WebMock::Matchers::HashExcludingMatcher)
            Severity: Minor
            Found in lib/webmock/request_pattern.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

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

                def self.request_signature_from_request(net_http, request, body = nil)
                  path = request.path
            
                  if path.respond_to?(:request_uri) #https://github.com/bblimke/webmock/issues/288
                    path = path.request_uri
            Severity: Minor
            Found in lib/webmock/http_lib_adapters/net_http.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

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

                def build_request_signature(req, reuse_existing = false)
                  uri = WebMock::Util::URI.heuristic_parse(req.header.request_uri.to_s)
                  uri.query = WebMock::Util::QueryMapper.values_to_query(req.header.request_query, notation: WebMock::Config.instance.query_values_notation) if req.header.request_query
                  uri.port = req.header.request_uri.port
            
            
            Severity: Minor
            Found in lib/webmock/http_lib_adapters/httpclient_adapter.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

            Severity
            Category
            Status
            Source
            Language