rhenium/plum

View on GitHub

Showing 67 of 67 total issues

File constants.rb has 328 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Plum
  module HPACK
    # RFC7541 Appendix A
    # index is starting from 0
    STATIC_TABLE = [
Severity: Minor
Found in lib/plum/hpack/constants.rb - About 3 hrs to fix

    Method start_tls_server has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

      def start_tls_server(&block)
        ctx = OpenSSL::SSL::SSLContext.new
        ctx.alpn_select_cb = -> protocols { "h2" }
        ctx.cert = TLS_CERT
        ctx.key = TLS_KEY
    Severity: Minor
    Found in test/plum/client/test_client.rb - About 2 hrs 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 transform_options has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

          def transform_options
            if @options[:config]
              dsl = DSL::Config.new.tap { |c| c.instance_eval(File.read(@options[:config])) }
              config = dsl.config
            else
    Severity: Minor
    Found in lib/plum/rack/cli.rb - About 2 hrs 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_parser has 50 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def setup_parser
            parser = OptionParser.new do |o|
              o.on "-C", "--config PATH", "Load PATH as a config" do |arg|
                @options[:config] = arg
              end
    Severity: Minor
    Found in lib/plum/rack/cli.rb - About 2 hrs to fix

      Method start_tls_server has 47 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def start_tls_server(&block)
          ctx = OpenSSL::SSL::SSLContext.new
          ctx.alpn_select_cb = -> protocols { "h2" }
          ctx.cert = TLS_CERT
          ctx.key = TLS_KEY
      Severity: Minor
      Found in test/plum/client/test_client.rb - About 1 hr to fix

        Method test_inadequate_security_ssl_socket has 45 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def test_inadequate_security_ssl_socket
            run = false
        
            ctx = OpenSSL::SSL::SSLContext.new
            ctx.alpn_select_cb = -> protocols { "h2" }
        Severity: Minor
        Found in test/plum/server/test_connection.rb - About 1 hr to fix

          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

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

                def split(max)
                  return yield self if @length <= max
                  first, *mid, last = @payload.chunk(max)
                  yield Frame.craft(type_value: @type_value, stream_id: @stream_id, payload: first, flags_value: @flags_value & ~4)
                  mid.each { |slice|
            Severity: Major
            Found in lib/plum/frame/headers.rb and 1 other location - About 1 hr to fix
            lib/plum/frame/push_promise.rb on lines 23..31

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

            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

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

                def split(max)
                  return yield self if @length <= max
                  first, *mid, last = @payload.chunk(max)
                  yield Frame.craft(type_value: @type_value, stream_id: @stream_id, payload: first, flags_value: @flags_value & ~4)
                  mid.each { |slice|
            Severity: Major
            Found in lib/plum/frame/push_promise.rb and 1 other location - About 1 hr to fix
            lib/plum/frame/headers.rb on lines 22..30

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

            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 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 transform_options has 33 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    def transform_options
                      if @options[:config]
                        dsl = DSL::Config.new.tap { |c| c.instance_eval(File.read(@options[:config])) }
                        config = dsl.config
                      else
              Severity: Minor
              Found in lib/plum/rack/cli.rb - About 1 hr to fix

                Method test_inadequate_security_ssl_socket has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                  def test_inadequate_security_ssl_socket
                    run = false
                
                    ctx = OpenSSL::SSL::SSLContext.new
                    ctx.alpn_select_cb = -> protocols { "h2" }
                Severity: Minor
                Found in test/plum/server/test_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 initialize has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                      def initialize(lc)
                        if lc[:certificate] && lc[:certificate_key]
                          cert = File.read(lc[:certificate])
                          key = File.read(lc[:certificate_key])
                        else
                Severity: Minor
                Found in lib/plum/rack/listener.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 validate_received_frame has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                    def validate_received_frame(frame)
                      if @state == :waiting_settings && !(Frame::Settings === frame)
                        raise RemoteConnectionError.new(:protocol_error)
                      end
                
                
                Severity: Minor
                Found in lib/plum/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 update_dependency has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                    def update_dependency(weight: nil, parent: nil, exclusive: nil)
                      raise RemoteStreamError.new(:protocol_error, "A stream cannot depend on itself.") if parent == self
                
                      if weight
                        @weight = weight
                Severity: Minor
                Found in lib/plum/stream.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 request has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def request(headers, body, options, &headers_cb)
                      headers = { ":method" => nil,
                                  ":path" => nil,
                                  ":authority" => @config[:hostname],
                                  ":scheme" => @config[:https] ? "https" : "http",
                Severity: Minor
                Found in lib/plum/client/client_session.rb - About 1 hr to fix

                  Method initialize has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                        def initialize(lc)
                          if lc[:certificate] && lc[:certificate_key]
                            cert = File.read(lc[:certificate])
                            key = File.read(lc[:certificate_key])
                          else
                  Severity: Minor
                  Found in lib/plum/rack/listener.rb - About 1 hr to fix

                    Method test_server_must_raise_frame_size_error_when_exeeeded_max_size has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def test_server_must_raise_frame_size_error_when_exeeeded_max_size
                        _settings = "".push_uint16(Frame::Settings::SETTINGS_TYPE[:max_frame_size]).push_uint32(2**14)
                        limit = 2 ** 14
                    
                        new_con = -> (&blk) {
                    Severity: Minor
                    Found in test/plum/test_connection.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

                      Severity
                      Category
                      Status
                      Source
                      Language