lostisland/faraday

View on GitHub

Showing 43 of 46 total issues

Class Options has 27 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Options < Struct
    # Public
    def self.from(value)
      value ? new.update(value) : new
    end
Severity: Minor
Found in lib/faraday/options.rb - About 3 hrs to fix

    Class Connection has 26 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class Connection
        # A Set of allowed HTTP verbs.
        METHODS = Set.new %i[get post put delete head patch options trace]
    
        # @return [Hash] URI query unencoded key/value pairs.
    Severity: Minor
    Found in lib/faraday/connection.rb - About 3 hrs to fix

      Class RackBuilder has 25 methods (exceeds 20 allowed). Consider refactoring.
      Open

        class RackBuilder
          # Used to detect missing arguments
          NO_ARGUMENT = Object.new
      
          attr_accessor :handlers
      Severity: Minor
      Found in lib/faraday/rack_builder.rb - About 2 hrs to fix

        Method encode has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

            def self.encode(params)
              return nil if params.nil?
        
              unless params.is_a?(Array)
                unless params.respond_to?(:to_hash)
        Severity: Minor
        Found in lib/faraday/encoders/flat_params_encoder.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 call has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

              def call(env)
                super
                # TODO: support streaming requests
                env[:body] = env[:body].read if env[:body].respond_to? :read
        
        
        Severity: Minor
        Found in lib/faraday/adapter/patron.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 call has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

              def call(env)
                super
                request = create_request(env)
        
                http_method = env[:method].to_s.downcase.to_sym
        Severity: Minor
        Found in lib/faraday/adapter/em_synchrony.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 call has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

              def call(env)
                retries = @options.max
                request_body = env[:body]
                begin
                  # after failure env[:body] is set to the response body
        Severity: Minor
        Found in lib/faraday/request/retry.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 perform_request has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

              def perform_request(env)
                if parallel?(env)
                  manager = env[:parallel_manager]
                  manager.add do
                    perform_single_request(env)
        Severity: Minor
        Found in lib/faraday/adapter/em_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 perform_request has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def perform_request(env)
                if parallel?(env)
                  manager = env[:parallel_manager]
                  manager.add do
                    perform_single_request(env)
        Severity: Minor
        Found in lib/faraday/adapter/em_http.rb - About 1 hr to fix

          Method decode has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              def self.decode(query)
                return nil if query.nil?
          
                empty_accumulator = {}
          
          
          Severity: Minor
          Found in lib/faraday/encoders/flat_params_encoder.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 encode has 33 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def self.encode(params)
                return nil if params.nil?
          
                unless params.is_a?(Array)
                  unless params.respond_to?(:to_hash)
          Severity: Minor
          Found in lib/faraday/encoders/flat_params_encoder.rb - About 1 hr to fix

            Method encode has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                def encode(params)
                  return nil if params.nil?
            
                  unless params.is_a?(Array)
                    unless params.respond_to?(:to_hash)
            Severity: Minor
            Found in lib/faraday/encoders/nested_params_encoder.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 build_exclusive_url has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                def build_exclusive_url(url = nil, params = nil, params_encoder = nil)
                  url = nil if url.respond_to?(:empty?) && url.empty?
                  base = url_prefix
                  if url && base.path && base.path !~ %r{/$}
                    base = base.dup
            Severity: Minor
            Found in lib/faraday/connection.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_params has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                  def process_params(params, prefix = nil, pieces = nil, &block)
                    params.inject(pieces || []) do |all, (key, value)|
                      if prefix
                        key = @options[:flat_encode] ? prefix.to_s : "#{prefix}[#{key}]"
                      end
            Severity: Minor
            Found in lib/faraday/request/multipart.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 call has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                  def call(env)
                    super
            
                    # TODO: Don't stream yet.
                    # https://github.com/nahi/httpclient/pull/90
            Severity: Minor
            Found in lib/faraday/adapter/httpclient.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 call has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def call(env)
                    super
                    # TODO: support streaming requests
                    env[:body] = env[:body].read if env[:body].respond_to? :read
            
            
            Severity: Minor
            Found in lib/faraday/adapter/patron.rb - About 1 hr to fix

              Method call has 30 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    def call(env)
                      super
              
                      # TODO: Don't stream yet.
                      # https://github.com/nahi/httpclient/pull/90
              Severity: Minor
              Found in lib/faraday/adapter/httpclient.rb - About 1 hr to fix

                Method call has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                      def call(env)
                        super
                        request = create_request(env)
                
                        http_method = env[:method].to_s.downcase.to_sym
                Severity: Minor
                Found in lib/faraday/adapter/em_synchrony.rb - About 1 hr to fix

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

                        def has_multipart?(obj) # rubocop:disable Naming/PredicateName
                          if obj.respond_to?(:each)
                            (obj.respond_to?(:values) ? obj.values : obj).each do |val|
                              return true if val.respond_to?(:content_type) || has_multipart?(val)
                            end
                  Severity: Minor
                  Found in lib/faraday/request/multipart.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 update has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def update(obj)
                        obj.each do |key, value|
                          sub_options = self.class.options_for(key)
                          if sub_options
                            new_value = sub_options.from(value) if value
                  Severity: Minor
                  Found in lib/faraday/options.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

                  Severity
                  Category
                  Status
                  Source
                  Language