bblimke/webmock

View on GitHub

Showing 60 of 70 total issues

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

  def self.net_connect_explicit_allowed?(allowed, uri=nil)
    case allowed
    when Array
      allowed.any? { |allowed_item| net_connect_explicit_allowed?(allowed_item, uri) }
    when Regexp
Severity: Minor
Found in lib/webmock/webmock.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 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_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

          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 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 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 matching_body_array? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def matching_body_array?(query_parameters, pattern, content_type)
                return false unless query_parameters.is_a?(Array)
                return false unless query_parameters.length == pattern.length
          
                query_parameters.each_with_index do |actual, index|
          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 build_request_signature has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

                def build_request_signature
                  headers, body = headers_and_body_processed_by_middleware
          
                  method = @req.method
                  uri = @req.uri.clone
          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 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 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 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 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 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 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 handle_file_name has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

                  def self.handle_file_name(req, webmock_response)
                    if req.action == :get && req.file_name
                      begin
                        File.open(req.file_name, "w") do |f|
                          f.write webmock_response.body
          Severity: Minor
          Found in lib/webmock/http_lib_adapters/patron_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

          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 build_request_signature has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def build_request_signature(req, reuse_existing = false)
                @request_filter.each do |filter|
                  filter.filter_request(req)
                end
          
          
          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