bblimke/webmock

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

Summary

Maintainability
D
2 days
Test Coverage

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

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

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 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

        Method build_request_signature has a Cognitive Complexity of 8 (exceeds 5 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 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

        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 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

          There are no issues that match your filters.

          Category
          Status