rest-client/rest-client

View on GitHub
lib/restclient/request.rb

Summary

Maintainability
F
4 days
Test Coverage

Method transmit has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring.
Open

    def transmit uri, req, payload, & block

      # We set this to true in the net/http block so that we can distinguish
      # read_timeout from open_timeout. Now that we only support Ruby 2.0+,
      # this is only needed for Timeout exceptions thrown outside of Net::HTTP.
Severity: Minor
Found in lib/restclient/request.rb - About 1 day 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

File request.rb has 481 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'tempfile'
require 'cgi'
require 'netrc'
require 'set'

Severity: Minor
Found in lib/restclient/request.rb - About 7 hrs to fix

    Class Request has 33 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class Request
    
        attr_reader :method, :uri, :url, :headers, :payload, :proxy,
                    :user, :password, :read_timeout, :max_redirects,
                    :open_timeout, :raw_response, :processed_headers, :args,
    Severity: Minor
    Found in lib/restclient/request.rb - About 4 hrs to fix

      Method initialize has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
      Open

          def initialize args
            @method = normalize_method(args[:method])
            @headers = (args[:headers] || {}).dup
            if args[:url]
              @url = process_url_params(normalize_url(args[:url]), headers)
      Severity: Minor
      Found in lib/restclient/request.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 transmit has 85 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def transmit uri, req, payload, & block
      
            # We set this to true in the net/http block so that we can distinguish
            # read_timeout from open_timeout. Now that we only support Ruby 2.0+,
            # this is only needed for Timeout exceptions thrown outside of Net::HTTP.
      Severity: Major
      Found in lib/restclient/request.rb - About 3 hrs to fix

        Method initialize has 63 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def initialize args
              @method = normalize_method(args[:method])
              @headers = (args[:headers] || {}).dup
              if args[:url]
                @url = process_url_params(normalize_url(args[:url]), headers)
        Severity: Major
        Found in lib/restclient/request.rb - About 2 hrs to fix

          Method process_url_params has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

              def process_url_params(url, headers)
                url_params = nil
          
                # find and extract/remove "params" key if the value is a Hash/ParamsArray
                headers.delete_if do |key, value|
          Severity: Minor
          Found in lib/restclient/request.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 process_cookie_args! has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              def process_cookie_args!(uri, headers, args)
          
                # Avoid ambiguity in whether options from headers or options from
                # Request#initialize should take precedence by raising ArgumentError when
                # both are present. Prior versions of rest-client claimed to give
          Severity: Minor
          Found in lib/restclient/request.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 fetch_body_to_tempfile has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              def fetch_body_to_tempfile(http_response)
                # Taken from Chef, which as in turn...
                # Stolen from http://www.ruby-forum.com/topic/166423
                # Kudos to _why!
                tf = Tempfile.new('rest-client.')
          Severity: Minor
          Found in lib/restclient/request.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 stringify_headers has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              def stringify_headers headers
                headers.inject({}) do |result, (key, value)|
                  if key.is_a? Symbol
                    key = key.to_s.split(/_/).map(&:capitalize).join('-')
                  end
          Severity: Minor
          Found in lib/restclient/request.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 proxy_uri has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def proxy_uri
                if defined?(@proxy)
                  if @proxy
                    URI.parse(@proxy)
                  else
          Severity: Minor
          Found in lib/restclient/request.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 default_ssl_cert_store has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def self.default_ssl_cert_store
                cert_store = OpenSSL::X509::Store.new
                cert_store.set_default_paths
          
                # set_default_paths() doesn't do anything on Windows, so look up
          Severity: Minor
          Found in lib/restclient/request.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 make_headers has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def make_headers(user_headers)
                headers = stringify_headers(default_headers).merge(stringify_headers(user_headers))
          
                # override headers from the payload (e.g. Content-Type, Content-Length)
                if @payload
          Severity: Minor
          Found in lib/restclient/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 process_result has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def process_result(res, start_time, tempfile=nil, &block)
                if @raw_response
                  unless tempfile
                    raise ArgumentError.new('tempfile is required')
                  end
          Severity: Minor
          Found in lib/restclient/request.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