rhenium/plum

View on GitHub

Showing 67 of 67 total issues

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

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

        prepare.call { |con, stream|
          stream.window_update(500) # extend only stream
          con << Frame::Headers.new(stream.id, "", end_headers: true).assemble
          assert_connection_error(:flow_control_error) {
            con << Frame::Data.new(stream.id, "\x00" * 30, end_stream: true).assemble
    Severity: Minor
    Found in test/plum/test_flow_control.rb and 1 other location - About 40 mins to fix
    test/plum/test_flow_control.rb on lines 108..112

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

    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

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

        prepare.call { |con, stream|
          con.window_update(500) # extend only connection
          con << Frame::Headers.new(stream.id, "", end_headers: true).assemble
          assert_stream_error(:flow_control_error) {
            con << Frame::Data.new(stream.id, "\x00" * 30, end_stream: true).assemble
    Severity: Minor
    Found in test/plum/test_flow_control.rb and 1 other location - About 40 mins to fix
    test/plum/test_flow_control.rb on lines 116..120

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

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

      Severity
      Category
      Status
      Source
      Language