kaspernj/http2

View on GitHub

Showing 22 of 22 total issues

Class Http2 has 28 methods (exceeds 20 allowed). Consider refactoring.
Open

class Http2
  # Autoloader for subclasses.
  def self.const_missing(name)
    file_path = "#{File.dirname(__FILE__)}/http2/#{::StringCases.camel_to_snake(name)}.rb"

Severity: Minor
Found in lib/http2.rb - About 3 hrs to fix

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

      def default_headers(args = {})
        return args[:default_headers] if args[:default_headers]
    
        headers = {
          "Connection" => "Keep-Alive",
    Severity: Minor
    Found in lib/http2.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 read_body has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

      def read_body
        loop do
          if @length
            line = @conn.read(@length)
            raise "Expected to get #{@length} of bytes but got #{line.bytesize}" if @length != line.bytesize
    Severity: Minor
    Found in lib/http2/response_reader.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 raw_data has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

      def raw_data
        if @args[:json]
          require "json" unless ::Kernel.const_defined?(:JSON)
          @args[:json].to_json
        elsif @args[:post].is_a?(String)
    Severity: Minor
    Found in lib/http2/post_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 parse_init_args has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

      def parse_init_args(args)
        args = {host: args} if args.is_a?(String)
        raise "Arguments wasnt a hash." unless args.is_a?(Hash)
    
        args.each_key do |key|
    Severity: Minor
    Found in lib/http2.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 read_headers has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

      def read_headers
        loop do
          line = @conn.gets
          check_line_read(line)
    
    
    Severity: Minor
    Found in lib/http2/response_reader.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 reconnect has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

      def reconnect
        puts "Http2: Reconnect." if @debug
    
        # Open connection.
        if @args[:proxy]
    Severity: Minor
    Found in lib/http2/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 socket_working? has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      def socket_working?
        return false if !@sock || @sock.closed?
    
        if @keepalive_timeout && @request_last
          between = Time.now.to_i - @request_last.to_i
    Severity: Minor
    Found in lib/http2/connection.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 parse_keep_alive has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      def parse_keep_alive(keep_alive_line)
        keep_alive_line.scan(/([a-z]+)=(\d+)/) do |match|
          if match[0] == "timeout"
            puts "Http2: Keepalive-max set to: '#{@keepalive_max}'." if @debug
            @http2.keepalive_timeout = match[1].to_i
    Severity: Minor
    Found in lib/http2/response_reader.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_header_special_values has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      def set_header_special_values(key, value)
        parse_cookie(value) if key == "set-cookie"
        parse_keep_alive(value) if key == "keep-alive"
        parse_content_type(value) if key == "content-type"
    
    
    Severity: Minor
    Found in lib/http2/response_reader.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 parse_body_chunked has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      def parse_body_chunked(line)
        len = line.strip.hex
    
        if len.positive?
          read = @conn.read(len)
    Severity: Minor
    Found in lib/http2/response_reader.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 parse_body has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def parse_body(line)
        return :break if @length&.zero?
    
        if @transfer_encoding == "chunked"
          parse_body_chunked(line)
    Severity: Minor
    Found in lib/http2/response_reader.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 finish has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def finish
        # Check if we should reconnect based on keep-alive-max.
        @conn.close if !@conn.closed? && (@keepalive_max == 1 || @connection == "close")
    
        # Validate that the response is as it should be.
    Severity: Minor
    Found in lib/http2/response_reader.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 connect_proxy_connect has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def connect_proxy_connect
        puts "Http2: Initializing proxy connect to '#{@args[:host]}:#{@args[:port]}' through proxy '#{@args[:proxy][:host]}:#{@args[:proxy][:port]}'." if @debug
        @sock_plain = TCPSocket.new(@args[:proxy][:host], @args[:proxy][:port])
    
        connect = "CONNECT #{@args[:host]}:#{@args[:port]} HTTP/1.1#{@nl}"
    Severity: Minor
    Found in lib/http2/connection.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 parse_set_cookies has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def self.parse_set_cookies(str)
        str = str.to_s
        return [] if str.empty?
    
        cookie_start_regex = /^(.+?)=(.*?)(;\s*|$)/
    Severity: Minor
    Found in lib/http2/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

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

      def validate_body_versus_content_length!
        unless header?("content-length")
          puts "Http2: No content length given - skipping length validation." if @debug
          return nil
        end
    Severity: Minor
    Found in lib/http2/response.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 set_default_values has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def set_default_values
        @debug = @args[:debug]
        @autostate_values = {} if autostate
        @nl = @args[:nl] || "\r\n"
    
    
    Severity: Minor
    Found in lib/http2.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_args has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def parse_args(*args)
        if args.length == 1 && args.first.is_a?(String)
          args = {url: args.first}
        elsif args.length == 1
          args = args.first
    Severity: Minor
    Found in lib/http2.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 build_params has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def build_params
        url_params = ""
    
        unless params.empty?
          first = true
    Severity: Minor
    Found in lib/http2/url_builder.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 write has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def write(str)
        reconnect unless socket_working?
    
        puts "Http2: Writing: #{str}" if @debug
    
    
    Severity: Minor
    Found in lib/http2/connection.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