bblimke/webmock

View on GitHub
lib/webmock/http_lib_adapters/net_http.rb

Summary

Maintainability
C
1 day
Test Coverage

File net_http.rb has 297 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

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

              def build_net_http_response(webmock_response, &block)
                response = Net::HTTPResponse.send(:response_class, webmock_response.status[0].to_s).new("1.0", webmock_response.status[0].to_s, webmock_response.status[1])
                body = webmock_response.body
                body = nil if webmock_response.status[0].to_s == '204'
      
      
      Severity: Minor
      Found in lib/webmock/http_lib_adapters/net_http.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 rbuf_fill has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

            def rbuf_fill
              case rv = @io.read_nonblock(BUFSIZE, nil, exception: false)
              when String
                return if rv.nil?
                @rbuf << rv
      Severity: Minor
      Found in lib/webmock/http_lib_adapters/net_http.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_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

      There are no issues that match your filters.

      Category
      Status