kaspernj/http2

View on GitHub
lib/http2/response_reader.rb

Summary

Maintainability
B
6 hrs
Test Coverage

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 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 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 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 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 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 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

There are no issues that match your filters.

Category
Status