typhoeus/typhoeus

View on GitHub

Showing 9 of 9 total issues

Method request has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

      def request(env)
        read_body env

        req = typhoeus_request(env)

Severity: Minor
Found in lib/typhoeus/adapters/faraday.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 response_headers has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

      def response_headers
        return options[:response_headers] if options[:response_headers]
        if mock? && h = options[:headers]
            status_code = return_code || "200"
            reason_phrase = status_code == "200" ? "OK" : "Mock Reason Phrase"
Severity: Minor
Found in lib/typhoeus/response/informations.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 set_callback has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def set_callback
      if request.streaming?
        response = nil
        easy.on_headers do |easy|
          response = Response.new(Ethon::Easy::Mirror.from_easy(easy).options)
Severity: Minor
Found in lib/typhoeus/easy_factory.rb - About 1 hr to fix

    Method sanitize has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def sanitize(options)
          # set nosignal to true by default
          # this improves thread safety and timeout behavior
          sanitized = {:nosignal => true}
          options.each do |k,v|
    Severity: Minor
    Found in lib/typhoeus/easy_factory.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 configure_ssl has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

          def configure_ssl(req, env)
            ssl = env[:ssl]
    
            verify_p = (ssl && ssl.fetch(:verify, true))
    
    
    Severity: Minor
    Found in lib/typhoeus/adapters/faraday.rb - About 55 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 set_defaults has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def set_defaults
          default_user_agent = Config.user_agent || Typhoeus::USER_AGENT
    
          options[:headers] = {'User-Agent' => default_user_agent}.merge(options[:headers] || {})
          options[:headers]['Expect'] ||= ''
    Severity: Minor
    Found in lib/typhoeus/request.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 status_message has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def status_message
            return @status_message if defined?(@status_message) && @status_message
            return options[:status_message] unless options[:status_message].nil?
    
            # HTTP servers can choose not to include the explanation to HTTP codes. The RFC
    Severity: Minor
    Found in lib/typhoeus/response/status.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 parse has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def parse
            case @raw
            when Hash
              raw.each do |k, v|
                process_pair(k, v)
    Severity: Minor
    Found in lib/typhoeus/response/header.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 encoded? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

              def encoded?(hash)
                return false if hash.empty?
                  if hash.keys.size > 1
                  keys = hash.keys.map{|i| i.to_i if i.respond_to?(:to_i)}.sort
                  keys == hash.keys.size.times.to_a
    Severity: Minor
    Found in lib/rack/typhoeus/middleware/params_decoder/helper.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