rhenium/plum

View on GitHub
lib/plum/rack/session.rb

Summary

Maintainability
C
7 hrs
Test Coverage

Method new_env has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

      def new_env(h, data)
        ebase = {
          "rack.version"      => ::Rack::VERSION,
          "rack.input"        => StringIO.new(data),
          "rack.errors"       => $stderr,
Severity: Minor
Found in lib/plum/rack/session.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 new_env has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def new_env(h, data)
        ebase = {
          "rack.version"      => ::Rack::VERSION,
          "rack.input"        => StringIO.new(data),
          "rack.errors"       => $stderr,
Severity: Minor
Found in lib/plum/rack/session.rb - About 1 hr to fix

    Method setup_plum has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def setup_plum
            @plum.on(:connection_error) { |ex| @logger.error(ex) }
    
            # @plum.on(:stream) { |stream| @logger.debug("new stream: #{stream}") }
            @plum.on(:stream_error) { |stream, ex|
    Severity: Minor
    Found in lib/plum/rack/session.rb - About 1 hr to fix

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

            def handle_request(stream, headers, data)
              env = new_env(headers, data)
              r_status, r_rawheaders, r_body = @app.call(env)
              r_headers, r_extheaders = extract_headers(r_status, r_rawheaders)
              if @config[:server_push] && @plum.push_enabled?
      Severity: Minor
      Found in lib/plum/rack/session.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 setup_plum has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

            def setup_plum
              @plum.on(:connection_error) { |ex| @logger.error(ex) }
      
              # @plum.on(:stream) { |stream| @logger.debug("new stream: #{stream}") }
              @plum.on(:stream_error) { |stream, ex|
      Severity: Minor
      Found in lib/plum/rack/session.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 send_body has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

            def send_body(stream, body)
              begin
                if body.respond_to?(:to_str)
                  stream.send_data(body, end_stream: true)
                elsif body.respond_to?(:readpartial) && body.respond_to?(:eof?)
      Severity: Minor
      Found in lib/plum/rack/session.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 extract_headers has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

            def extract_headers(r_status, r_h)
              rbase = {
                ":status" => r_status,
                "server" => "plum/#{::Plum::VERSION}",
              }
      Severity: Minor
      Found in lib/plum/rack/session.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

      There are no issues that match your filters.

      Category
      Status