liquidm/z-http-request

View on GitHub

Showing 20 of 20 total issues

Method extract_stream has a Cognitive Complexity of 75 (exceeds 5 allowed). Consider refactoring.
Open

    def extract_stream(compressed)
      @data << compressed
      pos = @pos

      while !eof? && !finished?
Severity: Minor
Found in lib/z-http/decoders.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

Method parse_response_header has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

    def parse_response_header(header, version, status)
      @response_header.raw = header
      header.each do |key, val|
        @response_header[key.upcase.gsub('-','_')] = val
      end
Severity: Minor
Found in lib/z-http/client.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 unbind has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    def unbind(reason = nil)
      if finished?
        if redirect?

          begin
Severity: Minor
Found in lib/z-http/client.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 extract_stream has 69 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def extract_stream(compressed)
      @data << compressed
      pos = @pos

      while !eof? && !finished?
Severity: Major
Found in lib/z-http/decoders.rb - About 2 hrs to fix

    Method parse_response_header has 53 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def parse_response_header(header, version, status)
          @response_header.raw = header
          header.each do |key, val|
            @response_header[key.upcase.gsub('-','_')] = val
          end
    Severity: Major
    Found in lib/z-http/client.rb - About 2 hrs to fix

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

          def build_request
            head    = @req.headers ? munge_header_keys(@req.headers) : {}
      
            if @conn.connopts.http_proxy?
              proxy = @conn.connopts.proxy
      Severity: Minor
      Found in lib/z-http/client.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_auth_digest has 44 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def build_auth_digest(method, uri, params = nil)
              params = @opts.merge(@digest_params) if !params
              nonce_count = next_nonce
      
              user = unescape params[:username]
      Severity: Minor
      Found in lib/z-http/middleware/digest_auth.rb - About 1 hr to fix

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

            tach('z-http-request (persistent)') do |n|
              ZMachine.run {
                count = 0
                error = 0
                conn = ZMachine::HttpRequest.new(url)
        Severity: Major
        Found in benchmarks/em-excon.rb and 1 other location - About 1 hr to fix
        benchmarks/clients.rb on lines 55..77

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 69.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

            tach('z-http-request (persistent)') do |n|
              ZMachine.run {
                count = 0
                error = 0
        
        
        Severity: Major
        Found in benchmarks/clients.rb and 1 other location - About 1 hr to fix
        benchmarks/em-excon.rb on lines 47..68

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 69.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

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

              def build_auth_digest(method, uri, params = nil)
                params = @opts.merge(@digest_params) if !params
                nonce_count = next_nonce
        
                user = unescape params[:username]
        Severity: Minor
        Found in lib/z-http/middleware/digest_auth.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 request has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

              def request(client, head, body)
                request = client.req
                uri     = request.uri.join(encode_query(request.uri, request.query))
                params  = {}
        
        
        Severity: Minor
        Found in lib/z-http/middleware/oauth.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 send_request has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def send_request(head, body)
              body    = normalize_body(body)
              file    = @req.file
              query   = @req.query
        
        
        Severity: Minor
        Found in lib/z-http/client.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 initialize has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

          def initialize(uri, options)
            @connect_timeout     = options[:connect_timeout] || 5        # default connection setup timeout
            @inactivity_timeout  = options[:inactivity_timeout] ||= 10   # default connection inactivity (post-setup) timeout
        
            @tls   = options[:tls] || options[:ssl] || {}
        Severity: Minor
        Found in lib/z-http/http_connection_options.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 form_encode_body has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def form_encode_body(obj)
              pairs = []
              recursive = Proc.new do |h, prefix|
                h.each do |k,v|
                  key = prefix == '' ? escape(k) : "#{prefix}[#{escape(k)}]"
        Severity: Minor
        Found in lib/z-http/http_encoding.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

        Avoid deeply nested control flow statements.
        Open

                      if buffer == 0
                        @state = :comment
                        break
                      end
        Severity: Major
        Found in lib/z-http/decoders.rb - About 45 mins to fix

          Method set_uri has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            def set_uri(uri, path = nil)
              uri = uri.kind_of?(Addressable::URI) ? uri : Addressable::URI::parse(uri.to_s)
              uri.path = path if path
              uri.path = '/' if uri.path.empty?
          
          
          Severity: Minor
          Found in lib/z-http/http_client_options.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

                        if buffer == 0
                          @state = :hcrc
                          break
                        end
          Severity: Major
          Found in lib/z-http/decoders.rb - About 45 mins to fix

            Method unbind has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def unbind(reason = nil)
                  @clients.map { |c| c.unbind(reason) }
            
                  if r = @pending.shift
                    @clients.push r
            Severity: Minor
            Found in lib/z-http/http_connection.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 finalize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def finalize
                  if @zstream
                    if !@zstream.finished?
                      r = @zstream.finish
                    end
            Severity: Minor
            Found in lib/z-http/decoders.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 encode_query has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def encode_query(uri, query)
                  encoded_query = if query.kind_of?(Hash)
                    query.map { |k, v| encode_param(k, v) }.join('&')
                  else
                    query.to_s
            Severity: Minor
            Found in lib/z-http/http_encoding.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