rhenium/plum

View on GitHub

Showing 46 of 67 total issues

Method stream has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def stream(stream_id, update_max_id = true)
      raise ArgumentError, "stream_id can't be 0" if stream_id == 0

      stream = @streams[stream_id]
      if stream
Severity: Minor
Found in lib/plum/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 run has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

      def run
        if @config[:fallback_legacy_host]
          @svc.logger.info "legacy HTTP: fallbacking to: #{@config[:fallback_legacy_host]}:#{@config[:fallback_legacy_port]}"
          upstream = TCPSocket.open(@config[:fallback_legacy_host], @config[:fallback_legacy_port])
          upstream.write(@e.buf) if @e.buf
Severity: Minor
Found in lib/plum/rack/legacy_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 has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def send(frame)
      if Frame::Data === frame
        @send_buffer << frame
        if @send_remaining_window < frame.length
          if Stream === self
Severity: Minor
Found in lib/plum/flow_control.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 spawn_worker has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

      def spawn_worker
        t = Thread.new {
          while true
            job, err = @jobs.pop
            begin
Severity: Minor
Found in lib/plum/rack/thread_pool.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 decode has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def decode(encoded)
        bits = encoded.unpack("B*")[0]
        out = []
        buf = "".b
        bits.each_char do |cb|
Severity: Minor
Found in lib/plum/hpack/huffman.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 receive_headers has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def receive_headers(frame)
      if @state == :reserved_local
        raise RemoteConnectionError.new(:protocol_error)
      elsif @state == :half_closed_remote
        raise RemoteStreamError.new(:stream_closed)
Severity: Minor
Found in lib/plum/stream.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 initialize has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def initialize(app, config)
        @config = config
        @state = :null
        @app = config[:debug] ? ::Rack::CommonLogger.new(app) : app
        @logger = Logger.new(config[:log] || $stdout).tap { |l| l.level = config[:debug] ? Logger::DEBUG : Logger::INFO }
Severity: Minor
Found in lib/plum/rack/server.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

Consider simplifying this complex logical expression.
Open

          if @options[:tls] == false
            config[:listeners] << { listener: TCPListener,
                                    hostname: @options[:host] || "0.0.0.0",
                                    port: @options[:port] || 8080 }
          else
Severity: Major
Found in lib/plum/rack/cli.rb - About 40 mins to fix

    Method _request_helper has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def _request_helper(method, path, body, options, &block)
    Severity: Minor
    Found in lib/plum/client.rb - About 35 mins to fix

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

            def accept(svc)
              sock = @server.accept
              Thread.start {
                begin
                  sock = sock.accept
      Severity: Minor
      Found in lib/plum/rack/listener.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 receive_window_update has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def receive_window_update(frame)
            if frame.length != 4
              raise Plum::RemoteConnectionError.new(:frame_size_error)
            end
      
      
      Severity: Minor
      Found in lib/plum/flow_control.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 receive_data has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def receive_data(frame)
            if @state != :open && @state != :half_closed_local
              raise RemoteStreamError.new(:stream_closed)
            end
      
      
      Severity: Minor
      Found in lib/plum/stream.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 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 each_byteslice has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

            def each_byteslice(n, &blk)
              if block_given?
                pos = 0
                while pos < self.bytesize
                  yield byteslice(pos, n)
      Severity: Minor
      Found in lib/plum/binary_string.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

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

          def consume_recv_window(frame)
            if Frame::Data === frame
              @recv_remaining_window -= frame.length
              if @recv_remaining_window < 0
                local_error = (Connection === self) ? RemoteConnectionError : RemoteStreamError
      Severity: Minor
      Found in lib/plum/flow_control.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 consume_queue has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def consume_queue
            return if @response || @requests.empty?
      
            response, headers, body, chunked = @requests.shift
            @response = response
      Severity: Minor
      Found in lib/plum/client/legacy_client_session.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 send_data has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def send_data(data = "", end_stream: true)
            max = @connection.remote_settings[:max_frame_size]
            if data.is_a?(IO)
              until data.eof?
                fragment = data.readpartial(max)
      Severity: Minor
      Found in lib/plum/stream.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 receive_complete_headers has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def receive_complete_headers(frames)
            first = frames.shift
            payload = first.payload
      
            if first.padded?
      Severity: Minor
      Found in lib/plum/stream.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 _start has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def _start
            @started = true
            nego = @socket || _connect
      
            if @config[:https]
      Severity: Minor
      Found in lib/plum/client.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