rest-client/rest-client

View on GitHub

Showing 31 of 31 total issues

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

            def self.flatten_params(object, uri_escape=false, parent_key=nil)
              unless object.is_a?(Hash) || object.is_a?(ParamsArray) ||
                     (parent_key && object.is_a?(Array))
                raise ArgumentError.new('expected Hash or ParamsArray, got: ' + object.inspect)
              end
        Severity: Minor
        Found in lib/restclient/utils.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 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 generate has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

              def generate(params)
                if params.is_a?(RestClient::Payload::Base)
                  # pass through Payload objects unchanged
                  params
                elsif params.is_a?(String)
          Severity: Minor
          Found in lib/restclient/payload.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 create_log has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def self.create_log param
              if param
                if param.is_a? String
                  if param == 'stdout'
                    stdout_logger = Class.new do
          Severity: Minor
          Found in lib/restclient.rb - About 1 hr to fix

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

                def self.get_encoding_from_headers(headers)
                  type_header = headers[:content_type]
                  return nil unless type_header
            
                  # TODO: remove this hack once we drop support for Ruby 2.0
            Severity: Minor
            Found in lib/restclient/utils.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 create_log has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

              def self.create_log param
                if param
                  if param.is_a? String
                    if param == 'stdout'
                      stdout_logger = Class.new do
            Severity: Minor
            Found in lib/restclient.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 create_file_field has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                  def create_file_field(s, k, v)
                    begin
                      s.write("Content-Disposition: form-data;")
                      s.write(" name=\"#{k}\";") unless (k.nil? || k=='')
                      s.write(" filename=\"#{v.respond_to?(:original_filename) ? v.original_filename : File.basename(v.path)}\"#{EOL}")
            Severity: Minor
            Found in lib/restclient/payload.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 _cgi_parseparam has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def self._cgi_parseparam(s)
                  return enum_for(__method__, s) unless block_given?
            
                  while s[0] == ';'
                    s = s[1..-1]
            Severity: Minor
            Found in lib/restclient/utils.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

            Severity
            Category
            Status
            Source
            Language