bblimke/webmock

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

Summary

Maintainability
B
4 hrs
Test Coverage

Method request has a Cognitive Complexity of 16 (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 34 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, request_uri, &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 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